From e2195935c08f12b7d2f398542f74da744171c9af Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 14 Nov 2020 08:54:26 +0100 Subject: [PATCH] chore: Switch from bottoast to flushbar --- lib/components/dialogs/simple_dialogs.dart | 8 +++++--- lib/components/encryption_button.dart | 7 ++++--- lib/components/list_items/chat_list_item.dart | 6 ++++-- lib/main.dart | 3 --- lib/utils/firebase_controller.dart | 11 ++++++----- lib/utils/fluffy_share.dart | 6 ++++-- lib/utils/sentry_controller.dart | 6 ++++-- lib/views/chat_details.dart | 19 +++++++++++++------ lib/views/chat_encryption_settings.dart | 11 +++++++++++ lib/views/invitation_selection.dart | 6 ++++-- lib/views/settings.dart | 6 ++++-- lib/views/settings_emotes.dart | 6 ++++-- lib/views/sign_up_password.dart | 10 +++++++--- pubspec.lock | 16 ++++++++-------- pubspec.yaml | 2 +- 15 files changed, 79 insertions(+), 44 deletions(-) diff --git a/lib/components/dialogs/simple_dialogs.dart b/lib/components/dialogs/simple_dialogs.dart index ffeca4f7..476fbaa0 100644 --- a/lib/components/dialogs/simple_dialogs.dart +++ b/lib/components/dialogs/simple_dialogs.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -169,10 +169,12 @@ class SimpleDialogs { onAdditionalAuth != null) { return await tryRequestWithErrorToast(onAdditionalAuth(exception)); } else { - BotToast.showText(text: exception.errorMessage); + await FlushbarHelper.createError(message: exception.errorMessage) + .show(context); } } catch (exception) { - BotToast.showText(text: exception.toString()); + await FlushbarHelper.createError(message: exception.toString()) + .show(context); return false; } } diff --git a/lib/components/encryption_button.dart b/lib/components/encryption_button.dart index 08973115..ca8d2fee 100644 --- a/lib/components/encryption_button.dart +++ b/lib/components/encryption_button.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/views/chat_encryption_settings.dart'; @@ -22,7 +22,6 @@ class _EncryptionButtonState extends State { void _enableEncryptionAction() async { if (widget.room.encrypted) { - BotToast.showText(text: L10n.of(context).warningEncryptionInBeta); await Navigator.of(context).push( AppRoute.defaultRoute( context, @@ -32,7 +31,9 @@ class _EncryptionButtonState extends State { return; } if (!widget.room.client.encryptionEnabled) { - BotToast.showText(text: L10n.of(context).needPantalaimonWarning); + await FlushbarHelper.createInformation( + message: L10n.of(context).needPantalaimonWarning) + .show(context); return; } if (await SimpleDialogs(context).askConfirmation( diff --git a/lib/components/list_items/chat_list_item.dart b/lib/components/list_items/chat_list_item.dart index 9b6ba7af..d2c8415d 100644 --- a/lib/components/list_items/chat_list_item.dart +++ b/lib/components/list_items/chat_list_item.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:circular_check_box/circular_check_box.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/utils/matrix_locals.dart'; @@ -43,7 +43,9 @@ class ChatListItem extends StatelessWidget { } if (room.membership == Membership.ban) { - BotToast.showText(text: L10n.of(context).youHaveBeenBannedFromThisChat); + await FlushbarHelper.createError( + message: L10n.of(context).youHaveBeenBannedFromThisChat) + .show(context); return; } diff --git a/lib/main.dart b/lib/main.dart index bba5897c..8d6a8ff4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:io'; -import 'package:bot_toast/bot_toast.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:fluffychat/views/homeserver_picker.dart'; @@ -37,8 +36,6 @@ class App extends StatelessWidget { child: Builder( builder: (BuildContext context) => MaterialApp( title: 'FluffyChat', - builder: BotToastInit(), - navigatorObservers: [BotToastNavigatorObserver()], theme: ThemeSwitcherWidget.of(context).themeData, localizationsDelegates: L10n.localizationsDelegates, supportedLocales: L10n.supportedLocales, diff --git a/lib/utils/firebase_controller.dart b/lib/utils/firebase_controller.dart index 859bbd38..21276a62 100644 --- a/lib/utils/firebase_controller.dart +++ b/lib/utils/firebase_controller.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:fluffychat/components/matrix.dart'; @@ -46,10 +46,10 @@ abstract class FirebaseController { final storeItem = await matrix.store.getItem(SettingKeys.showNoGoogle); final configOptionMissing = storeItem == null || storeItem.isEmpty; if (configOptionMissing || (!configOptionMissing && storeItem == '1')) { - BotToast.showText( - text: L10n.of(context).noGoogleServicesWarning, + await FlushbarHelper.createError( + message: L10n.of(context).noGoogleServicesWarning, duration: Duration(seconds: 15), - ); + ).show(context); if (configOptionMissing) { await matrix.store.setItem(SettingKeys.showNoGoogle, '0'); } @@ -120,7 +120,8 @@ abstract class FirebaseController { ), (r) => r.isFirst); } catch (_) { - BotToast.showText(text: 'Failed to open chat...'); + await FlushbarHelper.createError(message: 'Failed to open chat...') + .show(context); debugPrint(_); } }; diff --git a/lib/utils/fluffy_share.dart b/lib/utils/fluffy_share.dart index 88409a3d..8fbbab0a 100644 --- a/lib/utils/fluffy_share.dart +++ b/lib/utils/fluffy_share.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -13,7 +13,9 @@ abstract class FluffyShare { await Clipboard.setData( ClipboardData(text: text), ); - BotToast.showText(text: L10n.of(context).copiedToClipboard); + await FlushbarHelper.createSuccess( + message: L10n.of(context).copiedToClipboard) + .show(context); return; } } diff --git a/lib/utils/sentry_controller.dart b/lib/utils/sentry_controller.dart index a152a4e4..e50833cb 100644 --- a/lib/utils/sentry_controller.dart +++ b/lib/utils/sentry_controller.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:flutter/material.dart'; @@ -19,7 +19,9 @@ abstract class SentryController { ); final storage = Store(); await storage.setItem(SettingKeys.sentry, enableSentry.toString()); - BotToast.showText(text: L10n.of(context).changesHaveBeenSaved); + await FlushbarHelper.createSuccess( + message: L10n.of(context).changesHaveBeenSaved) + .show(context); return; } diff --git a/lib/views/chat_details.dart b/lib/views/chat_details.dart index d702db37..c43a224d 100644 --- a/lib/views/chat_details.dart +++ b/lib/views/chat_details.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/matrix_api.dart'; @@ -48,7 +48,9 @@ class _ChatDetailsState extends State { widget.room.setName(displayname), ); if (success != false) { - BotToast.showText(text: L10n.of(context).displaynameHasBeenChanged); + await FlushbarHelper.createSuccess( + message: L10n.of(context).displaynameHasBeenChanged) + .show(context); } } @@ -101,7 +103,9 @@ class _ChatDetailsState extends State { widget.room.setDescription(displayname), ); if (success != false) { - BotToast.showText(text: L10n.of(context).groupDescriptionHasBeenChanged); + await FlushbarHelper.createSuccess( + message: L10n.of(context).groupDescriptionHasBeenChanged) + .show(context); } } @@ -133,7 +137,9 @@ class _ChatDetailsState extends State { widget.room.setAvatar(file), ); if (success != false) { - BotToast.showText(text: L10n.of(context).avatarHasBeenChanged); + await FlushbarHelper.createSuccess( + message: L10n.of(context).avatarHasBeenChanged) + .show(context); } } @@ -184,8 +190,9 @@ class _ChatDetailsState extends State { Clipboard.setData( ClipboardData(text: widget.room.canonicalAlias), ); - BotToast.showText( - text: L10n.of(context).copiedToClipboard); + FlushbarHelper.createSuccess( + message: L10n.of(context).copiedToClipboard) + .show(context); }, ), ChatSettingsPopupMenu(widget.room, false) diff --git a/lib/views/chat_encryption_settings.dart b/lib/views/chat_encryption_settings.dart index 6f014b27..571a7eda 100644 --- a/lib/views/chat_encryption_settings.dart +++ b/lib/views/chat_encryption_settings.dart @@ -5,6 +5,7 @@ import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/utils/beautify_string_extension.dart'; import 'package:fluffychat/views/chat_list.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -102,6 +103,16 @@ class _ChatEncryptionSettingsState extends State { } } + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback( + (_) => FlushbarHelper.createInformation( + message: L10n.of(context).warningEncryptionInBeta) + .show(context), + ); + } + @override Widget build(BuildContext context) { final room = Matrix.of(context).client.getRoomById(widget.id); diff --git a/lib/views/invitation_selection.dart b/lib/views/invitation_selection.dart index 69525207..8e146335 100644 --- a/lib/views/invitation_selection.dart +++ b/lib/views/invitation_selection.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/matrix_api.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart'; @@ -60,7 +60,9 @@ class _InvitationSelectionState extends State { widget.room.invite(id), ); if (success != false) { - BotToast.showText(text: L10n.of(context).contactHasBeenInvitedToTheGroup); + await FlushbarHelper.createSuccess( + message: L10n.of(context).contactHasBeenInvitedToTheGroup) + .show(context); } } diff --git a/lib/views/settings.dart b/lib/views/settings.dart index ce62e6c2..6308a774 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:file_picker_cross/file_picker_cross.dart'; @@ -76,7 +76,9 @@ class _SettingsState extends State { .client .changePassword(newPassword, oldPassword: oldPassword), ); - BotToast.showText(text: L10n.of(context).passwordHasBeenChanged); + await FlushbarHelper.createSuccess( + message: L10n.of(context).passwordHasBeenChanged) + .show(context); } void _deleteAccountAction(BuildContext context) async { diff --git a/lib/views/settings_emotes.dart b/lib/views/settings_emotes.dart index d7bca137..cdf6ae2c 100644 --- a/lib/views/settings_emotes.dart +++ b/lib/views/settings_emotes.dart @@ -1,4 +1,4 @@ -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:file_picker_cross/file_picker_cross.dart'; @@ -449,7 +449,9 @@ class _EmoteImagePickerState extends State<_EmoteImagePicker> { ), onPressed: () async { if (kIsWeb) { - BotToast.showText(text: L10n.of(context).notSupportedInWeb); + await FlushbarHelper.createError( + message: L10n.of(context).notSupportedInWeb) + .show(context); return; } MatrixFile file; diff --git a/lib/views/sign_up_password.dart b/lib/views/sign_up_password.dart index e0ec9ef8..5244f403 100644 --- a/lib/views/sign_up_password.dart +++ b/lib/views/sign_up_password.dart @@ -1,6 +1,6 @@ import 'dart:math'; -import 'package:bot_toast/bot_toast.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/matrix.dart'; @@ -95,13 +95,17 @@ class _SignUpPasswordState extends State { await matrix.client .setDisplayname(matrix.client.userID, widget.displayname); } catch (exception) { - BotToast.showText(text: L10n.of(context).couldNotSetDisplayname); + await FlushbarHelper.createError( + message: L10n.of(context).couldNotSetDisplayname) + .show(context); } if (widget.avatar != null) { try { await matrix.client.setAvatar(widget.avatar); } catch (exception) { - BotToast.showText(text: L10n.of(context).couldNotSetAvatar); + await FlushbarHelper.createError( + message: L10n.of(context).couldNotSetAvatar) + .show(context); } } await Navigator.of(context).pushAndRemoveUntil( diff --git a/pubspec.lock b/pubspec.lock index df5a2261..a8962f8b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -64,13 +64,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0-nullsafety.1" - bot_toast: - dependency: "direct main" - description: - name: bot_toast - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.4" cached_network_image: dependency: "direct main" description: @@ -290,6 +283,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.0.3" + flushbar: + dependency: "direct main" + description: + name: flushbar + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.4" flutter: dependency: "direct main" description: flutter @@ -1137,5 +1137,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.10.2 <=2.11.0-161.0.dev" + dart: ">=2.10.2 <2.11.0" flutter: ">=1.22.2 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9389847f..9507b1fe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,7 +48,7 @@ dependencies: flutter_sound: 2.1.1 open_file: ^3.0.3 mime_type: ^0.3.2 - bot_toast: ^3.0.4 + flushbar: ^1.10.4 flutter_matrix_html: ^0.1.10 moor: ^3.4.0 sqlite3_flutter_libs: ^0.2.0