refactor: Switch to loading dialog
This commit is contained in:
parent
9521a93622
commit
75797a62b9
36 changed files with 461 additions and 350 deletions
|
|
@ -11,7 +11,7 @@ import 'package:fluffychat/components/avatar.dart';
|
|||
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
||||
import 'package:fluffychat/components/connection_status_header.dart';
|
||||
import 'package:fluffychat/components/dialogs/recording_dialog.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.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';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
|
|
@ -114,8 +114,9 @@ class _ChatState extends State<_Chat> {
|
|||
if (_canLoadMore) {
|
||||
setState(() => _loadingHistory = true);
|
||||
|
||||
await SimpleDialogs(context).tryRequestWithErrorToast(
|
||||
timeline.requestHistory(historyCount: _loadHistoryCount),
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => timeline.requestHistory(historyCount: _loadHistoryCount),
|
||||
);
|
||||
|
||||
// we do NOT setState() here as then the event order will be wrong.
|
||||
|
|
@ -275,8 +276,9 @@ class _ChatState extends State<_Chat> {
|
|||
final audioFile = File(result);
|
||||
// as we already explicitly say send in the recording dialog,
|
||||
// we do not need the send file dialog anymore. We can just send this straight away.
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.sendFileEvent(
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.sendFileEvent(
|
||||
MatrixAudioFile(
|
||||
bytes: audioFile.readAsBytesSync(), name: audioFile.path),
|
||||
),
|
||||
|
|
@ -313,8 +315,9 @@ class _ChatState extends State<_Chat> {
|
|||
OkCancelResult.ok;
|
||||
if (!confirmed) return;
|
||||
for (var event in selectedEvents) {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
event.status > 0 ? event.redact() : event.remove());
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => event.status > 0 ? event.redact() : event.remove());
|
||||
}
|
||||
setState(() => selectedEvents.clear());
|
||||
}
|
||||
|
|
@ -400,7 +403,7 @@ class _ChatState extends State<_Chat> {
|
|||
}
|
||||
});
|
||||
if (context != null) {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(task);
|
||||
await showFutureLoadingDialog(context: context, future: () => task);
|
||||
} else {
|
||||
await task;
|
||||
}
|
||||
|
|
@ -445,8 +448,9 @@ class _ChatState extends State<_Chat> {
|
|||
}
|
||||
|
||||
void _sendEmojiAction(BuildContext context, String emoji) {
|
||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.sendReaction(
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.sendReaction(
|
||||
selectedEvents.first.eventId,
|
||||
emoji,
|
||||
),
|
||||
|
|
@ -472,7 +476,7 @@ class _ChatState extends State<_Chat> {
|
|||
matrix.activeRoomId = widget.id;
|
||||
|
||||
if (room.membership == Membership.invite) {
|
||||
SimpleDialogs(context).tryRequestWithLoadingDialog(room.join());
|
||||
showFutureLoadingDialog(context: context, future: () => room.join());
|
||||
}
|
||||
|
||||
final typingText = room.getLocalizedTypingText(context);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import 'package:file_picker_cross/file_picker_cross.dart';
|
|||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
||||
import 'package:fluffychat/components/content_banner.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/list_items/participant_list_item.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/matrix_locals.dart';
|
||||
|
|
@ -52,10 +52,11 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.setName(input.single),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.setName(input.single),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
await FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).displaynameHasBeenChanged)
|
||||
.show(context);
|
||||
|
|
@ -82,19 +83,24 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
if (aliases.indexWhere((s) => s == canonicalAlias) == -1) {
|
||||
var newAliases = List<String>.from(aliases);
|
||||
newAliases.add(canonicalAlias);
|
||||
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.client.requestRoomAliasInformations(canonicalAlias),
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.client.requestRoomAliasInformations(canonicalAlias),
|
||||
);
|
||||
if (response == false) {
|
||||
final success =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.client.createRoomAlias(canonicalAlias, widget.room.id),
|
||||
if (response.error != null) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.client
|
||||
.createRoomAlias(canonicalAlias, widget.room.id),
|
||||
);
|
||||
if (success == false) return;
|
||||
if (success.error != null) return;
|
||||
}
|
||||
}
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.client.sendState(widget.room.id, 'm.room.canonical_alias', {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.client
|
||||
.sendState(widget.room.id, 'm.room.canonical_alias', {
|
||||
'alias': input.single,
|
||||
}),
|
||||
);
|
||||
|
|
@ -114,10 +120,11 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.setDescription(input.single),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.setDescription(input.single),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
await FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).groupDescriptionHasBeenChanged)
|
||||
.show(context);
|
||||
|
|
@ -148,10 +155,11 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
);
|
||||
}
|
||||
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.setAvatar(file),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.setAvatar(file),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
await FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).avatarHasBeenChanged)
|
||||
.show(context);
|
||||
|
|
@ -159,9 +167,11 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
}
|
||||
|
||||
void requestMoreMembersAction(BuildContext context) async {
|
||||
final List<User> participants = await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(widget.room.requestParticipants());
|
||||
if (participants != null) setState(() => members = participants);
|
||||
final participants = await showFutureLoadingDialog(
|
||||
context: context, future: () => widget.room.requestParticipants());
|
||||
if (participants.error == null) {
|
||||
setState(() => members = participants.result);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -359,9 +369,10 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
),
|
||||
),
|
||||
onSelected: (JoinRules joinRule) =>
|
||||
SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
widget.room.setJoinRules(joinRule),
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.setJoinRules(joinRule),
|
||||
),
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<JoinRules>>[
|
||||
|
|
@ -399,9 +410,9 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
),
|
||||
onSelected:
|
||||
(HistoryVisibility historyVisibility) =>
|
||||
SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
widget.room
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room
|
||||
.setHistoryVisibility(historyVisibility),
|
||||
),
|
||||
itemBuilder: (BuildContext context) =>
|
||||
|
|
@ -453,9 +464,10 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
),
|
||||
),
|
||||
onSelected: (GuestAccess guestAccess) =>
|
||||
SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
widget.room.setGuestAccess(guestAccess),
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
widget.room.setGuestAccess(guestAccess),
|
||||
),
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<GuestAccess>>[
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/components/connection_status_header.dart';
|
||||
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||
import 'package:fluffychat/components/default_drawer.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
|
@ -142,24 +142,28 @@ class _ChatListState extends State<ChatList> {
|
|||
|
||||
Future<void> _toggleUnread(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
||||
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.setUnread(!room.isUnread),
|
||||
return showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setUnread(!room.isUnread),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _toggleFavouriteRoom(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
||||
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.setFavourite(!room.isFavourite),
|
||||
return showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setFavourite(!room.isFavourite),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _toggleMuted(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
||||
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.setPushRuleState(room.pushRuleState == PushRuleState.notify
|
||||
? PushRuleState.mentions_only
|
||||
: PushRuleState.notify),
|
||||
return showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setPushRuleState(
|
||||
room.pushRuleState == PushRuleState.notify
|
||||
? PushRuleState.mentions_only
|
||||
: PushRuleState.notify),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -170,8 +174,10 @@ class _ChatListState extends State<ChatList> {
|
|||
) ==
|
||||
OkCancelResult.ok;
|
||||
if (!confirmed) return;
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(_archiveSelectedRooms(context));
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => _archiveSelectedRooms(context),
|
||||
);
|
||||
setState(() => null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'dart:developer';
|
|||
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/permission_slider_dialog.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.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';
|
||||
|
|
@ -55,8 +55,10 @@ class ChatPermissionsSettings extends StatelessWidget {
|
|||
content[key] = newLevel;
|
||||
}
|
||||
inspect(content);
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
room.client.sendState(room.id, EventTypes.RoomPowerLevels, content),
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
room.client.sendState(room.id, EventTypes.RoomPowerLevels, content),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
|
|
@ -101,18 +101,19 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
|||
OkCancelResult.cancel) {
|
||||
return;
|
||||
}
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
_joinRoomAndWait(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => _joinRoomAndWait(
|
||||
context,
|
||||
room.roomId,
|
||||
room.canonicalAlias ?? room.aliases.first,
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatView(success),
|
||||
ChatView(success.result),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -41,9 +41,10 @@ class HomeserverPicker extends StatelessWidget {
|
|||
homeserver = 'https://$homeserver';
|
||||
}
|
||||
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
checkHomeserver(homeserver, Matrix.of(context).client));
|
||||
if (success == true) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => checkHomeserver(homeserver, Matrix.of(context).client));
|
||||
if (success.result == true) {
|
||||
await Navigator.of(context)
|
||||
.push(AppRoute(AppConfig.enableRegistration ? SignUp() : Login()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../utils/localized_exception_extension.dart';
|
||||
import 'chat_list.dart';
|
||||
|
||||
class InvitationSelection extends StatefulWidget {
|
||||
|
|
@ -57,10 +58,11 @@ class _InvitationSelectionState extends State<InvitationSelection> {
|
|||
}
|
||||
|
||||
void inviteAction(BuildContext context, String id) async {
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.room.invite(id),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.invite(id),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
await FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).contactHasBeenInvitedToTheGroup)
|
||||
.show(context);
|
||||
|
|
@ -87,11 +89,16 @@ class _InvitationSelectionState extends State<InvitationSelection> {
|
|||
if (loading) return;
|
||||
setState(() => loading = true);
|
||||
final matrix = Matrix.of(context);
|
||||
final response = await SimpleDialogs(context).tryRequestWithErrorToast(
|
||||
matrix.client.searchUser(text, limit: 10),
|
||||
);
|
||||
setState(() => loading = false);
|
||||
if (response == false || (response?.results == null)) return;
|
||||
UserSearchResult response;
|
||||
try {
|
||||
response = await matrix.client.searchUser(text, limit: 10);
|
||||
} catch (e) {
|
||||
FlushbarHelper.createError(
|
||||
message: (e as Object).toLocalizedString(context));
|
||||
return;
|
||||
} finally {
|
||||
setState(() => loading = false);
|
||||
}
|
||||
setState(() {
|
||||
foundProfiles = List<Profile>.from(response.results);
|
||||
if ('@$text'.isValidMatrixId &&
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/firebase_controller.dart';
|
||||
|
|
@ -87,8 +87,10 @@ class _LoginState extends State<Login> {
|
|||
final newDomain = wellKnownInformations.mHomeserver?.baseUrl;
|
||||
if ((newDomain?.isNotEmpty ?? false) &&
|
||||
newDomain != Matrix.of(context).client.homeserver.toString()) {
|
||||
await SimpleDialogs(context).tryRequestWithErrorToast(
|
||||
Matrix.of(context).client.checkHomeserver(newDomain));
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.checkHomeserver(newDomain),
|
||||
);
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -109,14 +111,15 @@ class _LoginState extends State<Login> {
|
|||
);
|
||||
if (input == null) return;
|
||||
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.resetPasswordUsingEmail(
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.resetPasswordUsingEmail(
|
||||
input.single,
|
||||
clientSecret,
|
||||
sendAttempt++,
|
||||
),
|
||||
);
|
||||
if (response == false) return;
|
||||
if (response.error != null) return;
|
||||
final ok = await showOkAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).weSentYouAnEmail,
|
||||
|
|
@ -137,8 +140,9 @@ class _LoginState extends State<Login> {
|
|||
],
|
||||
);
|
||||
if (password == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.changePassword(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.changePassword(
|
||||
password.single,
|
||||
auth: AuthenticationThreePidCreds(
|
||||
type: AuthenticationTypes.emailIdentity,
|
||||
|
|
@ -151,7 +155,7 @@ class _LoginState extends State<Login> {
|
|||
),
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
FlushbarHelper.createSuccess(
|
||||
message: L10n.of(context).passwordHasBeenChanged);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:famedlysdk/matrix_api.dart' as api;
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -33,9 +33,9 @@ class _NewGroupState extends State<_NewGroup> {
|
|||
|
||||
void submitAction(BuildContext context) async {
|
||||
final matrix = Matrix.of(context);
|
||||
final String roomID =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
matrix.client.createRoom(
|
||||
final roomID = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.createRoom(
|
||||
preset: publicGroup
|
||||
? api.CreateRoomPreset.public_chat
|
||||
: api.CreateRoomPreset.private_chat,
|
||||
|
|
@ -51,7 +51,7 @@ class _NewGroupState extends State<_NewGroup> {
|
|||
Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatView(roomID),
|
||||
ChatView(roomID.result),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -59,7 +59,7 @@ class _NewGroupState extends State<_NewGroup> {
|
|||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => InvitationSelection(
|
||||
matrix.client.getRoomById(roomID),
|
||||
matrix.client.getRoomById(roomID.result),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||
|
|
@ -56,15 +56,17 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
|
|||
'@' + controller.text.trim(),
|
||||
room: Room(id: '', client: matrix.client),
|
||||
);
|
||||
final String roomID = await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(user.startDirectChat());
|
||||
final roomID = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => user.startDirectChat(),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (roomID != null) {
|
||||
if (roomID.error == null) {
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatView(roomID),
|
||||
ChatView(roomID.result),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -89,13 +91,14 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
|
|||
if (loading) return;
|
||||
setState(() => loading = true);
|
||||
final matrix = Matrix.of(context);
|
||||
final response = await SimpleDialogs(context).tryRequestWithErrorToast(
|
||||
matrix.client.searchUser(text, limit: 10),
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.searchUser(text, limit: 10),
|
||||
);
|
||||
setState(() => loading = false);
|
||||
if (response == false || (response?.results?.isEmpty ?? true)) return;
|
||||
if (response.result?.results?.isEmpty ?? true) return;
|
||||
setState(() {
|
||||
foundProfiles = List<Profile>.from(response.results);
|
||||
foundProfiles = List<Profile>.from(response.result.results);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||
|
||||
import '../components/adaptive_page_layout.dart';
|
||||
import '../components/content_banner.dart';
|
||||
import '../components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import '../components/matrix.dart';
|
||||
import '../utils/app_route.dart';
|
||||
import '../app_config.dart';
|
||||
|
|
@ -62,8 +62,10 @@ class _SettingsState extends State<Settings> {
|
|||
return;
|
||||
}
|
||||
var matrix = Matrix.of(context);
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(matrix.client.logout());
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.logout(),
|
||||
);
|
||||
}
|
||||
|
||||
void _changePasswordAccountAction(BuildContext context) async {
|
||||
|
|
@ -86,8 +88,9 @@ class _SettingsState extends State<Settings> {
|
|||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context)
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.changePassword(input.last, oldPassword: input.first),
|
||||
);
|
||||
|
|
@ -123,8 +126,9 @@ class _SettingsState extends State<Settings> {
|
|||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.deactivateAccount(
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.deactivateAccount(
|
||||
auth: AuthenticationPassword(
|
||||
password: input.single,
|
||||
user: Matrix.of(context).client.userID,
|
||||
|
|
@ -170,10 +174,12 @@ class _SettingsState extends State<Settings> {
|
|||
);
|
||||
if (input == null) return;
|
||||
final matrix = Matrix.of(context);
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
matrix.client.setDisplayname(matrix.client.userID, input.single),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
matrix.client.setDisplayname(matrix.client.userID, input.single),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
setState(() {
|
||||
profileFuture = null;
|
||||
profile = null;
|
||||
|
|
@ -204,10 +210,11 @@ class _SettingsState extends State<Settings> {
|
|||
);
|
||||
}
|
||||
final matrix = Matrix.of(context);
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
matrix.client.setAvatar(file),
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.setAvatar(file),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
setState(() {
|
||||
profileFuture = null;
|
||||
profile = null;
|
||||
|
|
@ -230,21 +237,22 @@ class _SettingsState extends State<Settings> {
|
|||
],
|
||||
);
|
||||
if (input != null) {
|
||||
final valid = await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(Future.microtask(() async {
|
||||
// make sure the loading spinner shows before we test the keys
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
var valid = false;
|
||||
try {
|
||||
await handle.unlock(recoveryKey: input.single);
|
||||
valid = true;
|
||||
} catch (e, s) {
|
||||
SentryController.captureException(e, s);
|
||||
}
|
||||
return valid;
|
||||
}));
|
||||
final valid = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
// make sure the loading spinner shows before we test the keys
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
var valid = false;
|
||||
try {
|
||||
await handle.unlock(recoveryKey: input.single);
|
||||
valid = true;
|
||||
} catch (e, s) {
|
||||
SentryController.captureException(e, s);
|
||||
}
|
||||
return valid;
|
||||
});
|
||||
|
||||
if (valid == true) {
|
||||
if (valid.result == true) {
|
||||
await handle.maybeCacheAll();
|
||||
await showOkAlertDialog(
|
||||
context: context,
|
||||
|
|
@ -514,28 +522,29 @@ class _SettingsState extends State<Settings> {
|
|||
],
|
||||
);
|
||||
if (input != null) {
|
||||
final valid = await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(Future.microtask(() async {
|
||||
// make sure the loading spinner shows before we test the keys
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
var valid = false;
|
||||
try {
|
||||
await client.encryption.crossSigning
|
||||
.selfSign(recoveryKey: input.single);
|
||||
valid = true;
|
||||
} catch (_) {
|
||||
try {
|
||||
await client.encryption.crossSigning
|
||||
.selfSign(passphrase: input.single);
|
||||
valid = true;
|
||||
} catch (_) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}));
|
||||
final valid = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
// make sure the loading spinner shows before we test the keys
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
var valid = false;
|
||||
try {
|
||||
await client.encryption.crossSigning
|
||||
.selfSign(recoveryKey: input.single);
|
||||
valid = true;
|
||||
} catch (_) {
|
||||
try {
|
||||
await client.encryption.crossSigning
|
||||
.selfSign(passphrase: input.single);
|
||||
valid = true;
|
||||
} catch (_) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
});
|
||||
|
||||
if (valid == true) {
|
||||
if (valid.result == true) {
|
||||
await showOkAlertDialog(
|
||||
context: context,
|
||||
message: L10n.of(context).verifiedSession,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
|
@ -40,14 +40,15 @@ class _Settings3PidState extends State<Settings3Pid> {
|
|||
);
|
||||
if (input == null) return;
|
||||
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.requestEmailToken(
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.requestEmailToken(
|
||||
input.single,
|
||||
clientSecret,
|
||||
Settings3Pid.sendAttempt++,
|
||||
),
|
||||
);
|
||||
if (response == false) return;
|
||||
if (response.error != null) return;
|
||||
final ok = await showOkAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).weSentYouAnEmail,
|
||||
|
|
@ -68,8 +69,9 @@ class _Settings3PidState extends State<Settings3Pid> {
|
|||
],
|
||||
);
|
||||
if (password == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.uiaRequestBackground(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.uiaRequestBackground(
|
||||
(auth) => Matrix.of(context).client.addThirdPartyIdentifier(
|
||||
clientSecret,
|
||||
(response as RequestTokenResponse).sid,
|
||||
|
|
@ -77,7 +79,7 @@ class _Settings3PidState extends State<Settings3Pid> {
|
|||
),
|
||||
),
|
||||
);
|
||||
if (success == false) return;
|
||||
if (success.error != null) return;
|
||||
setState(() => _request = null);
|
||||
}
|
||||
|
||||
|
|
@ -92,12 +94,13 @@ class _Settings3PidState extends State<Settings3Pid> {
|
|||
OkCancelResult.ok) {
|
||||
return;
|
||||
}
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.deleteThirdPartyIdentifier(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.deleteThirdPartyIdentifier(
|
||||
identifier.address,
|
||||
identifier.medium,
|
||||
));
|
||||
if (success == false) return;
|
||||
if (success.error != null) return;
|
||||
setState(() => _request = null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
|
|
@ -60,8 +60,9 @@ class DevicesSettingsState extends State<DevicesSettings> {
|
|||
);
|
||||
if (password == null) return;
|
||||
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
matrix.client.deleteDevices(
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.deleteDevices(
|
||||
deviceIds,
|
||||
auth: AuthenticationPassword(
|
||||
password: password.single,
|
||||
|
|
@ -70,7 +71,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
|
|||
),
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
|
@ -86,12 +87,13 @@ class DevicesSettingsState extends State<DevicesSettings> {
|
|||
],
|
||||
);
|
||||
if (displayName == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context)
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.setDeviceMetadata(device.deviceId, displayName: displayName.single),
|
||||
);
|
||||
if (success != false) {
|
||||
if (success.error == null) {
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../components/adaptive_page_layout.dart';
|
||||
import '../components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import '../components/matrix.dart';
|
||||
import 'chat_list.dart';
|
||||
|
||||
|
|
@ -94,13 +94,16 @@ class _EmotesSettingsState extends State<EmotesSettings> {
|
|||
// remove the old "short" key
|
||||
content.remove('short');
|
||||
if (widget.room != null) {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
client.sendState(widget.room.id, 'im.ponies.room_emotes', content,
|
||||
widget.stateKey ?? ''),
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => client.sendState(widget.room.id, 'im.ponies.room_emotes',
|
||||
content, widget.stateKey ?? ''),
|
||||
);
|
||||
} else {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
client.setAccountData(client.userID, 'im.ponies.user_emotes', content),
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => client.setAccountData(
|
||||
client.userID, 'im.ponies.user_emotes', content),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,8 +131,10 @@ class _EmotesSettingsState extends State<EmotesSettings> {
|
|||
content['rooms'][widget.room.id].remove(widget.stateKey ?? '');
|
||||
}
|
||||
// and save
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
client.setAccountData(client.userID, 'im.ponies.emote_rooms', content),
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => client.setAccountData(
|
||||
client.userID, 'im.ponies.emote_rooms', content),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -477,13 +482,16 @@ class _EmoteImagePickerState extends State<_EmoteImagePicker> {
|
|||
name: result.fileName,
|
||||
);
|
||||
}
|
||||
final uploadResp =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.upload(file.bytes, file.name),
|
||||
final uploadResp = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
Matrix.of(context).client.upload(file.bytes, file.name),
|
||||
);
|
||||
setState(() {
|
||||
widget.controller.text = uploadResp;
|
||||
});
|
||||
if (uploadResp.error == null) {
|
||||
setState(() {
|
||||
widget.controller.text = uploadResp.result;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
|
|
@ -24,8 +24,9 @@ class SettingsIgnoreList extends StatelessWidget {
|
|||
|
||||
void _ignoreUser(BuildContext context) {
|
||||
if (controller.text.isEmpty) return;
|
||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.ignoreUser('@${controller.text}'),
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.ignoreUser('@${controller.text}'),
|
||||
);
|
||||
controller.clear();
|
||||
}
|
||||
|
|
@ -86,9 +87,10 @@ class SettingsIgnoreList extends StatelessWidget {
|
|||
Text(s.data?.displayname ?? client.ignoredUsers[i]),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete_forever_outlined),
|
||||
onPressed: () => SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
client.unignoreUser(client.ignoredUsers[i]),
|
||||
onPressed: () => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
client.unignoreUser(client.ignoredUsers[i]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -107,8 +107,9 @@ class SettingsNotifications extends StatelessWidget {
|
|||
|
||||
void _setNotificationSetting(
|
||||
BuildContext context, NotificationSettingsItem item, bool enabled) {
|
||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.enablePushRule(
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.enablePushRule(
|
||||
'global',
|
||||
item.type,
|
||||
item.key,
|
||||
|
|
@ -136,9 +137,11 @@ class SettingsNotifications extends StatelessWidget {
|
|||
value: !Matrix.of(context).client.allPushNotificationsMuted,
|
||||
title:
|
||||
Text(L10n.of(context).notificationsEnabledForThisAccount),
|
||||
onChanged: (_) =>
|
||||
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.setMuteAllPushNotifications(
|
||||
onChanged: (_) => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.setMuteAllPushNotifications(
|
||||
!Matrix.of(context).client.allPushNotificationsMuted,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue