refactor: Switch to loading dialog
This commit is contained in:
parent
9521a93622
commit
75797a62b9
36 changed files with 461 additions and 350 deletions
|
|
@ -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>>[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue