mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Add debug page.
This commit is contained in:
@@ -140,17 +140,6 @@ class _AppSettingsState extends State<AppSettings> {
|
|||||||
},
|
},
|
||||||
actionTitle: 'Set'.tl,
|
actionTitle: 'Set'.tl,
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
_SettingPartTitle(
|
|
||||||
title: "Log".tl,
|
|
||||||
icon: Icons.error_outline,
|
|
||||||
),
|
|
||||||
_CallbackSetting(
|
|
||||||
title: "Open Log".tl,
|
|
||||||
callback: () {
|
|
||||||
context.to(() => const LogsPage());
|
|
||||||
},
|
|
||||||
actionTitle: 'Open'.tl,
|
|
||||||
).toSliver(),
|
|
||||||
_SettingPartTitle(
|
_SettingPartTitle(
|
||||||
title: "User".tl,
|
title: "User".tl,
|
||||||
icon: Icons.person_outline,
|
icon: Icons.person_outline,
|
||||||
|
95
lib/pages/settings/debug.dart
Normal file
95
lib/pages/settings/debug.dart
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
part of 'settings_page.dart';
|
||||||
|
|
||||||
|
class DebugPage extends StatefulWidget {
|
||||||
|
const DebugPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DebugPage> createState() => DebugPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class DebugPageState extends State<DebugPage> {
|
||||||
|
final controller = TextEditingController();
|
||||||
|
|
||||||
|
var result = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SmoothCustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverAppbar(title: Text("Debug".tl)),
|
||||||
|
_CallbackSetting(
|
||||||
|
title: "Reload Configs",
|
||||||
|
actionTitle: "Reload",
|
||||||
|
callback: () {
|
||||||
|
ComicSourceManager().reload();
|
||||||
|
},
|
||||||
|
).toSliver(),
|
||||||
|
_CallbackSetting(
|
||||||
|
title: "Open Log".tl,
|
||||||
|
callback: () {
|
||||||
|
context.to(() => const LogsPage());
|
||||||
|
},
|
||||||
|
actionTitle: 'Open'.tl,
|
||||||
|
).toSliver(),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text(
|
||||||
|
"JS Evaluator",
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
).toAlign(Alignment.centerLeft).paddingLeft(16),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 200,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
|
child: TextField(
|
||||||
|
controller: controller,
|
||||||
|
maxLines: null,
|
||||||
|
expands: true,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
textAlignVertical: TextAlignVertical.top,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
contentPadding: const EdgeInsets.all(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
try {
|
||||||
|
var res = JsEngine().runCode(controller.text);
|
||||||
|
setState(() {
|
||||||
|
result = res.toString();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
result = e.toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text("Run"),
|
||||||
|
).toAlign(Alignment.centerRight).paddingRight(16),
|
||||||
|
const Text(
|
||||||
|
"Result",
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
).toAlign(Alignment.centerLeft).paddingLeft(16),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 200,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: context.colorScheme.outline),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Text(result).paddingAll(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -30,6 +30,7 @@ part 'local_favorites.dart';
|
|||||||
part 'app.dart';
|
part 'app.dart';
|
||||||
part 'about.dart';
|
part 'about.dart';
|
||||||
part 'network.dart';
|
part 'network.dart';
|
||||||
|
part 'debug.dart';
|
||||||
|
|
||||||
class SettingsPage extends StatefulWidget {
|
class SettingsPage extends StatefulWidget {
|
||||||
const SettingsPage({this.initialPage = -1, super.key});
|
const SettingsPage({this.initialPage = -1, super.key});
|
||||||
@@ -55,6 +56,7 @@ class _SettingsPageState extends State<SettingsPage> implements PopEntry {
|
|||||||
"APP",
|
"APP",
|
||||||
"Network",
|
"Network",
|
||||||
"About",
|
"About",
|
||||||
|
"Debug"
|
||||||
];
|
];
|
||||||
|
|
||||||
final icons = <IconData>[
|
final icons = <IconData>[
|
||||||
@@ -64,7 +66,8 @@ class _SettingsPageState extends State<SettingsPage> implements PopEntry {
|
|||||||
Icons.collections_bookmark_rounded,
|
Icons.collections_bookmark_rounded,
|
||||||
Icons.apps,
|
Icons.apps,
|
||||||
Icons.public,
|
Icons.public,
|
||||||
Icons.info
|
Icons.info,
|
||||||
|
Icons.bug_report,
|
||||||
];
|
];
|
||||||
|
|
||||||
double offset = 0;
|
double offset = 0;
|
||||||
@@ -350,6 +353,7 @@ class _SettingsPageState extends State<SettingsPage> implements PopEntry {
|
|||||||
4 => const AppSettings(),
|
4 => const AppSettings(),
|
||||||
5 => const NetworkSettings(),
|
5 => const NetworkSettings(),
|
||||||
6 => const AboutSettings(),
|
6 => const AboutSettings(),
|
||||||
|
7 => const DebugPage(),
|
||||||
_ => throw UnimplementedError()
|
_ => throw UnimplementedError()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user