change: Switch to ScaffoldMessenger

This commit is contained in:
Christian Pauly 2021-04-03 13:09:20 +02:00
parent 5bf54837c2
commit 6cdce6f673
16 changed files with 73 additions and 84 deletions

View File

@ -1,9 +1,10 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/message_download_content.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound_lite/flutter_sound.dart';
@ -81,8 +82,11 @@ class _AudioPlayerState extends State<AudioPlayer> {
_playAction();
} catch (e, s) {
Logs().v('Could not download audio file', e, s);
await FlushbarHelper.createError(message: e.toLocalizedString(context))
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(
content: Text(e.toLocalizedString(context)),
),
);
}
}

View File

@ -6,7 +6,7 @@ import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/matrix_locals.dart';
import 'package:fluffychat/utils/room_status_extension.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:pedantic/pedantic.dart';
@ -47,9 +47,11 @@ class ChatListItem extends StatelessWidget {
}
if (room.membership == Membership.ban) {
await FlushbarHelper.createError(
message: L10n.of(context).youHaveBeenBannedFromThisChat)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(
content: Text(L10n.of(context).youHaveBeenBannedFromThisChat),
),
);
return;
}

View File

@ -1,3 +1,4 @@
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/encryption/utils/key_verification.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/audio_player.dart';
@ -6,7 +7,7 @@ import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/matrix_locals.dart';
import 'package:fluffychat/components/dialogs/key_verification_dialog.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix_link_text/link_text.dart';
@ -26,13 +27,14 @@ class MessageContent extends StatelessWidget {
void _verifyOrRequestKey(BuildContext context) async {
if (event.content['can_request_session'] != true) {
FlushbarHelper.createError(
message: event.type == EventTypes.Encrypted
AdaptivePageLayout.of(context).showSnackBar(SnackBar(
content: Text(
event.type == EventTypes.Encrypted
? L10n.of(context).needPantalaimonWarning
: event.getLocalizedBody(
MatrixLocals(L10n.of(context)),
),
);
)));
return;
}
final client = Matrix.of(context).client;
@ -59,11 +61,8 @@ class MessageContent extends StatelessWidget {
future: () => event.requestKey(),
);
if (success.error == null) {
await FlushbarHelper.createLoading(
title: L10n.of(context).loadingPleaseWait,
message: L10n.of(context).requestToReadOlderMessages,
linearProgressIndicator: LinearProgressIndicator(),
).show(context);
AdaptivePageLayout.of(context).showSnackBar(SnackBar(
content: Text(L10n.of(context).requestToReadOlderMessages)));
}
}
}

View File

@ -25,7 +25,7 @@ import 'dart:ui';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
@ -255,10 +255,10 @@ class BackgroundPush {
}
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) {
await loadLocale();
await FlushbarHelper.createError(
message: l10n.noGoogleServicesWarning,
duration: Duration(seconds: 15),
).show(context);
AdaptivePageLayout.of(context).showSnackBar(SnackBar(
content: Text(
l10n.noGoogleServicesWarning,
)));
if (null == await store.getItem(SettingKeys.showNoGoogle)) {
await store.setItemBool(SettingKeys.showNoGoogle, false);
}

View File

@ -1,4 +1,4 @@
import 'package:flushbar/flushbar_helper.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -13,9 +13,8 @@ abstract class FluffyShare {
await Clipboard.setData(
ClipboardData(text: text),
);
await FlushbarHelper.createSuccess(
message: L10n.of(context).copiedToClipboard)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).copiedToClipboard)));
return;
}
}

View File

@ -14,7 +14,7 @@ import 'package:fluffychat/components/connection_status_header.dart';
import 'package:fluffychat/components/dialogs/recording_dialog.dart';
import 'package:fluffychat/components/unread_badge_back_button.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/components/encryption_button.dart';
import 'package:fluffychat/components/list_items/message.dart';
@ -110,9 +110,8 @@ class _ChatState extends State<Chat> {
try {
await timeline.requestHistory(historyCount: _loadHistoryCount);
} catch (err) {
await FlushbarHelper.createError(
message: err.toLocalizedString(context))
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(err.toLocalizedString(context))));
}
}
}
@ -351,9 +350,8 @@ class _ChatState extends State<Chat> {
);
if (result.error != null) return;
setState(() => selectedEvents.clear());
await FlushbarHelper.createSuccess(
message: L10n.of(context).contentHasBeenReported)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).contentHasBeenReported)));
}
void redactEventsAction(BuildContext context) async {

View File

@ -4,7 +4,7 @@ import 'package:fluffychat/app_config.dart';
import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/fluffy_share.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
@ -56,9 +56,8 @@ class _ChatDetailsState extends State<ChatDetails> {
future: () => room.setName(input.single),
);
if (success.error == null) {
await FlushbarHelper.createSuccess(
message: L10n.of(context).displaynameHasBeenChanged)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).displaynameHasBeenChanged)));
}
}
@ -127,9 +126,8 @@ class _ChatDetailsState extends State<ChatDetails> {
future: () => room.setDescription(input.single),
);
if (success.error == null) {
await FlushbarHelper.createSuccess(
message: L10n.of(context).groupDescriptionHasBeenChanged)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(SnackBar(
content: Text(L10n.of(context).groupDescriptionHasBeenChanged)));
}
}
@ -162,9 +160,8 @@ class _ChatDetailsState extends State<ChatDetails> {
future: () => room.setAvatar(file),
);
if (success.error == null) {
await FlushbarHelper.createSuccess(
message: L10n.of(context).avatarHasBeenChanged)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).avatarHasBeenChanged)));
}
}

