mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: debug page (#259)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/extension/datetime.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
|
||||
import '../../data/res/misc.dart';
|
||||
@@ -17,7 +18,7 @@ class DebugProvider extends ChangeNotifier {
|
||||
widgets.add(Text.rich(TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '[${record.loggerName}]',
|
||||
text: '[${DateTime.now().hourMinute}][${record.loggerName}]',
|
||||
style: const TextStyle(color: Colors.cyan),
|
||||
),
|
||||
TextSpan(
|
||||
|
||||
@@ -53,5 +53,6 @@ abstract final class GithubIds {
|
||||
'aliuzzz',
|
||||
'58fly',
|
||||
'Potterli20',
|
||||
'Seifon',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:toolbox/core/build_mode.dart';
|
||||
import 'package:toolbox/core/channel/bg_run.dart';
|
||||
import 'package:toolbox/core/utils/sync/icloud.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
@@ -81,7 +80,6 @@ Future<void> _initApp() async {
|
||||
Computer.shared.turnOn(
|
||||
// Plus 1 to avoid 0.
|
||||
workersCount: (Stores.server.box.keys.length / 3).round() + 1,
|
||||
verbose: !BuildMode.isRelease,
|
||||
);
|
||||
_setupLogger();
|
||||
_setupProviders();
|
||||
|
||||
@@ -6,14 +6,9 @@ import 'package:toolbox/data/res/provider.dart';
|
||||
|
||||
import '../widget/appbar.dart';
|
||||
|
||||
class DebugPage extends StatefulWidget {
|
||||
class DebugPage extends StatelessWidget {
|
||||
const DebugPage({super.key});
|
||||
|
||||
@override
|
||||
_DebugPageState createState() => _DebugPageState();
|
||||
}
|
||||
|
||||
class _DebugPageState extends State<DebugPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -24,6 +19,12 @@ class _DebugPageState extends State<DebugPage> {
|
||||
),
|
||||
title: const Text('Logs', style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: Colors.black,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => Pros.debug.clear(),
|
||||
icon: const Icon(Icons.delete, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _buildTerminal(context),
|
||||
backgroundColor: Colors.black,
|
||||
@@ -36,25 +37,21 @@ class _DebugPageState extends State<DebugPage> {
|
||||
color: Colors.black,
|
||||
child: DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: ChangeNotifierProvider(
|
||||
create: (_) => Pros.debug,
|
||||
child: ChangeNotifierProvider.value(
|
||||
value: Pros.debug,
|
||||
child: Consumer<DebugProvider>(
|
||||
builder: (_, debug, __) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: debug.widgets,
|
||||
builder: (_, provider, __) {
|
||||
return ListView(
|
||||
key: ValueKey(provider.widgets.length),
|
||||
reverse: true,
|
||||
children: provider.widgets,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user