opt.: debug page (#259)

This commit is contained in:
lollipopkit
2024-01-28 15:43:11 +08:00
parent 799a1ac5f0
commit b9640c380f
4 changed files with 20 additions and 23 deletions

View File

@@ -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,22 +37,18 @@ 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: Consumer<DebugProvider>(
builder: (_, debug, __) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: debug.widgets,
);
},
),
child: ChangeNotifierProvider.value(
value: Pros.debug,
child: Consumer<DebugProvider>(
builder: (_, provider, __) {
return ListView(
key: ValueKey(provider.widgets.length),
reverse: true,
children: provider.widgets,
);
},
),
),
),