mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.
opt: check `private key` size opt: expand key list in default
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../data/res/misc.dart';
|
||||||
|
|
||||||
/// format: [NAME][LEVEL]: MESSAGE
|
/// format: [NAME][LEVEL]: MESSAGE
|
||||||
final _headReg = RegExp(r'(\[[A-Za-z]+\])(\[[A-Z]+\]): (.*)');
|
final _headReg = RegExp(r'(\[[A-Za-z]+\])(\[[A-Z]+\]): (.*)');
|
||||||
const _level2Color = {
|
const _level2Color = {
|
||||||
@@ -14,7 +16,7 @@ class DebugProvider extends ChangeNotifier {
|
|||||||
final match = _headReg.allMatches(text);
|
final match = _headReg.allMatches(text);
|
||||||
|
|
||||||
if (match.isNotEmpty) {
|
if (match.isNotEmpty) {
|
||||||
addWidget(Text.rich(TextSpan(
|
_addWidget(Text.rich(TextSpan(
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: match.first.group(1),
|
text: match.first.group(1),
|
||||||
@@ -30,31 +32,11 @@ class DebugProvider extends ChangeNotifier {
|
|||||||
],
|
],
|
||||||
)));
|
)));
|
||||||
} else {
|
} else {
|
||||||
_addText(text);
|
_addWidget(Text(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addText(String text) {
|
|
||||||
_addWidget(Text(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
void addError(Object error) {
|
|
||||||
_addError(error);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addError(Object error) {
|
|
||||||
_addMultiline(error, Colors.red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMultiline(Object data, [Color color = Colors.blue]) {
|
void addMultiline(Object data, [Color color = Colors.blue]) {
|
||||||
_addMultiline(data, color);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addMultiline(Object data, [Color color = Colors.blue]) {
|
|
||||||
final widget = Text(
|
final widget = Text(
|
||||||
'$data',
|
'$data',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -67,14 +49,13 @@ class DebugProvider extends ChangeNotifier {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addWidget(Widget widget) {
|
|
||||||
_addWidget(widget);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addWidget(Widget widget) {
|
void _addWidget(Widget widget) {
|
||||||
widgets.add(widget);
|
widgets.add(widget);
|
||||||
widgets.add(const SizedBox(height: 13));
|
widgets.add(const SizedBox(height: 13));
|
||||||
|
if (widgets.length > maxDebugLogLines) {
|
||||||
|
widgets.removeRange(0, widgets.length - maxDebugLogLines);
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ final numReg = RegExp(r'\s{1,}');
|
|||||||
|
|
||||||
/// Private Key max allowed size is 20kb
|
/// Private Key max allowed size is 20kb
|
||||||
const privateKeyMaxSize = 20 * 1024;
|
const privateKeyMaxSize = 20 * 1024;
|
||||||
|
|
||||||
|
/// Max debug log lines
|
||||||
|
const maxDebugLogLines = 100;
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ void runInZone(dynamic Function() body) {
|
|||||||
void onError(Object obj, StackTrace stack) {
|
void onError(Object obj, StackTrace stack) {
|
||||||
Analysis.recordException(obj);
|
Analysis.recordException(obj);
|
||||||
final debugProvider = locator<DebugProvider>();
|
final debugProvider = locator<DebugProvider>();
|
||||||
debugProvider.addError(obj);
|
debugProvider.addMultiline(obj, Colors.red);
|
||||||
debugProvider.addError(stack);
|
debugProvider.addMultiline(stack, Colors.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import '../../data/model/app/dynamic_color.dart';
|
|||||||
import '../../data/model/app/navigation_item.dart';
|
import '../../data/model/app/navigation_item.dart';
|
||||||
import '../../data/provider/server.dart';
|
import '../../data/provider/server.dart';
|
||||||
import '../../data/res/build_data.dart';
|
import '../../data/res/build_data.dart';
|
||||||
import '../../data/res/color.dart';
|
|
||||||
import '../../data/res/font_style.dart';
|
import '../../data/res/font_style.dart';
|
||||||
import '../../data/res/icon.dart';
|
import '../../data/res/icon.dart';
|
||||||
import '../../data/res/tab.dart';
|
import '../../data/res/tab.dart';
|
||||||
@@ -284,7 +283,7 @@ class _MyHomePageState extends State<MyHomePage>
|
|||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxHeight: 53, maxWidth: 53),
|
constraints: const BoxConstraints(maxHeight: 53, maxWidth: 53),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: primaryColor,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
Widget _buildSwapView(ServerStatus ss) {
|
Widget _buildSwapView(ServerStatus ss) {
|
||||||
if (ss.swap.total == 0) return const SizedBox();
|
if (ss.swap.total == 0) return const SizedBox();
|
||||||
final used = ss.swap.used / ss.swap.total * 100;
|
final used = ss.swap.used / ss.swap.total * 100;
|
||||||
final free = ss.swap.free / ss.swap.total * 100;
|
|
||||||
final cached = ss.swap.cached / ss.swap.total * 100;
|
final cached = ss.swap.cached / ss.swap.total * 100;
|
||||||
return RoundRectCard(
|
return RoundRectCard(
|
||||||
Padding(
|
Padding(
|
||||||
@@ -264,13 +263,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
style: textSize13Grey)
|
style: textSize13Grey)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
_buildDetailPercent(cached, 'cached'),
|
||||||
children: [
|
|
||||||
_buildDetailPercent(free, 'free'),
|
|
||||||
width13,
|
|
||||||
_buildDetailPercent(cached, 'cached')
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
height13,
|
height13,
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
iconColor: primaryColor,
|
iconColor: primaryColor,
|
||||||
tilePadding: EdgeInsets.zero,
|
tilePadding: EdgeInsets.zero,
|
||||||
childrenPadding: EdgeInsets.zero,
|
childrenPadding: EdgeInsets.zero,
|
||||||
|
initiallyExpanded: true,
|
||||||
title: Text(
|
title: Text(
|
||||||
_s.choosePrivateKey,
|
_s.choosePrivateKey,
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 14),
|
||||||
|
|||||||
Reference in New Issue
Block a user