View File

@ -5,7 +5,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/components/dialogs/permission_slider_dialog.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:famedlysdk/famedlysdk.dart';
@ -19,8 +19,9 @@ class ChatPermissionsSettings extends StatelessWidget {
{String category}) async {
final room = Matrix.of(context).client.getRoomById(roomId);
if (!room.canSendEvent(EventTypes.RoomPowerLevels)) {
return FlushbarHelper.createError(message: L10n.of(context).noPermission)
.show(context);
AdaptivePageLayout.of(context)
.showSnackBar(SnackBar(content: Text(L10n.of(context).noPermission)));
return;
}
final newLevel =
await PermissionSliderDialog(initialPermission: currentLevel)

View File

@ -8,7 +8,7 @@ import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter/material.dart';
@ -109,10 +109,8 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/client/r0/login/sso/redirect?redirectUrl=${Uri.encodeQueryComponent(redirectUrl)}');
}
} catch (e) {
// ignore: unawaited_futures
FlushbarHelper.createError(
message: (e as Object).toLocalizedString(context))
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text((e as Object).toLocalizedString(context))));
} finally {
if (mounted) {
setState(() => _isLoading = false);

View File

@ -1,7 +1,8 @@
import 'dart:async';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/components/default_app_bar_search_field.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/avatar.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
@ -61,9 +62,8 @@ class _InvitationSelectionState extends State<InvitationSelection> {
future: () => room.invite(id),
);
if (success.error == null) {
await FlushbarHelper.createSuccess(
message: L10n.of(context).contactHasBeenInvitedToTheGroup)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(SnackBar(
content: Text(L10n.of(context).contactHasBeenInvitedToTheGroup)));
}
}
@ -89,8 +89,8 @@ class _InvitationSelectionState extends State<InvitationSelection> {
try {
response = await matrix.client.searchUser(text, limit: 10);
} catch (e) {
FlushbarHelper.createError(
message: (e as Object).toLocalizedString(context));
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text((e as Object).toLocalizedString(context))));
return;
} finally {
setState(() => loading = false);

View File

@ -2,10 +2,11 @@ import 'dart:async';
import 'dart:math';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import '../utils/platform_infos.dart';
@ -174,8 +175,8 @@ class _LoginState extends State<Login> {
),
);
if (success.error == null) {
FlushbarHelper.createSuccess(
message: L10n.of(context).passwordHasBeenChanged);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).passwordHasBeenChanged)));
}
}

View File

@ -5,7 +5,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/components/dialogs/bootstrap_dialog.dart';
import 'package:fluffychat/components/sentry_switch_list_tile.dart';
import 'package:fluffychat/components/settings_switch_list_tile.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/utils/beautify_string_extension.dart';
@ -88,9 +88,8 @@ class _SettingsState extends State<Settings> {
.changePassword(input.last, oldPassword: input.first),
);
if (success.error == null) {
await FlushbarHelper.createSuccess(
message: L10n.of(context).passwordHasBeenChanged)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).passwordHasBeenChanged)));
}
}

View File

@ -1,5 +1,6 @@
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
@ -443,9 +444,8 @@ class _EmoteImagePickerState extends State<_EmoteImagePicker> {
return ElevatedButton(
onPressed: () async {
if (kIsWeb) {
await FlushbarHelper.createError(
message: L10n.of(context).notSupportedInWeb)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).notSupportedInWeb)));
return;
}
MatrixFile file;

View File

@ -1,7 +1,8 @@
import 'dart:math';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart';
@ -114,17 +115,15 @@ class _SignUpPasswordState extends State<SignUpPassword> {
await matrix.client
.setDisplayname(matrix.client.userID, widget.displayname);
} catch (exception) {
await FlushbarHelper.createError(
message: L10n.of(context).couldNotSetDisplayname)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).couldNotSetDisplayname)));
}
if (widget.avatar != null) {
try {
await matrix.client.setAvatar(widget.avatar);
} catch (exception) {
await FlushbarHelper.createError(
message: L10n.of(context).couldNotSetAvatar)
.show(context);
AdaptivePageLayout.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).couldNotSetAvatar)));
}
}
if (mounted) setState(() => loading = false);

View File

@ -21,7 +21,7 @@ packages:
name: adaptive_page_layout
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.6"
version: "0.2.2"
adaptive_theme:
dependency: "direct main"
description:
@ -306,13 +306,6 @@ 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

View File

@ -33,7 +33,7 @@ dependencies:
url_launcher: ^5.7.10
cached_network_image: ^2.5.0
flutter_local_notifications: ^3.0.3
adaptive_page_layout: ^0.1.6
adaptive_page_layout: ^0.2.1
provider: ^4.3.3
adaptive_theme: ^1.1.0
# desktop_notifications: ^0.0.0-dev.4 // Currently blocked by: https://github.com/canonical/desktop_notifications.dart/issues/5
@ -50,7 +50,6 @@ dependencies:
flutter_sound_lite: ^7.5.3+1
open_file: ^3.0.3
mime_type: ^0.3.2
flushbar: ^1.10.4
adaptive_dialog: ^0.9.3
flutter_matrix_html:
git: