diff --git a/flutter/Makefile b/flutter/Makefile index fa52657..f459fc4 100644 --- a/flutter/Makefile +++ b/flutter/Makefile @@ -6,26 +6,28 @@ # sudo archlinux-java set java-17-openjdk # - +java: + sudo archlinux-java set java-17-openjdk + java -version # runs app locally (linux) -run-linux: gen +run-linux: java gen dart run build_runner build _JAVA_OPTIONS="" flutter run -d linux # runs app locally (web | not really supported) -run-web: gen +run-web: java gen dart run build_runner build _JAVA_OPTIONS="" flutter run -d chrome # runs on android device (must have network adb enabled teh correct IP) -run-android: gen +run-android: java gen ping -c1 10.10.10.177 adb connect 10.10.10.177:5555 flutter pub run build_runner build _JAVA_OPTIONS="" flutter run -d 10.10.10.177:5555 -install-release: gen +install-release: java gen # Install on Pixel 7a flutter build apk --release flutter run --release -d 35221JEHN07157 @@ -41,7 +43,7 @@ test: fix: dart fix --apply -gen: +gen: java ./_utils/inc_buildnum.sh dart run build_runner build dart run git_stamp git_stamp --build-type lite --limit 2 @@ -62,7 +64,7 @@ clean: # https://docs.flutter.dev/release/upgrade # upgrading flutter can be done via `flutter upgrade`: https://docs.flutter.dev/release/upgrade # android/gradle updates should be done via androidStudio: https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide -upgrade: +upgrade: flutter upgrade flutter pub upgrade flutter doctor diff --git a/flutter/lib/main.dart b/flutter/lib/main.dart index 5974862..8297ef3 100644 --- a/flutter/lib/main.dart +++ b/flutter/lib/main.dart @@ -205,7 +205,7 @@ void main() async { final appLaunchNotification = await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails(); if (appLaunchNotification != null) { - // Use has launched SCN by clicking on a loca notifiaction, if it was a summary or message notifiaction open the corresponding screen + // Use has launched SCN by clicking on a local notifiaction, if it was a summary or message notifiaction open the corresponding screen // This is android only //TODO same on iOS, somehow?? ApplicationLog.info('App launched by notification: ${appLaunchNotification.notificationResponse?.id}'); @@ -216,6 +216,8 @@ void main() async { ApplicationLog.debug('[INIT] Application started'); + Globals().appWidgetInitialized = true; + runApp( MultiProvider( providers: [ diff --git a/flutter/lib/state/globals.dart b/flutter/lib/state/globals.dart index 314ddb1..d8c14fe 100644 --- a/flutter/lib/state/globals.dart +++ b/flutter/lib/state/globals.dart @@ -17,6 +17,8 @@ class Globals { bool _initialized = false; + bool appWidgetInitialized = false; + String appName = ''; String packageName = ''; String version = ''; diff --git a/flutter/lib/utils/toaster.dart b/flutter/lib/utils/toaster.dart index 526e19a..1ec2f2b 100644 --- a/flutter/lib/utils/toaster.dart +++ b/flutter/lib/utils/toaster.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:simplecloudnotifier/state/globals.dart'; import 'package:toastification/toastification.dart'; class Toaster { @@ -10,6 +11,13 @@ class Toaster { static final borderRadius = BorderRadius.circular(4.0); static void simple(String title) { + print('[TOAST]: [[SIMPLE]] $title'); + + if (!Globals().appWidgetInitialized) { + print('[TOAST]: Cannot show simple-toast - app not initialized - skipping'); + return; + } + toastification.show( type: ToastificationType.success, style: ToastificationStyle.simple, @@ -17,7 +25,7 @@ class Toaster { description: Text(title), autoCloseDuration: autoCloseDuration, borderRadius: borderRadius, - closeButtonShowType: CloseButtonShowType.none, + closeButton: ToastCloseButton(showType: CloseButtonShowType.none), alignment: alignment, animationDuration: animationDuration, pauseOnHover: false, @@ -28,6 +36,13 @@ class Toaster { } static void success(String title, String message) { + print('[TOAST]: [[SUCC]] $title:\n$message'); + + if (!Globals().appWidgetInitialized) { + print('[TOAST]: Cannot show succ-toast - app not initialized - skipping'); + return; + } + toastification.show( type: ToastificationType.success, style: ToastificationStyle.flatColored, @@ -35,7 +50,7 @@ class Toaster { description: Text(message), autoCloseDuration: autoCloseDuration, borderRadius: borderRadius, - closeButtonShowType: CloseButtonShowType.none, + closeButton: ToastCloseButton(showType: CloseButtonShowType.none), alignment: alignment, animationDuration: animationDuration, pauseOnHover: false, @@ -46,6 +61,13 @@ class Toaster { } static void info(String title, String message) { + print('[TOAST]: [[INFO]] $title:\n$message'); + + if (!Globals().appWidgetInitialized) { + print('[TOAST]: Cannot show info-toast - app not initialized - skipping'); + return; + } + toastification.show( type: ToastificationType.info, style: ToastificationStyle.flatColored, @@ -53,7 +75,7 @@ class Toaster { description: Text(message), autoCloseDuration: autoCloseDuration, borderRadius: borderRadius, - closeButtonShowType: CloseButtonShowType.none, + closeButton: ToastCloseButton(showType: CloseButtonShowType.none), alignment: alignment, animationDuration: animationDuration, pauseOnHover: false, @@ -64,6 +86,13 @@ class Toaster { } static void warn(String title, String message) { + print('[TOAST]: [[WARN]] $title:\n$message'); + + if (!Globals().appWidgetInitialized) { + print('[TOAST]: Cannot show warn-toast - app not initialized - skipping'); + return; + } + toastification.show( type: ToastificationType.warning, style: ToastificationStyle.flatColored, @@ -71,7 +100,7 @@ class Toaster { description: Text(message), autoCloseDuration: autoCloseDuration, borderRadius: borderRadius, - closeButtonShowType: CloseButtonShowType.none, + closeButton: ToastCloseButton(showType: CloseButtonShowType.none), alignment: alignment, animationDuration: animationDuration, pauseOnHover: false, @@ -82,6 +111,13 @@ class Toaster { } static void error(String title, String message) { + print('[TOAST]: [[ERROR]] $title:\n$message'); + + if (!Globals().appWidgetInitialized) { + print('[TOAST]: Cannot show error-toast - app not initialized - skipping'); + return; + } + toastification.show( type: ToastificationType.error, style: ToastificationStyle.flatColored, @@ -89,7 +125,7 @@ class Toaster { description: Text(message), autoCloseDuration: autoCloseDuration, borderRadius: borderRadius, - closeButtonShowType: CloseButtonShowType.none, + closeButton: ToastCloseButton(showType: CloseButtonShowType.none), alignment: alignment, animationDuration: animationDuration, pauseOnHover: false, diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 0aae14b..5f9369e 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: simplecloudnotifier description: "Receive push messages" publish_to: 'none' -version: 2.0.0+481 +version: 2.0.0+484 environment: sdk: '>=3.2.6 <4.0.0'