SimpleCloudNotifier/flutter/lib/pages/debug/debug_main.dart

76 lines
2.9 KiB
Dart
Raw Normal View History

2024-05-23 17:41:51 +02:00
import 'package:flutter/material.dart';
2024-05-31 23:21:24 +02:00
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
2024-05-23 17:41:51 +02:00
import 'package:simplecloudnotifier/components/layout/scaffold.dart';
2024-05-31 23:21:24 +02:00
import 'package:simplecloudnotifier/pages/debug/debug_actions.dart';
2024-05-23 17:41:51 +02:00
import 'package:simplecloudnotifier/pages/debug/debug_colors.dart';
2024-05-25 18:09:39 +02:00
import 'package:simplecloudnotifier/pages/debug/debug_logs.dart';
2024-05-23 17:41:51 +02:00
import 'package:simplecloudnotifier/pages/debug/debug_persistence.dart';
import 'package:simplecloudnotifier/pages/debug/debug_requests.dart';
class DebugMainPage extends StatefulWidget {
@override
_DebugMainPageState createState() => _DebugMainPageState();
}
2024-05-31 23:21:24 +02:00
enum DebugMainPageSubPage { colors, requests, persistence, logs, actions }
2024-05-23 17:41:51 +02:00
class _DebugMainPageState extends State<DebugMainPage> {
final Map<DebugMainPageSubPage, Widget> _subpages = {
DebugMainPageSubPage.colors: DebugColorsPage(),
DebugMainPageSubPage.requests: DebugRequestsPage(),
DebugMainPageSubPage.persistence: DebugPersistencePage(),
2024-05-25 18:09:39 +02:00
DebugMainPageSubPage.logs: DebugLogsPage(),
2024-05-31 23:21:24 +02:00
DebugMainPageSubPage.actions: DebugActionsPage(),
2024-05-23 17:41:51 +02:00
};
DebugMainPageSubPage _subPage = DebugMainPageSubPage.colors;
@override
Widget build(BuildContext context) {
return SCNScaffold(
title: 'Debug',
showSearch: false,
showDebug: false,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buildSegButton(context),
],
),
),
Expanded(
child: _subpages[_subPage]!,
),
],
),
);
}
Widget buildSegButton(BuildContext context) {
return SegmentedButton<DebugMainPageSubPage>(
showSelectedIcon: false,
segments: const <ButtonSegment<DebugMainPageSubPage>>[
2024-05-31 23:21:24 +02:00
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.colors, icon: Icon(FontAwesomeIcons.solidPaintRoller, size: 14)),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.actions, icon: Icon(FontAwesomeIcons.solidHammer, size: 14)),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.requests, icon: Icon(FontAwesomeIcons.solidNetworkWired, size: 14)),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.persistence, icon: Icon(FontAwesomeIcons.solidFloppyDisk, size: 14)),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.logs, icon: Icon(FontAwesomeIcons.solidFileLines, size: 14)),
2024-05-23 17:41:51 +02:00
],
2024-05-31 23:21:24 +02:00
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.fromLTRB(0, 0, 0, 0)),
visualDensity: VisualDensity(horizontal: -3, vertical: -3),
),
2024-05-23 17:41:51 +02:00
selected: <DebugMainPageSubPage>{_subPage},
onSelectionChanged: (Set<DebugMainPageSubPage> v) {
setState(() {
_subPage = v.first;
});
},
);
}
}