Fix login and toasts
This commit is contained in:
parent
8cde337a58
commit
ab45d0960f
12 changed files with 165 additions and 239 deletions
|
|
@ -5,6 +5,7 @@ import 'package:fluffychat/i18n/i18n.dart';
|
|||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat_encryption_settings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
import 'matrix.dart';
|
||||
|
|
@ -21,11 +22,7 @@ class _EncryptionButtonState extends State<EncryptionButton> {
|
|||
|
||||
void _enableEncryptionAction() async {
|
||||
if (widget.room.encrypted) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(I18n.of(context).warningEncryptionInBeta),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).warningEncryptionInBeta);
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
|
|
@ -35,13 +32,7 @@ class _EncryptionButtonState extends State<EncryptionButton> {
|
|||
return;
|
||||
}
|
||||
if (!widget.room.client.encryptionEnabled) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).needPantalaimonWarning,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).needPantalaimonWarning);
|
||||
return;
|
||||
}
|
||||
if (await SimpleDialogs(context).askConfirmation(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import '../../i18n/i18n.dart';
|
||||
|
|
@ -31,13 +32,7 @@ class ChatListItem extends StatelessWidget {
|
|||
}
|
||||
|
||||
if (room.membership == Membership.ban) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).youHaveBeenBannedFromThisChat,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).youHaveBeenBannedFromThisChat);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
|
@ -95,22 +96,10 @@ class MatrixState extends State<Matrix> {
|
|||
onAdditionalAuth != null) {
|
||||
return await tryRequestWithErrorToast(onAdditionalAuth(exception));
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
exception.errorMessage,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(exception.errorMessage);
|
||||
}
|
||||
} catch (exception) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
exception.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(exception.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -158,15 +147,14 @@ class MatrixState extends State<Matrix> {
|
|||
Future<void> setupFirebase() async {
|
||||
if (Platform.isIOS) iOS_Permission();
|
||||
|
||||
final String token = await _firebaseMessaging.getToken();
|
||||
String token;
|
||||
try {
|
||||
token = await _firebaseMessaging.getToken();
|
||||
} catch (_) {
|
||||
token = null;
|
||||
}
|
||||
if (token?.isEmpty ?? true) {
|
||||
return Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
I18n.of(context).noGoogleServicesWarning,
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).noGoogleServicesWarning);
|
||||
}
|
||||
await client.setPushers(
|
||||
token,
|
||||
|
|
@ -196,13 +184,7 @@ class MatrixState extends State<Matrix> {
|
|||
),
|
||||
(r) => r.isFirst);
|
||||
} catch (_) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"Failed to open chat...",
|
||||
),
|
||||
),
|
||||
);
|
||||
showToast("Failed to open chat...");
|
||||
debugPrint(_);
|
||||
}
|
||||
};
|
||||
|
|
@ -419,7 +401,7 @@ class MatrixState extends State<Matrix> {
|
|||
void initState() {
|
||||
if (widget.client == null) {
|
||||
debugPrint("[Matrix] Init matrix client");
|
||||
client = Client(widget.clientName, debug: false);
|
||||
client = Client(widget.clientName, debug: true);
|
||||
onJitsiCallSub ??= client.onEvent.stream
|
||||
.where((e) =>
|
||||
e.type == 'timeline' &&
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:fluffychat/i18n/i18n.dart';
|
|||
import 'package:fluffychat/utils/event_extension.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:link_text/link_text.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||
|
|
@ -51,12 +52,7 @@ class MessageContent extends StatelessWidget {
|
|||
onPressed: () async {
|
||||
if (kIsWeb) {
|
||||
if (event.room.encrypted) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text(I18n.of(context).notSupportedInWeb),
|
||||
),
|
||||
);
|
||||
showToast(I18n.of(context).notSupportedInWeb);
|
||||
}
|
||||
await launch(
|
||||
MxContent(event.content["url"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue