Switch to better notification library

This commit is contained in:
2024-05-31 23:21:24 +02:00
parent dfcee5dfc7
commit d5d89ee93a
15 changed files with 320 additions and 65 deletions

View File

@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:simplecloudnotifier/utils/toaster.dart';
import 'package:toastification/toastification.dart';
class DebugActionsPage extends StatefulWidget {
@override
_DebugActionsPageState createState() => _DebugActionsPageState();
}
class _DebugActionsPageState extends State<DebugActionsPage> {
@override
Widget build(BuildContext context) {
return Container(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () => Toaster.success("Hello World", "This was a triumph!"),
child: const Text('Show Success Notification'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () => Toaster.info("Hello World", "This was a triumph!"),
child: const Text('Show Info Notification'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () => Toaster.warn("Hello World", "This was a triumph!"),
child: const Text('Show Warn Notification'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () => Toaster.error("Hello World", "This was a triumph!"),
child: const Text('Show Info Notification'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () => Toaster.simple("Hello World"),
child: const Text('Show Simple Notification'),
),
SizedBox(height: 20),
],
),
),
),
);
}
}

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:simplecloudnotifier/components/layout/scaffold.dart';
import 'package:simplecloudnotifier/pages/debug/debug_actions.dart';
import 'package:simplecloudnotifier/pages/debug/debug_colors.dart';
import 'package:simplecloudnotifier/pages/debug/debug_logs.dart';
import 'package:simplecloudnotifier/pages/debug/debug_persistence.dart';
@@ -10,7 +12,7 @@ class DebugMainPage extends StatefulWidget {
_DebugMainPageState createState() => _DebugMainPageState();
}
enum DebugMainPageSubPage { colors, requests, persistence, logs }
enum DebugMainPageSubPage { colors, requests, persistence, logs, actions }
class _DebugMainPageState extends State<DebugMainPage> {
final Map<DebugMainPageSubPage, Widget> _subpages = {
@@ -18,6 +20,7 @@ class _DebugMainPageState extends State<DebugMainPage> {
DebugMainPageSubPage.requests: DebugRequestsPage(),
DebugMainPageSubPage.persistence: DebugPersistencePage(),
DebugMainPageSubPage.logs: DebugLogsPage(),
DebugMainPageSubPage.actions: DebugActionsPage(),
};
DebugMainPageSubPage _subPage = DebugMainPageSubPage.colors;
@@ -51,11 +54,16 @@ class _DebugMainPageState extends State<DebugMainPage> {
return SegmentedButton<DebugMainPageSubPage>(
showSelectedIcon: false,
segments: const <ButtonSegment<DebugMainPageSubPage>>[
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.colors, label: Text('Theme')),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.requests, label: Text('Requests')),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.persistence, label: Text('Persistence')),
ButtonSegment<DebugMainPageSubPage>(value: DebugMainPageSubPage.logs, label: Text('Logs')),
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)),
],
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.fromLTRB(0, 0, 0, 0)),
visualDensity: VisualDensity(horizontal: -3, vertical: -3),
),
selected: <DebugMainPageSubPage>{_subPage},
onSelectionChanged: (Set<DebugMainPageSubPage> v) {
setState(() {

View File

@@ -1,9 +1,9 @@
import 'package:fl_toast/fl_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:simplecloudnotifier/components/layout/scaffold.dart';
import 'package:simplecloudnotifier/state/request_log.dart';
import 'package:simplecloudnotifier/utils/toaster.dart';
class DebugRequestViewPage extends StatelessWidget {
final SCNRequest request;
@@ -64,7 +64,7 @@ class DebugRequestViewPage extends StatelessWidget {
constraints: BoxConstraints(),
onPressed: () {
Clipboard.setData(new ClipboardData(text: value));
showPlatformToast(child: Text('Copied to clipboard'), context: ToastProvider.context);
Toaster.info("Clipboard", 'Copied text to Clipboard');
},
),
],