diff --git a/lib/main.dart b/lib/main.dart index c797b64f..900027bf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -28,10 +28,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:intl/intl.dart'; import 'package:moment_dart/moment_dart.dart'; -import 'package:oktoast/oktoast.dart'; import 'package:pie_menu/pie_menu.dart'; -const appVersion = "0.1.2+4"; +const appVersion = "0.1.3+5"; final String namedVersion = appVersion.split("+").first; final int buildNumber = int.parse(appVersion.split("+").last); @@ -99,26 +98,21 @@ class FlowState extends State { @override Widget build(BuildContext context) { - return OKToast( - backgroundColor: lightTheme.colorScheme.background, - textStyle: lightTheme.textTheme.bodyMedium, - child: MaterialApp.router( - onGenerateTitle: (context) => "appName".t(context), - localizationsDelegates: [ - GlobalMaterialLocalizations.delegate, - if (kDebugMode || Platform.isIOS) - GlobalCupertinoLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - FlowLocalizations.delegate, - ], - supportedLocales: FlowLocalizations.supportedLanguages, - locale: LocalPreferences().localeOverride.value, - routerConfig: router, - theme: lightTheme, - darkTheme: darkTheme, - themeMode: _themeMode, - debugShowCheckedModeBanner: false, - ), + return MaterialApp.router( + onGenerateTitle: (context) => "appName".t(context), + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + if (kDebugMode || Platform.isIOS) GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + FlowLocalizations.delegate, + ], + supportedLocales: FlowLocalizations.supportedLanguages, + locale: LocalPreferences().localeOverride.value, + routerConfig: router, + theme: lightTheme, + darkTheme: darkTheme, + themeMode: _themeMode, + debugShowCheckedModeBanner: false, ); } diff --git a/lib/routes/home/profile_tab.dart b/lib/routes/home/profile_tab.dart index 3b3ca5d8..272026ef 100644 --- a/lib/routes/home/profile_tab.dart +++ b/lib/routes/home/profile_tab.dart @@ -161,12 +161,11 @@ class _ProfileTabState extends State { if (context.mounted) { context.showToast( text: "sync.import.successful".t(context), - error: true, ); } } catch (e) { if (context.mounted) { - context.showToast(text: e.toString(), error: true); + context.showErrorToast(error: e); } } } diff --git a/lib/utils/toast.dart b/lib/utils/toast.dart index 476d5b35..b7c030d2 100644 --- a/lib/utils/toast.dart +++ b/lib/utils/toast.dart @@ -3,10 +3,10 @@ import 'package:flow/theme/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:material_symbols_icons/symbols.dart'; -import 'package:oktoast/oktoast.dart'; +import 'package:toastification/toastification.dart'; extension ToastHelper on BuildContext { - ToastFuture showErrorToast({required dynamic error, Widget? icon}) => + ToastificationItem showErrorToast({required dynamic error, Widget? icon}) => showToast( text: switch (error) { LocalizedException localizedException => @@ -15,12 +15,12 @@ extension ToastHelper on BuildContext { _ => error.toString(), }, icon: icon, - error: true, + type: ToastificationType.error, ); - ToastFuture showToast({ + ToastificationItem showToast({ required String text, - bool error = false, + ToastificationType type = ToastificationType.success, Widget? icon, }) { icon ??= Icon( @@ -28,32 +28,30 @@ extension ToastHelper on BuildContext { color: colorScheme.error, ); - final Widget contents = Material( - elevation: 2.0, - borderRadius: BorderRadius.circular(16.0), - type: MaterialType.card, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), - child: Row( - children: [ - icon, - const SizedBox(width: 12.0), - Flexible(child: Text(text)), - ], - ), - ), - ); - - if (error) { + if (type == ToastificationType.error) { HapticFeedback.heavyImpact(); } - return showToastWidget( - Padding( - padding: const EdgeInsets.all(16.0), - child: contents, - ), - position: const ToastPosition(align: Alignment.topCenter), + return toastification.show( + context: this, + title: Text(text), + type: type, + icon: icon, + autoCloseDuration: const Duration(seconds: 5), + alignment: Alignment.topCenter, + primaryColor: colorScheme.primary, + backgroundColor: colorScheme.background, + foregroundColor: colorScheme.onBackground, + showProgressBar: false, + style: ToastificationStyle.flat, + boxShadow: [ + BoxShadow( + color: colorScheme.onBackground.withAlpha(0x40), + offset: const Offset(0.0, 1.0), + blurRadius: 4.0, + spreadRadius: -1.5, + ) + ], ); } } diff --git a/pubspec.lock b/pubspec.lock index caf4f8b0..acaf9446 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -241,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.4" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -461,6 +469,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + iconsax_flutter: + dependency: transitive + description: + name: iconsax_flutter + sha256: "95b65699da8ea98f87c5d232f06b0debaaf1ec1332b697e4d90969ec9a93037d" + url: "https://pub.dev" + source: hosted + version: "1.0.0" image: dependency: transitive description: @@ -677,14 +693,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.0" - oktoast: - dependency: "direct main" - description: - name: oktoast - sha256: f1366c5c793ddfb8f55bc6fc3e45db43c45debf173b765fb4c5ec096cbdeb84a - url: "https://pub.dev" - source: hosted - version: "3.4.0" package_config: dependency: transitive description: @@ -749,6 +757,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.1" + pausable_timer: + dependency: transitive + description: + name: pausable_timer + sha256: "6ef1a95441ec3439de6fb63f39a011b67e693198e7dae14e20675c3c00e86074" + url: "https://pub.dev" + source: hosted + version: "3.1.0+3" petitparser: dependency: transitive description: @@ -1019,6 +1035,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + toastification: + dependency: "direct main" + description: + name: toastification + sha256: "18293318ffcdc5b6fb10289eb18b9addfef56f053b824c320fbdddcf6a48bab1" + url: "https://pub.dev" + source: hosted + version: "1.2.0" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6a42bf3b..b1e00b4b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A personal finance tracking app. publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.1.2+4 +version: 0.1.3+5 environment: sdk: ">=3.1.3 <4.0.0" @@ -35,7 +35,6 @@ dependencies: moment_dart: ^1.1.1 objectbox: ^2.4.0 objectbox_flutter_libs: ^2.4.0 - oktoast: ^3.4.0 path: ^1.8.3 path_provider: ^2.1.1 # pie_menu: ^3.1.3 @@ -46,20 +45,21 @@ dependencies: share_plus: ^7.2.2 shared_preferences: ^2.2.2 simple_icons: ^10.1.3 + toastification: ^1.2.0 url_launcher: ^6.2.3 uuid: ^4.2.2 dev_dependencies: build_runner: ^2.4.8 + flutter_launcher_icons: ^0.13.1 + flutter_lints: ^3.0.0 flutter_test: sdk: flutter json_serializable: ^6.7.1 objectbox_generator: ^2.3.1 - flutter_launcher_icons: ^0.13.1 - flutter: generate: true uses-material-design: true