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
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/encryption/utils/key_verification.dart';
|
||||
|
|
@ -8,6 +7,8 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/pages/device_settings/device_settings_view.dart';
|
||||
import 'package:fluffychat/pages/key_verification/key_verification_dialog.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';
|
||||
|
||||
|
|
@ -54,9 +55,10 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
if (await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).areYouSure,
|
||||
okLabel: L10n.of(context).yes,
|
||||
okLabel: L10n.of(context).remove,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
message: L10n.of(context).removeDevicesDescription,
|
||||
isDestructive: true,
|
||||
) ==
|
||||
OkCancelResult.cancel) return;
|
||||
final matrix = Matrix.of(context);
|
||||
|
|
@ -84,18 +86,14 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
title: L10n.of(context).changeDeviceName,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
hintText: device.displayName,
|
||||
),
|
||||
],
|
||||
hintText: device.displayName,
|
||||
);
|
||||
if (displayName == null) return;
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.updateDevice(device.deviceId, displayName: displayName.single),
|
||||
.updateDevice(device.deviceId, displayName: displayName),
|
||||
);
|
||||
if (success.error == null) {
|
||||
reload();
|
||||
|
|
@ -109,7 +107,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
message: L10n.of(context).verifyOtherDeviceDescription,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
fullyCapitalizedForMaterial: false,
|
||||
);
|
||||
if (consent != OkCancelResult.ok) return;
|
||||
final req = await Matrix.of(context)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import '../../utils/date_time_extension.dart';
|
||||
import '../../utils/matrix_sdk_extensions/device_extension.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
|
|
@ -49,37 +49,43 @@ class UserDeviceListItem extends StatelessWidget {
|
|||
clipBehavior: Clip.hardEdge,
|
||||
child: ListTile(
|
||||
onTap: () async {
|
||||
final action = await showModalActionSheet<UserDeviceListItemAction>(
|
||||
final action = await showModalActionPopup<UserDeviceListItemAction>(
|
||||
context: context,
|
||||
title: '${userDevice.displayName} (${userDevice.deviceId})',
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
actions: [
|
||||
SheetAction(
|
||||
key: UserDeviceListItemAction.rename,
|
||||
AdaptiveModalAction(
|
||||
value: UserDeviceListItemAction.rename,
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
label: L10n.of(context).changeDeviceName,
|
||||
),
|
||||
if (!isOwnDevice && keys != null) ...{
|
||||
SheetAction(
|
||||
key: UserDeviceListItemAction.verify,
|
||||
AdaptiveModalAction(
|
||||
value: UserDeviceListItemAction.verify,
|
||||
icon: const Icon(Icons.verified_outlined),
|
||||
label: L10n.of(context).verifyStart,
|
||||
),
|
||||
if (!keys.blocked)
|
||||
SheetAction(
|
||||
key: UserDeviceListItemAction.block,
|
||||
AdaptiveModalAction(
|
||||
value: UserDeviceListItemAction.block,
|
||||
icon: const Icon(Icons.block_outlined),
|
||||
label: L10n.of(context).blockDevice,
|
||||
isDestructiveAction: true,
|
||||
isDestructive: true,
|
||||
),
|
||||
if (keys.blocked)
|
||||
SheetAction(
|
||||
key: UserDeviceListItemAction.unblock,
|
||||
AdaptiveModalAction(
|
||||
value: UserDeviceListItemAction.unblock,
|
||||
icon: const Icon(Icons.block),
|
||||
label: L10n.of(context).unblockDevice,
|
||||
isDestructiveAction: true,
|
||||
isDestructive: true,
|
||||
),
|
||||
},
|
||||
if (!isOwnDevice)
|
||||
SheetAction(
|
||||
key: UserDeviceListItemAction.remove,
|
||||
AdaptiveModalAction(
|
||||
value: UserDeviceListItemAction.remove,
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
label: L10n.of(context).delete,
|
||||
isDestructiveAction: true,
|
||||
isDestructive: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue