From ce25382f1b5ccf648b3f2114ab82c7de13c58ca1 Mon Sep 17 00:00:00 2001 From: Atamert Rahma Date: Fri, 11 Oct 2024 12:24:35 +0200 Subject: [PATCH] snackbar notif component, connectivity check Issue: #541 --- lib/components/notifs/snackbar.dart | 25 +++++++++++++++++++++++++ lib/pages/editor/editor.dart | 5 ++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 lib/components/notifs/snackbar.dart diff --git a/lib/components/notifs/snackbar.dart b/lib/components/notifs/snackbar.dart new file mode 100644 index 000000000..0837f8e0d --- /dev/null +++ b/lib/components/notifs/snackbar.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +class SnackBarNotification extends StatelessWidget { + final String message; + + const SnackBarNotification({ + super.key, + required this.message, + }); + + @override + Widget build(BuildContext context) { + return SnackBar( + content: Text(message), + ); + } + + static void show(BuildContext context, {required String message}) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + ), + ); + } +} diff --git a/lib/pages/editor/editor.dart b/lib/pages/editor/editor.dart index b53bcd237..503ee0fa3 100644 --- a/lib/pages/editor/editor.dart +++ b/lib/pages/editor/editor.dart @@ -21,6 +21,7 @@ import 'package:saber/components/canvas/canvas_preview.dart'; import 'package:saber/components/canvas/image/editor_image.dart'; import 'package:saber/components/canvas/save_indicator.dart'; import 'package:saber/components/navbar/responsive_navbar.dart'; +import 'package:saber/components/notifs/snackbar.dart'; import 'package:saber/components/theming/adaptive_alert_dialog.dart'; import 'package:saber/components/theming/adaptive_icon.dart'; import 'package:saber/components/theming/dynamic_material_app.dart'; @@ -1722,9 +1723,7 @@ class EditorState extends State { void snackBarNeedsToSaveBeforeExiting() { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(t.editor.needsToSaveBeforeExiting), - )); + SnackBarNotification.show(context, message: t.editor.needsToSaveBeforeExiting); } Widget bottomSheet(BuildContext context) {