refactor: Implement own adaptive dialogs and remove package
This commit is contained in:
parent
dea29161c8
commit
8819c40ebd
42 changed files with 597 additions and 439 deletions
|
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
|
@ -10,6 +9,9 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/utils/file_selector.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
import '../bootstrap/bootstrap_dialog.dart';
|
||||
|
|
@ -39,19 +41,14 @@ class SettingsController extends State<Settings> {
|
|||
title: L10n.of(context).editDisplayname,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: profile?.displayName ??
|
||||
Matrix.of(context).client.userID!.localpart,
|
||||
),
|
||||
],
|
||||
initialText:
|
||||
profile?.displayName ?? Matrix.of(context).client.userID!.localpart,
|
||||
);
|
||||
if (input == null) return;
|
||||
final matrix = Matrix.of(context);
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
matrix.client.setDisplayName(matrix.client.userID!, input.single),
|
||||
future: () => matrix.client.setDisplayName(matrix.client.userID!, input),
|
||||
);
|
||||
if (success.error == null) {
|
||||
updateProfile();
|
||||
|
|
@ -65,7 +62,7 @@ class SettingsController extends State<Settings> {
|
|||
context: context,
|
||||
title: L10n.of(context).areYouSureYouWantToLogout,
|
||||
message: L10n.of(context).noBackupWarning,
|
||||
isDestructiveAction: noBackup,
|
||||
isDestructive: noBackup,
|
||||
okLabel: L10n.of(context).logout,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
) ==
|
||||
|
|
@ -83,30 +80,31 @@ class SettingsController extends State<Settings> {
|
|||
final profile = await profileFuture;
|
||||
final actions = [
|
||||
if (PlatformInfos.isMobile)
|
||||
SheetAction(
|
||||
key: AvatarAction.camera,
|
||||
AdaptiveModalAction(
|
||||
value: AvatarAction.camera,
|
||||
label: L10n.of(context).openCamera,
|
||||
isDefaultAction: true,
|
||||
icon: Icons.camera_alt_outlined,
|
||||
icon: const Icon(Icons.camera_alt_outlined),
|
||||
),
|
||||
SheetAction(
|
||||
key: AvatarAction.file,
|
||||
AdaptiveModalAction(
|
||||
value: AvatarAction.file,
|
||||
label: L10n.of(context).openGallery,
|
||||
icon: Icons.photo_outlined,
|
||||
icon: const Icon(Icons.photo_outlined),
|
||||
),
|
||||
if (profile?.avatarUrl != null)
|
||||
SheetAction(
|
||||
key: AvatarAction.remove,
|
||||
AdaptiveModalAction(
|
||||
value: AvatarAction.remove,
|
||||
label: L10n.of(context).removeYourAvatar,
|
||||
isDestructiveAction: true,
|
||||
icon: Icons.delete_outlined,
|
||||
isDestructive: true,
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
),
|
||||
];
|
||||
final action = actions.length == 1
|
||||
? actions.single.key
|
||||
: await showModalActionSheet<AvatarAction>(
|
||||
? actions.single.value
|
||||
: await showModalActionPopup<AvatarAction>(
|
||||
context: context,
|
||||
title: L10n.of(context).changeYourAvatar,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
actions: actions,
|
||||
);
|
||||
if (action == null) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue