feat: Implement Snack instead of BotToast

This commit is contained in:
Christian Pauly 2020-10-04 12:54:43 +02:00
parent 2f8491b41b
commit 32d5fdd0eb
13 changed files with 61 additions and 41 deletions

View File

@ -1,4 +1,5 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -169,10 +170,10 @@ class SimpleDialogs {
onAdditionalAuth != null) { onAdditionalAuth != null) {
return await tryRequestWithErrorToast(onAdditionalAuth(exception)); return await tryRequestWithErrorToast(onAdditionalAuth(exception));
} else { } else {
BotToast.showText(text: exception.errorMessage); await Flushbar(message: exception.errorMessage).show(context);
} }
} catch (exception) { } catch (exception) {
BotToast.showText(text: exception.toString()); await Flushbar(message: exception.toString()).show(context);
return false; return false;
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_encryption_settings.dart'; import 'package:fluffychat/views/chat_encryption_settings.dart';
@ -22,7 +23,8 @@ class _EncryptionButtonState extends State<EncryptionButton> {
void _enableEncryptionAction() async { void _enableEncryptionAction() async {
if (widget.room.encrypted) { if (widget.room.encrypted) {
BotToast.showText(text: L10n.of(context).warningEncryptionInBeta); await Flushbar(message: L10n.of(context).warningEncryptionInBeta)
.show(context);
await Navigator.of(context).push( await Navigator.of(context).push(
AppRoute.defaultRoute( AppRoute.defaultRoute(
context, context,
@ -32,7 +34,8 @@ class _EncryptionButtonState extends State<EncryptionButton> {
return; return;
} }
if (!widget.room.client.encryptionEnabled) { if (!widget.room.client.encryptionEnabled) {
BotToast.showText(text: L10n.of(context).needPantalaimonWarning); await Flushbar(message: L10n.of(context).needPantalaimonWarning)
.show(context);
return; return;
} }
if (await SimpleDialogs(context).askConfirmation( if (await SimpleDialogs(context).askConfirmation(

View File

@ -1,4 +1,5 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/matrix_locals.dart'; import 'package:fluffychat/utils/matrix_locals.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
@ -41,7 +42,8 @@ class ChatListItem extends StatelessWidget {
} }
if (room.membership == Membership.ban) { if (room.membership == Membership.ban) {
BotToast.showText(text: L10n.of(context).youHaveBeenBannedFromThisChat); await Flushbar(message: L10n.of(context).youHaveBeenBannedFromThisChat)
.show(context);
return; return;
} }

View File

@ -1,7 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:bot_toast/bot_toast.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/homeserver_picker.dart'; import 'package:fluffychat/views/homeserver_picker.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -51,8 +50,6 @@ class App extends StatelessWidget {
child: Builder( child: Builder(
builder: (BuildContext context) => MaterialApp( builder: (BuildContext context) => MaterialApp(
title: 'FluffyChat', title: 'FluffyChat',
builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()],
theme: ThemeSwitcherWidget.of(context).themeData, theme: ThemeSwitcherWidget.of(context).themeData,
localizationsDelegates: L10n.localizationsDelegates, localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales, supportedLocales: L10n.supportedLocales,

View File

@ -1,7 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
@ -46,10 +47,10 @@ abstract class FirebaseController {
await matrix.store.getItem('chat.fluffy.show_no_google'); await matrix.store.getItem('chat.fluffy.show_no_google');
final configOptionMissing = storeItem == null || storeItem.isEmpty; final configOptionMissing = storeItem == null || storeItem.isEmpty;
if (configOptionMissing || (!configOptionMissing && storeItem == '1')) { if (configOptionMissing || (!configOptionMissing && storeItem == '1')) {
BotToast.showText( await Flushbar(
text: L10n.of(context).noGoogleServicesWarning, message: L10n.of(context).noGoogleServicesWarning,
duration: Duration(seconds: 15), duration: Duration(seconds: 15),
); ).show(context);
if (configOptionMissing) { if (configOptionMissing) {
await matrix.store.setItem('chat.fluffy.show_no_google', '0'); await matrix.store.setItem('chat.fluffy.show_no_google', '0');
} }
@ -120,7 +121,7 @@ abstract class FirebaseController {
), ),
(r) => r.isFirst); (r) => r.isFirst);
} catch (_) { } catch (_) {
BotToast.showText(text: 'Failed to open chat...'); await Flushbar(message: 'Failed to open chat...').show(context);
debugPrint(_); debugPrint(_);
} }
}; };

View File

@ -1,4 +1,5 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -15,7 +16,8 @@ abstract class SentryController {
); );
await storage.ready; await storage.ready;
await storage.setItem('sentry', enableSentry); await storage.setItem('sentry', enableSentry);
BotToast.showText(text: L10n.of(context).changesHaveBeenSaved); await Flushbar(message: L10n.of(context).changesHaveBeenSaved)
.show(context);
return; return;
} }

View File

@ -1,4 +1,5 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:famedlysdk/matrix_api.dart'; import 'package:famedlysdk/matrix_api.dart';
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
@ -46,7 +47,8 @@ class _ChatDetailsState extends State<ChatDetails> {
widget.room.setName(displayname), widget.room.setName(displayname),
); );
if (success != false) { if (success != false) {
BotToast.showText(text: L10n.of(context).displaynameHasBeenChanged); await Flushbar(message: L10n.of(context).displaynameHasBeenChanged)
.show(context);
} }
} }
@ -99,7 +101,8 @@ class _ChatDetailsState extends State<ChatDetails> {
widget.room.setDescription(displayname), widget.room.setDescription(displayname),
); );
if (success != false) { if (success != false) {
BotToast.showText(text: L10n.of(context).groupDescriptionHasBeenChanged); await Flushbar(message: L10n.of(context).groupDescriptionHasBeenChanged)
.show(context);
} }
} }
@ -119,7 +122,8 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
); );
if (success != false) { if (success != false) {
BotToast.showText(text: L10n.of(context).avatarHasBeenChanged); await Flushbar(message: L10n.of(context).avatarHasBeenChanged)
.show(context);
} }
} }
@ -170,8 +174,9 @@ class _ChatDetailsState extends State<ChatDetails> {
Clipboard.setData( Clipboard.setData(
ClipboardData(text: widget.room.canonicalAlias), ClipboardData(text: widget.room.canonicalAlias),
); );
BotToast.showText( Flushbar(
text: L10n.of(context).copiedToClipboard); message: L10n.of(context).copiedToClipboard)
.show(context);
}, },
), ),
ChatSettingsPopupMenu(widget.room, false) ChatSettingsPopupMenu(widget.room, false)

View File

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:famedlysdk/matrix_api.dart'; import 'package:famedlysdk/matrix_api.dart';
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
@ -60,7 +61,8 @@ class _InvitationSelectionState extends State<InvitationSelection> {
widget.room.invite(id), widget.room.invite(id),
); );
if (success != false) { if (success != false) {
BotToast.showText(text: L10n.of(context).contactHasBeenInvitedToTheGroup); await Flushbar(message: L10n.of(context).contactHasBeenInvitedToTheGroup)
.show(context);
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/settings_themes.dart'; import 'package:fluffychat/components/settings_themes.dart';
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
@ -72,7 +73,8 @@ class _SettingsState extends State<Settings> {
.client .client
.changePassword(newPassword, oldPassword: oldPassword), .changePassword(newPassword, oldPassword: oldPassword),
); );
BotToast.showText(text: L10n.of(context).passwordHasBeenChanged); await Flushbar(message: L10n.of(context).passwordHasBeenChanged)
.show(context);
} }
void _deleteAccountAction(BuildContext context) async { void _deleteAccountAction(BuildContext context) async {

View File

@ -1,4 +1,5 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -447,7 +448,8 @@ class _EmoteImagePickerState extends State<_EmoteImagePicker> {
), ),
onPressed: () async { onPressed: () async {
if (kIsWeb) { if (kIsWeb) {
BotToast.showText(text: L10n.of(context).notSupportedInWeb); await Flushbar(message: L10n.of(context).notSupportedInWeb)
.show(context);
return; return;
} }
var file = await MemoryFilePicker.getImage( var file = await MemoryFilePicker.getImage(

View File

@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'package:bot_toast/bot_toast.dart'; import 'package:flushbar/flushbar.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
@ -95,7 +96,8 @@ class _SignUpPasswordState extends State<SignUpPassword> {
await matrix.client await matrix.client
.setDisplayname(matrix.client.userID, widget.displayname); .setDisplayname(matrix.client.userID, widget.displayname);
} catch (exception) { } catch (exception) {
BotToast.showText(text: L10n.of(context).couldNotSetDisplayname); await Flushbar(message: L10n.of(context).couldNotSetDisplayname)
.show(context);
} }
if (widget.avatar != null) { if (widget.avatar != null) {
try { try {
@ -106,7 +108,8 @@ class _SignUpPasswordState extends State<SignUpPassword> {
), ),
); );
} catch (exception) { } catch (exception) {
BotToast.showText(text: L10n.of(context).couldNotSetAvatar); await Flushbar(message: L10n.of(context).couldNotSetAvatar)
.show(context);
} }
} }
await Navigator.of(context).pushAndRemoveUntil( await Navigator.of(context).pushAndRemoveUntil(

View File

@ -64,13 +64,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" 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: cached_network_image:
dependency: "direct main" dependency: "direct main"
description: description:
@ -248,6 +241,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.0.2" version: "7.0.2"
flushbar:
dependency: "direct main"
description:
name: flushbar
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.4"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

View File

@ -49,7 +49,7 @@ dependencies:
flutter_sound: ^2.1.1 flutter_sound: ^2.1.1
open_file: ^3.0.1 open_file: ^3.0.1
mime_type: ^0.3.0 mime_type: ^0.3.0
bot_toast: ^3.0.0 flushbar: ^1.10.4
flutter_matrix_html: ^0.1.5 flutter_matrix_html: ^0.1.5
moor: ^3.3.1 moor: ^3.3.1
sqlite3_flutter_libs: ^0.2.0 sqlite3_flutter_libs: ^0.2.0