diff --git a/lib/config/themes.dart b/lib/config/themes.dart index 2125283d37..abb45c2f55 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -123,11 +123,6 @@ abstract class FluffyThemes { ), ), ), - dialogTheme: DialogTheme( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(AppConfig.borderRadius), - ), - ), snackBarTheme: const SnackBarThemeData( behavior: SnackBarBehavior.floating, ), diff --git a/lib/pages/archive/archive.dart b/lib/pages/archive/archive.dart index 64693d7e39..61c6d6a939 100644 --- a/lib/pages/archive/archive.dart +++ b/lib/pages/archive/archive.dart @@ -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/pages/archive/archive_view.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index 19ddfb1e89..88b3f57aab 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:matrix/encryption.dart'; @@ -11,6 +10,7 @@ import 'package:fluffychat/utils/error_reporter.dart'; import 'package:fluffychat/utils/fluffy_share.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/platform_infos.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import '../../utils/adaptive_bottom_sheet.dart'; import '../key_verification/key_verification_dialog.dart'; @@ -366,7 +366,6 @@ class BootstrapDialogState extends State { .verifyOtherDeviceDescription, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - fullyCapitalizedForMaterial: false, ); if (consent != OkCancelResult.ok) return; final req = await showFutureLoadingDialog( @@ -404,7 +403,7 @@ class BootstrapDialogState extends State { message: L10n.of(context).wipeChatBackup, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - isDestructiveAction: true, + isDestructive: true, )) { setState(() => _createBootstrap(true)); } diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 1fee3a572b..811094f8c1 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:collection/collection.dart'; import 'package:desktop_drop/desktop_drop.dart'; import 'package:device_info_plus/device_info_plus.dart'; @@ -33,6 +32,9 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/filtered_timeline_extensi import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/show_scaffold_dialog.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 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/share_scaffold_dialog.dart'; @@ -691,23 +693,22 @@ class ChatController extends State void reportEventAction() async { final event = selectedEvents.single; - final score = await showConfirmationDialog( + final score = await showModalActionPopup( context: context, title: L10n.of(context).reportMessage, message: L10n.of(context).howOffensiveIsThisContent, cancelLabel: L10n.of(context).cancel, - okLabel: L10n.of(context).ok, actions: [ - AlertDialogAction( - key: -100, + AdaptiveModalAction( + value: -100, label: L10n.of(context).extremeOffensive, ), - AlertDialogAction( - key: -50, + AdaptiveModalAction( + value: -50, label: L10n.of(context).offensive, ), - AlertDialogAction( - key: 0, + AdaptiveModalAction( + value: 0, label: L10n.of(context).inoffensive, ), ], @@ -718,15 +719,15 @@ class ChatController extends State title: L10n.of(context).whyDoYouWantToReportThis, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [DialogTextField(hintText: L10n.of(context).reason)], + hintText: L10n.of(context).reason, ); - if (reason == null || reason.single.isEmpty) return; + if (reason == null || reason.isEmpty) return; final result = await showFutureLoadingDialog( context: context, future: () => Matrix.of(context).client.reportContent( event.roomId!, event.eventId, - reason: reason.single, + reason: reason, score: score, ), ); @@ -765,18 +766,14 @@ class ChatController extends State context: context, title: L10n.of(context).redactMessage, message: L10n.of(context).redactMessageDescription, - isDestructiveAction: true, - textFields: [ - DialogTextField( - hintText: L10n.of(context).optionalRedactReason, - ), - ], + isDestructive: true, + hintText: L10n.of(context).optionalRedactReason, okLabel: L10n.of(context).remove, cancelLabel: L10n.of(context).cancel, ) - : []; + : null; if (reasonInput == null) return; - final reason = reasonInput.single.isEmpty ? null : reasonInput.single; + final reason = reasonInput.isEmpty ? null : reasonInput; for (final event in selectedEvents) { await showFutureLoadingDialog( context: context, @@ -1243,21 +1240,21 @@ class ChatController extends State } }); } - final callType = await showModalActionSheet( + final callType = await showModalActionPopup( context: context, title: L10n.of(context).warning, message: L10n.of(context).videoCallsBetaWarning, cancelLabel: L10n.of(context).cancel, actions: [ - SheetAction( + AdaptiveModalAction( label: L10n.of(context).voiceCall, - icon: Icons.phone_outlined, - key: CallType.kVoice, + icon: const Icon(Icons.phone_outlined), + value: CallType.kVoice, ), - SheetAction( + AdaptiveModalAction( label: L10n.of(context).videoCall, - icon: Icons.video_call_outlined, - key: CallType.kVideo, + icon: const Icon(Icons.video_call_outlined), + value: CallType.kVideo, ), ], ); diff --git a/lib/pages/chat/pinned_events.dart b/lib/pages/chat/pinned_events.dart index e56b34d488..c27f606fae 100644 --- a/lib/pages/chat/pinned_events.dart +++ b/lib/pages/chat/pinned_events.dart @@ -2,13 +2,13 @@ import 'dart:async'; 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/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/chat_app_bar_list_tile.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; class PinnedEvents extends StatelessWidget { @@ -30,13 +30,15 @@ class PinnedEvents extends StatelessWidget { final eventId = events.length == 1 ? events.single?.eventId - : await showConfirmationDialog( + : await showModalActionPopup( context: context, - title: L10n.of(context).pinMessage, + title: L10n.of(context).pin, + cancelLabel: L10n.of(context).cancel, actions: events .map( - (event) => AlertDialogAction( - key: event?.eventId ?? '', + (event) => AdaptiveModalAction( + value: event?.eventId ?? '', + icon: const Icon(Icons.push_pin_outlined), label: event?.calcLocalizedBodyFallback( MatrixLocals(L10n.of(context)), withSenderNamePrefix: true, diff --git a/lib/pages/chat/send_file_dialog.dart b/lib/pages/chat/send_file_dialog.dart index e027113a5e..7f0fce3310 100644 --- a/lib/pages/chat/send_file_dialog.dart +++ b/lib/pages/chat/send_file_dialog.dart @@ -14,7 +14,7 @@ import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/size_string.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; import '../../utils/resize_video.dart'; class SendFileDialog extends StatefulWidget { diff --git a/lib/pages/chat/send_location_dialog.dart b/lib/pages/chat/send_location_dialog.dart index bf14460ca6..58c44db2d1 100644 --- a/lib/pages/chat/send_location_dialog.dart +++ b/lib/pages/chat/send_location_dialog.dart @@ -8,7 +8,7 @@ import 'package:geolocator/geolocator.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/pages/chat/events/map_bubble.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; class SendLocationDialog extends StatefulWidget { diff --git a/lib/pages/chat_access_settings/chat_access_settings_controller.dart b/lib/pages/chat_access_settings/chat_access_settings_controller.dart index 6ea313d1e5..bf60017720 100644 --- a/lib/pages/chat_access_settings/chat_access_settings_controller.dart +++ b/lib/pages/chat_access_settings/chat_access_settings_controller.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart' hide Visibility; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/pages/chat_access_settings/chat_access_settings_page.dart'; import 'package:fluffychat/utils/localized_exception_extension.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 'package:fluffychat/widgets/matrix.dart'; @@ -149,14 +151,15 @@ class ChatAccessSettingsController extends State { ); final capabilities = capabilitiesResult.result; if (capabilities == null) return; - final newVersion = await showConfirmationDialog( + final newVersion = await showModalActionPopup( context: context, title: L10n.of(context).replaceRoomWithNewerVersion, + cancelLabel: L10n.of(context).cancel, actions: capabilities.mRoomVersions!.available.entries .where((r) => r.key != roomVersion) .map( - (version) => AlertDialogAction( - key: version.key, + (version) => AdaptiveModalAction( + value: version.key, label: '${version.key} (${version.value.toString().split('.').last})', ), @@ -172,7 +175,7 @@ class ChatAccessSettingsController extends State { cancelLabel: L10n.of(context).cancel, title: L10n.of(context).areYouSure, message: L10n.of(context).roomUpgradeDescription, - isDestructiveAction: true, + isDestructive: true, )) { return; } @@ -191,15 +194,11 @@ class ChatAccessSettingsController extends State { final input = await showTextInputDialog( context: context, title: L10n.of(context).editRoomAliases, - textFields: [ - DialogTextField( - prefixText: '#', - suffixText: domain, - hintText: L10n.of(context).alias, - ), - ], + prefixText: '#', + suffixText: domain, + hintText: L10n.of(context).alias, ); - final aliasLocalpart = input?.singleOrNull?.trim(); + final aliasLocalpart = input?.trim(); if (aliasLocalpart == null || aliasLocalpart.isEmpty) return; final alias = '#$aliasLocalpart:$domain'; diff --git a/lib/pages/chat_details/chat_details.dart b/lib/pages/chat_details/chat_details.dart index 0ee925e0d7..5d5ef30691 100644 --- a/lib/pages/chat_details/chat_details.dart +++ b/lib/pages/chat_details/chat_details.dart @@ -1,6 +1,5 @@ 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:go_router/go_router.dart'; @@ -12,6 +11,8 @@ import 'package:fluffychat/pages/settings/settings.dart'; import 'package:fluffychat/utils/file_selector.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.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_text_input_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -46,20 +47,16 @@ class ChatDetailsController extends State { title: L10n.of(context).changeTheNameOfTheGroup, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - initialText: room.getLocalizedDisplayname( - MatrixLocals( - L10n.of(context), - ), - ), + initialText: room.getLocalizedDisplayname( + MatrixLocals( + L10n.of(context), ), - ], + ), ); if (input == null) return; final success = await showFutureLoadingDialog( context: context, - future: () => room.setName(input.single), + future: () => room.setName(input), ); if (success.error == null) { ScaffoldMessenger.of(context).showSnackBar( @@ -75,19 +72,15 @@ class ChatDetailsController extends State { title: L10n.of(context).setChatDescription, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - hintText: L10n.of(context).noChatDescriptionYet, - initialText: room.topic, - minLines: 4, - maxLines: 8, - ), - ], + hintText: L10n.of(context).noChatDescriptionYet, + initialText: room.topic, + minLines: 4, + maxLines: 8, ); if (input == null) return; final success = await showFutureLoadingDialog( context: context, - future: () => room.setDescription(input.single), + future: () => room.setDescription(input), ); if (success.error == null) { ScaffoldMessenger.of(context).showSnackBar( @@ -116,30 +109,31 @@ class ChatDetailsController extends State { final room = Matrix.of(context).client.getRoomById(roomId!); 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 (room?.avatar != null) - SheetAction( - key: AvatarAction.remove, + AdaptiveModalAction( + value: AvatarAction.remove, label: L10n.of(context).delete, - isDestructiveAction: true, - icon: Icons.delete_outlined, + isDestructive: true, + icon: const Icon(Icons.delete_outlined), ), ]; final action = actions.length == 1 - ? actions.single.key - : await showModalActionSheet( + ? actions.single.value + : await showModalActionPopup( context: context, title: L10n.of(context).editRoomAvatar, + cancelLabel: L10n.of(context).cancel, actions: actions, ); if (action == null) return; diff --git a/lib/pages/chat_encryption_settings/chat_encryption_settings.dart b/lib/pages/chat_encryption_settings/chat_encryption_settings.dart index 35cabad91e..8d0d53c76f 100644 --- a/lib/pages/chat_encryption_settings/chat_encryption_settings.dart +++ b/lib/pages/chat_encryption_settings/chat_encryption_settings.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; import 'package:matrix/encryption.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings_view.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; import '../key_verification/key_verification_dialog.dart'; @@ -76,7 +76,6 @@ class ChatEncryptionSettingsController extends State { message: L10n.of(context).verifyOtherUserDescription, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - fullyCapitalizedForMaterial: false, ); if (consent != OkCancelResult.ok) return; final req = await room.client.userDeviceKeys[room.directChatMatrixID]! diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index badf0e8c9b..5c494acb1c 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -4,7 +4,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:cross_file/cross_file.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_shortcuts/flutter_shortcuts.dart'; @@ -21,6 +20,9 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/show_scaffold_dialog.dart'; import 'package:fluffychat/utils/show_update_snackbar.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/avatar.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/share_scaffold_dialog.dart'; @@ -188,23 +190,19 @@ class ChatListController extends State context: context, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - prefixText: 'https://', - hintText: Matrix.of(context).client.homeserver?.host, - initialText: searchServer, - keyboardType: TextInputType.url, - autocorrect: false, - validator: (server) => server?.contains('.') == true - ? null - : L10n.of(context).invalidServerName, - ), - ], + prefixText: 'https://', + hintText: Matrix.of(context).client.homeserver?.host, + initialText: searchServer, + keyboardType: TextInputType.url, + autocorrect: false, + validator: (server) => server.contains('.') == true + ? null + : L10n.of(context).invalidServerName, ); if (newServer == null) return; - Matrix.of(context).store.setString(_serverStoreNamespace, newServer.single); + Matrix.of(context).store.setString(_serverStoreNamespace, newServer); setState(() { - searchServer = newServer.single; + searchServer = newServer; }); _coolDown?.cancel(); _coolDown = Timer(const Duration(milliseconds: 500), _search); @@ -668,7 +666,7 @@ class ChatListController extends State message: L10n.of(context).archiveRoomDescription, okLabel: L10n.of(context).leave, cancelLabel: L10n.of(context).cancel, - isDestructiveAction: true, + isDestructive: true, ); if (confirmed == OkCancelResult.cancel) return; if (!mounted) return; @@ -677,13 +675,13 @@ class ChatListController extends State return; case ChatContextAction.addToSpace: - final space = await showConfirmationDialog( + final space = await showModalActionPopup( context: context, title: L10n.of(context).space, actions: spacesWithPowerLevels .map( - (space) => AlertDialogAction( - key: space, + (space) => AdaptiveModalAction( + value: space, label: space .getLocalizedDisplayname(MatrixLocals(L10n.of(context))), ), @@ -724,15 +722,11 @@ class ChatListController extends State message: L10n.of(context).leaveEmptyToClearStatus, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - hintText: L10n.of(context).statusExampleMessage, - maxLines: 6, - minLines: 1, - maxLength: 255, - initialText: currentPresence.statusMsg, - ), - ], + hintText: L10n.of(context).statusExampleMessage, + maxLines: 6, + minLines: 1, + maxLength: 255, + initialText: currentPresence.statusMsg, ); if (input == null) return; if (!mounted) return; @@ -741,7 +735,7 @@ class ChatListController extends State future: () => client.setPresence( client.userID!, PresenceType.online, - statusMsg: input.single, + statusMsg: input, ), ); } @@ -834,17 +828,18 @@ class ChatListController extends State final client = Matrix.of(context) .widget .clients[Matrix.of(context).getClientIndexByMatrixId(userId!)]; - final action = await showConfirmationDialog( + final action = await showModalActionPopup( context: context, title: L10n.of(context).editBundlesForAccount, + cancelLabel: L10n.of(context).cancel, actions: [ - AlertDialogAction( - key: EditBundleAction.addToBundle, + AdaptiveModalAction( + value: EditBundleAction.addToBundle, label: L10n.of(context).addToBundle, ), if (activeBundle != client.userID) - AlertDialogAction( - key: EditBundleAction.removeFromBundle, + AdaptiveModalAction( + value: EditBundleAction.removeFromBundle, label: L10n.of(context).removeFromBundle, ), ], @@ -855,12 +850,12 @@ class ChatListController extends State final bundle = await showTextInputDialog( context: context, title: l10n.bundleName, - textFields: [DialogTextField(hintText: l10n.bundleName)], + hintText: l10n.bundleName, ); - if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return; + if (bundle == null || bundle.isEmpty || bundle.isEmpty) return; await showFutureLoadingDialog( context: context, - future: () => client.setAccountBundle(bundle.single), + future: () => client.setAccountBundle(bundle), ); break; case EditBundleAction.removeFromBundle: diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index d7ce698735..a77307f52e 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -1,12 +1,12 @@ 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/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/room_status_extension.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/hover_builder.dart'; import '../../config/themes.dart'; @@ -51,7 +51,7 @@ class ChatListItem extends StatelessWidget { okLabel: L10n.of(context).leave, cancelLabel: L10n.of(context).cancel, message: L10n.of(context).archiveRoomDescription, - isDestructiveAction: true, + isDestructive: true, ); if (confirmed != OkCancelResult.ok) return false; final leaveResult = await showFutureLoadingDialog( diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 5ec81bd5b6..386bb0e2b6 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -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:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/matrix.dart'; import '../../utils/fluffy_share.dart'; diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index dfa6ff9967..73be8cdcf5 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -1,6 +1,5 @@ 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:go_router/go_router.dart'; @@ -13,6 +12,9 @@ import 'package:fluffychat/pages/chat_list/search_title.dart'; import 'package:fluffychat/utils/adaptive_bottom_sheet.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/stream_extension.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/avatar.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -136,7 +138,7 @@ class _SpaceViewState extends State { okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, message: L10n.of(context).archiveRoomDescription, - isDestructiveAction: true, + isDestructive: true, ); if (!mounted) return; if (confirmed != OkCancelResult.ok) return; @@ -152,16 +154,16 @@ class _SpaceViewState extends State { } void _addChatOrSubspace() async { - final roomType = await showConfirmationDialog( + final roomType = await showModalActionPopup( context: context, title: L10n.of(context).addChatOrSubSpace, actions: [ - AlertDialogAction( - key: AddRoomType.subspace, + AdaptiveModalAction( + value: AddRoomType.subspace, label: L10n.of(context).createNewSpace, ), - AlertDialogAction( - key: AddRoomType.chat, + AdaptiveModalAction( + value: AddRoomType.chat, label: L10n.of(context).createGroup, ), ], @@ -173,28 +175,18 @@ class _SpaceViewState extends State { title: roomType == AddRoomType.subspace ? L10n.of(context).createNewSpace : L10n.of(context).createGroup, - textFields: [ - DialogTextField( - hintText: roomType == AddRoomType.subspace - ? L10n.of(context).spaceName - : L10n.of(context).groupName, - minLines: 1, - maxLines: 1, - maxLength: 64, - validator: (text) { - if (text == null || text.isEmpty) { - return L10n.of(context).pleaseChoose; - } - return null; - }, - ), - DialogTextField( - hintText: L10n.of(context).chatDescription, - minLines: 4, - maxLines: 8, - maxLength: 255, - ), - ], + hintText: roomType == AddRoomType.subspace + ? L10n.of(context).spaceName + : L10n.of(context).groupName, + minLines: 1, + maxLines: 1, + maxLength: 64, + validator: (text) { + if (text.isEmpty) { + return L10n.of(context).pleaseChoose; + } + return null; + }, okLabel: L10n.of(context).create, cancelLabel: L10n.of(context).cancel, ); @@ -209,29 +201,20 @@ class _SpaceViewState extends State { if (roomType == AddRoomType.subspace) { roomId = await client.createSpace( - name: names.first, - topic: names.last.isEmpty ? null : names.last, + name: names, visibility: activeSpace.joinRules == JoinRules.public ? sdk.Visibility.public : sdk.Visibility.private, ); } else { roomId = await client.createGroupChat( - groupName: names.first, + groupName: names, preset: activeSpace.joinRules == JoinRules.public ? CreateRoomPreset.publicChat : CreateRoomPreset.privateChat, visibility: activeSpace.joinRules == JoinRules.public ? sdk.Visibility.public : sdk.Visibility.private, - initialState: names.length > 1 && names.last.isNotEmpty - ? [ - StateEvent( - type: EventTypes.RoomTopic, - content: {'topic': names.last}, - ), - ] - : null, ); } await activeSpace.setSpaceChild(roomId); diff --git a/lib/pages/device_settings/device_settings.dart b/lib/pages/device_settings/device_settings.dart index 7d863ef72b..5124ba8251 100644 --- a/lib/pages/device_settings/device_settings.dart +++ b/lib/pages/device_settings/device_settings.dart @@ -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 { 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 { 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 { 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) diff --git a/lib/pages/device_settings/user_device_list_item.dart b/lib/pages/device_settings/user_device_list_item.dart index 96be6c7870..5c9e803290 100644 --- a/lib/pages/device_settings/user_device_list_item.dart +++ b/lib/pages/device_settings/user_device_list_item.dart @@ -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( + final action = await showModalActionPopup( 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, ), ], ); diff --git a/lib/pages/homeserver_picker/homeserver_picker.dart b/lib/pages/homeserver_picker/homeserver_picker.dart index a50083f7ab..e379937cac 100644 --- a/lib/pages/homeserver_picker/homeserver_picker.dart +++ b/lib/pages/homeserver_picker/homeserver_picker.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; 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:flutter_web_auth_2/flutter_web_auth_2.dart'; @@ -17,6 +16,7 @@ import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pages/homeserver_picker/homeserver_picker_view.dart'; import 'package:fluffychat/utils/file_selector.dart'; import 'package:fluffychat/utils/platform_infos.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; import '../../utils/localized_exception_extension.dart'; diff --git a/lib/pages/homeserver_picker/homeserver_picker_view.dart b/lib/pages/homeserver_picker/homeserver_picker_view.dart index ff3045c27a..1d022f68e2 100644 --- a/lib/pages/homeserver_picker/homeserver_picker_view.dart +++ b/lib/pages/homeserver_picker/homeserver_picker_view.dart @@ -6,7 +6,7 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; import 'package:fluffychat/widgets/layouts/login_scaffold.dart'; import 'package:fluffychat/widgets/matrix.dart'; import '../../config/themes.dart'; diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index 8d195149b2..3dfa75be64 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -4,12 +4,12 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/encryption.dart'; import 'package:matrix/matrix.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; @@ -88,7 +88,7 @@ class KeyVerificationPageState extends State { await showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).incorrectPassphraseOrKey, + title: L10n.of(context).incorrectPassphraseOrKey, ); } } diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index af79b7fe84..4ad6ac41ae 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -2,11 +2,12 @@ import 'dart:async'; 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/utils/localized_exception_extension.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 'package:fluffychat/widgets/matrix.dart'; import '../../utils/platform_infos.dart'; @@ -128,7 +129,7 @@ class LoginController extends State { final dialogResult = await showOkCancelAlertDialog( context: context, useRootNavigator: false, - message: L10n.of(context).noMatrixServer(newDomain, oldHomeserver!), + title: L10n.of(context).noMatrixServer(newDomain, oldHomeserver!), okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, ); @@ -162,15 +163,10 @@ class LoginController extends State { message: L10n.of(context).enterAnEmailAddress, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - fullyCapitalizedForMaterial: false, - textFields: [ - DialogTextField( - initialText: - usernameController.text.isEmail ? usernameController.text : '', - hintText: L10n.of(context).enterAnEmailAddress, - keyboardType: TextInputType.emailAddress, - ), - ], + initialText: + usernameController.text.isEmail ? usernameController.text : '', + hintText: L10n.of(context).enterAnEmailAddress, + keyboardType: TextInputType.emailAddress, ); if (input == null) return; final clientSecret = DateTime.now().millisecondsSinceEpoch.toString(); @@ -179,7 +175,7 @@ class LoginController extends State { future: () => Matrix.of(context).getLoginClient().requestTokenToResetPasswordEmail( clientSecret, - input.single, + input, sendAttempt++, ), ); @@ -191,15 +187,10 @@ class LoginController extends State { message: L10n.of(context).chooseAStrongPassword, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - fullyCapitalizedForMaterial: false, - textFields: [ - const DialogTextField( - hintText: '******', - obscureText: true, - minLines: 1, - maxLines: 1, - ), - ], + hintText: '******', + obscureText: true, + minLines: 1, + maxLines: 1, ); if (password == null) return; final ok = await showOkAlertDialog( @@ -208,11 +199,10 @@ class LoginController extends State { title: L10n.of(context).weSentYouAnEmail, message: L10n.of(context).pleaseClickOnLink, okLabel: L10n.of(context).iHaveClickedOnLink, - fullyCapitalizedForMaterial: false, ); if (ok != OkCancelResult.ok) return; final data = { - 'new_password': password.single, + 'new_password': password, 'logout_devices': false, "auth": AuthenticationThreePidCreds( type: AuthenticationTypes.emailIdentity, @@ -234,8 +224,8 @@ class LoginController extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(L10n.of(context).passwordHasBeenChanged)), ); - usernameController.text = input.single; - passwordController.text = password.single; + usernameController.text = input; + passwordController.text = password; login(); } } diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 5ab126359a..6e822f4b7c 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -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 { 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 { 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 { 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( + ? actions.single.value + : await showModalActionPopup( context: context, title: L10n.of(context).changeYourAvatar, + cancelLabel: L10n.of(context).cancel, actions: actions, ); if (action == null) return; diff --git a/lib/pages/settings_3pid/settings_3pid.dart b/lib/pages/settings_3pid/settings_3pid.dart index d738146084..73ec227449 100644 --- a/lib/pages/settings_3pid/settings_3pid.dart +++ b/lib/pages/settings_3pid/settings_3pid.dart @@ -1,9 +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/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 'package:fluffychat/widgets/matrix.dart'; import 'settings_3pid_view.dart'; @@ -25,12 +26,8 @@ class Settings3PidController extends State { title: L10n.of(context).enterAnEmailAddress, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - hintText: L10n.of(context).enterAnEmailAddress, - keyboardType: TextInputType.emailAddress, - ), - ], + hintText: L10n.of(context).enterAnEmailAddress, + keyboardType: TextInputType.emailAddress, ); if (input == null) return; final clientSecret = DateTime.now().millisecondsSinceEpoch.toString(); @@ -38,7 +35,7 @@ class Settings3PidController extends State { context: context, future: () => Matrix.of(context).client.requestTokenToRegisterEmail( clientSecret, - input.single, + input, Settings3Pid.sendAttempt++, ), ); diff --git a/lib/pages/settings_emotes/import_archive_dialog.dart b/lib/pages/settings_emotes/import_archive_dialog.dart index 02cafad78a..b2b5885f2d 100644 --- a/lib/pages/settings_emotes/import_archive_dialog.dart +++ b/lib/pages/settings_emotes/import_archive_dialog.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:archive/archive.dart'; import 'package:collection/collection.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -11,6 +10,7 @@ import 'package:matrix/matrix.dart'; import 'package:fluffychat/pages/settings_emotes/settings_emotes.dart'; import 'package:fluffychat/utils/client_manager.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; class ImportEmoteArchiveDialog extends StatefulWidget { diff --git a/lib/pages/settings_emotes/settings_emotes.dart b/lib/pages/settings_emotes/settings_emotes.dart index 6ace6a0980..3c5b82b04a 100644 --- a/lib/pages/settings_emotes/settings_emotes.dart +++ b/lib/pages/settings_emotes/settings_emotes.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; 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:go_router/go_router.dart'; @@ -13,6 +12,7 @@ import 'package:matrix/matrix.dart'; import 'package:fluffychat/utils/client_manager.dart'; import 'package:fluffychat/utils/file_selector.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import '../../widgets/matrix.dart'; import 'import_archive_dialog.dart'; @@ -139,7 +139,7 @@ class EmotesSettingsController extends State { showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).emoteExists, + title: L10n.of(context).emoteExists, okLabel: L10n.of(context).ok, ); return; @@ -149,7 +149,7 @@ class EmotesSettingsController extends State { showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).emoteInvalid, + title: L10n.of(context).emoteInvalid, okLabel: L10n.of(context).ok, ); return; @@ -185,7 +185,7 @@ class EmotesSettingsController extends State { await showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).emoteWarnNeedToPick, + title: L10n.of(context).emoteWarnNeedToPick, okLabel: L10n.of(context).ok, ); return; @@ -195,7 +195,7 @@ class EmotesSettingsController extends State { await showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).emoteExists, + title: L10n.of(context).emoteExists, okLabel: L10n.of(context).ok, ); return; @@ -204,7 +204,7 @@ class EmotesSettingsController extends State { await showOkAlertDialog( useRootNavigator: false, context: context, - message: L10n.of(context).emoteInvalid, + title: L10n.of(context).emoteInvalid, okLabel: L10n.of(context).ok, ); return; diff --git a/lib/pages/settings_notifications/settings_notifications.dart b/lib/pages/settings_notifications/settings_notifications.dart index 25d3e30387..772cdef5a6 100644 --- a/lib/pages/settings_notifications/settings_notifications.dart +++ b/lib/pages/settings_notifications/settings_notifications.dart @@ -1,11 +1,11 @@ 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/matrix.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import '../../widgets/matrix.dart'; import 'settings_notifications_view.dart'; @@ -138,15 +138,16 @@ class SettingsNotificationsController extends State { } void onPusherTap(Pusher pusher) async { - final delete = await showModalActionSheet( + final delete = await showModalActionPopup( context: context, title: pusher.deviceDisplayName, message: '${pusher.appDisplayName} (${pusher.appId})', + cancelLabel: L10n.of(context).cancel, actions: [ - SheetAction( + AdaptiveModalAction( label: L10n.of(context).delete, - isDestructiveAction: true, - key: true, + isDestructive: true, + value: true, ), ], ); diff --git a/lib/pages/settings_security/settings_security.dart b/lib/pages/settings_security/settings_security.dart index 6134073b24..18625dc04d 100644 --- a/lib/pages/settings_security/settings_security.dart +++ b/lib/pages/settings_security/settings_security.dart @@ -1,9 +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/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart'; import 'package:fluffychat/widgets/app_lock.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -28,25 +29,20 @@ class SettingsSecurityController extends State { title: L10n.of(context).pleaseChooseAPasscode, message: L10n.of(context).pleaseEnter4Digits, cancelLabel: L10n.of(context).cancel, - textFields: [ - DialogTextField( - validator: (text) { - if (text!.isEmpty || - (text.length == 4 && int.tryParse(text)! >= 0)) { - return null; - } - return L10n.of(context).pleaseEnter4Digits; - }, - keyboardType: TextInputType.number, - obscureText: true, - maxLines: 1, - minLines: 1, - maxLength: 4, - ), - ], + validator: (text) { + if (text.isEmpty || (text.length == 4 && int.tryParse(text)! >= 0)) { + return null; + } + return L10n.of(context).pleaseEnter4Digits; + }, + keyboardType: TextInputType.number, + obscureText: true, + maxLines: 1, + minLines: 1, + maxLength: 4, ); if (newLock != null) { - await AppLock.of(context).changePincode(newLock.single); + await AppLock.of(context).changePincode(newLock); } } @@ -58,7 +54,7 @@ class SettingsSecurityController extends State { message: L10n.of(context).deactivateAccountWarning, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - isDestructiveAction: true, + isDestructive: true, ) == OkCancelResult.cancel) { return; @@ -68,18 +64,14 @@ class SettingsSecurityController extends State { useRootNavigator: false, context: context, title: L10n.of(context).confirmMatrixId, - textFields: [ - DialogTextField( - validator: (text) => text == supposedMxid - ? null - : L10n.of(context).supposedMxid(supposedMxid), - ), - ], - isDestructiveAction: true, + validator: (text) => text == supposedMxid + ? null + : L10n.of(context).supposedMxid(supposedMxid), + isDestructive: true, okLabel: L10n.of(context).delete, cancelLabel: L10n.of(context).cancel, ); - if (mxids == null || mxids.length != 1 || mxids.single != supposedMxid) { + if (mxids == null || mxids.length != 1 || mxids != supposedMxid) { return; } final input = await showTextInputDialog( @@ -88,22 +80,18 @@ class SettingsSecurityController extends State { title: L10n.of(context).pleaseEnterYourPassword, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - isDestructiveAction: true, - textFields: [ - const DialogTextField( - obscureText: true, - hintText: '******', - minLines: 1, - maxLines: 1, - ), - ], + isDestructive: true, + obscureText: true, + hintText: '******', + minLines: 1, + maxLines: 1, ); if (input == null) return; await showFutureLoadingDialog( context: context, future: () => Matrix.of(context).client.deactivateAccount( auth: AuthenticationPassword( - password: input.single, + password: input, identifier: AuthenticationUserIdentifier( user: Matrix.of(context).client.userID!, ), diff --git a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart index c2f47d4334..c4c04bf578 100644 --- a/lib/pages/user_bottom_sheet/user_bottom_sheet.dart +++ b/lib/pages/user_bottom_sheet/user_bottom_sheet.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/config/themes.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 'package:fluffychat/widgets/permission_slider_dialog.dart'; import '../../widgets/matrix.dart'; @@ -96,23 +98,22 @@ class UserBottomSheetController extends State { case UserBottomSheetAction.report: if (user == null) throw ('User must not be null for this action!'); - final score = await showConfirmationDialog( + final score = await showModalActionPopup( context: context, title: L10n.of(context).reportUser, message: L10n.of(context).howOffensiveIsThisContent, cancelLabel: L10n.of(context).cancel, - okLabel: L10n.of(context).ok, actions: [ - AlertDialogAction( - key: -100, + AdaptiveModalAction( + value: -100, label: L10n.of(context).extremeOffensive, ), - AlertDialogAction( - key: -50, + AdaptiveModalAction( + value: -50, label: L10n.of(context).offensive, ), - AlertDialogAction( - key: 0, + AdaptiveModalAction( + value: 0, label: L10n.of(context).inoffensive, ), ], @@ -124,16 +125,16 @@ class UserBottomSheetController extends State { title: L10n.of(context).whyDoYouWantToReportThis, okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, - textFields: [DialogTextField(hintText: L10n.of(context).reason)], + hintText: L10n.of(context).reason, ); - if (reason == null || reason.single.isEmpty) return; + if (reason == null || reason.isEmpty) return; final result = await showFutureLoadingDialog( context: context, future: () => Matrix.of(widget.outerContext).client.reportContent( user.room.id, user.id, - reason: reason.single, + reason: reason, score: score, ), ); diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index 72cfb83a2d..7690e4370c 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -8,7 +8,7 @@ import 'package:matrix/matrix.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; class ErrorReporter { final BuildContext context; diff --git a/lib/utils/markdown_context_builder.dart b/lib/utils/markdown_context_builder.dart index bf33f948bf..ce649488e2 100644 --- a/lib/utils/markdown_context_builder.dart +++ b/lib/utils/markdown_context_builder.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart'; + Widget markdownContextBuilder( BuildContext context, EditableTextState editableTextState, @@ -26,27 +27,21 @@ Widget markdownContextBuilder( title: l10n.addLink, okLabel: l10n.ok, cancelLabel: l10n.cancel, - textFields: [ - DialogTextField( - validator: (text) { - if (text == null || text.isEmpty) { - return l10n.pleaseFillOut; - } - try { - text.startsWith('http') - ? Uri.parse(text) - : Uri.https(text); - } catch (_) { - return l10n.invalidUrl; - } - return null; - }, - hintText: 'www...', - keyboardType: TextInputType.url, - ), - ], + validator: (text) { + if (text.isEmpty) { + return l10n.pleaseFillOut; + } + try { + text.startsWith('http') ? Uri.parse(text) : Uri.https(text); + } catch (_) { + return l10n.invalidUrl; + } + return null; + }, + hintText: 'www...', + keyboardType: TextInputType.url, ); - final urlString = input?.singleOrNull; + final urlString = input; if (urlString == null) return; final url = urlString.startsWith('http') ? Uri.parse(urlString) diff --git a/lib/utils/uia_request_manager.dart b/lib/utils/uia_request_manager.dart index 414e5e6477..9187ed2734 100644 --- a/lib/utils/uia_request_manager.dart +++ b/lib/utils/uia_request_manager.dart @@ -1,10 +1,11 @@ import 'dart:async'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; import 'package:url_launcher/url_launcher_string.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/fluffy_chat_app.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -30,16 +31,11 @@ extension UiaRequestManager on MatrixState { title: l10n.pleaseEnterYourPassword, okLabel: l10n.ok, cancelLabel: l10n.cancel, - textFields: [ - const DialogTextField( - minLines: 1, - maxLines: 1, - obscureText: true, - hintText: '******', - ), - ], - )) - ?.single; + minLines: 1, + maxLines: 1, + obscureText: true, + hintText: '******', + )); if (input == null || input.isEmpty) { return uiaRequest.cancel(); } @@ -91,7 +87,7 @@ extension UiaRequestManager on MatrixState { if (OkCancelResult.ok == await showOkCancelAlertDialog( useRootNavigator: false, - message: l10n.pleaseFollowInstructionsOnWeb, + title: l10n.pleaseFollowInstructionsOnWeb, context: navigatorContext, okLabel: l10n.next, cancelLabel: l10n.cancel, diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index 0854621507..da892c893e 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -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:go_router/go_router.dart'; @@ -11,6 +10,7 @@ import 'package:url_launcher/url_launcher_string.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart'; import 'package:fluffychat/utils/adaptive_bottom_sheet.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/public_room_bottom_sheet.dart'; diff --git a/lib/widgets/adaptive_dialog_action.dart b/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart similarity index 100% rename from lib/widgets/adaptive_dialog_action.dart rename to lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart diff --git a/lib/widgets/adaptive_dialogs/show_modal_action_popup.dart b/lib/widgets/adaptive_dialogs/show_modal_action_popup.dart new file mode 100644 index 0000000000..7e67098716 --- /dev/null +++ b/lib/widgets/adaptive_dialogs/show_modal_action_popup.dart @@ -0,0 +1,116 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +Future showModalActionPopup({ + required BuildContext context, + required List> actions, + String? title, + String? message, + String? cancelLabel, + bool useRootNavigator = true, +}) { + final theme = Theme.of(context); + + switch (theme.platform) { + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.windows: + case TargetPlatform.linux: + return showModalBottomSheet( + isScrollControlled: true, + useRootNavigator: useRootNavigator, + context: context, + clipBehavior: Clip.hardEdge, + constraints: BoxConstraints( + maxWidth: 512, + maxHeight: MediaQuery.of(context).size.height - 32, + ), + builder: (context) => ListView( + shrinkWrap: true, + children: [ + if (title != null || message != null) ...[ + ListTile( + title: title == null + ? null + : Text( + title, + style: theme.textTheme.labelSmall, + ), + subtitle: message == null ? null : Text(message), + ), + const Divider(height: 1), + ], + ...actions.map( + (action) => ListTile( + leading: action.icon, + title: Text( + action.label, + maxLines: 1, + style: action.isDestructive + ? TextStyle( + color: theme.colorScheme.error, + fontWeight: + action.isDefaultAction ? FontWeight.bold : null, + ) + : null, + ), + onTap: () => Navigator.of(context).pop(action.value), + ), + ), + if (cancelLabel != null) ...[ + const Divider(height: 1), + ListTile( + title: Text(cancelLabel), + onTap: () => Navigator.of(context).pop(null), + ), + ], + ], + ), + ); + case TargetPlatform.iOS: + case TargetPlatform.macOS: + return showCupertinoModalPopup( + context: context, + useRootNavigator: useRootNavigator, + builder: (context) => ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 512), + child: CupertinoActionSheet( + title: title == null ? null : Text(title), + message: message == null ? null : Text(message), + cancelButton: cancelLabel == null + ? null + : CupertinoActionSheetAction( + onPressed: () => Navigator.of(context).pop(null), + child: Text(cancelLabel), + ), + actions: actions + .map( + (action) => CupertinoActionSheetAction( + isDestructiveAction: action.isDestructive, + isDefaultAction: action.isDefaultAction, + onPressed: () => Navigator.of(context).pop(action.value), + child: Text(action.label, maxLines: 1), + ), + ) + .toList(), + ), + ), + ); + } +} + +class AdaptiveModalAction { + final String label; + final T value; + Icon? icon; + final bool isDefaultAction; + final bool isDestructive; + + AdaptiveModalAction({ + required this.label, + required this.value, + this.icon, + this.isDefaultAction = false, + this.isDestructive = false, + }); +} diff --git a/lib/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart b/lib/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart new file mode 100644 index 0000000000..7e622cc478 --- /dev/null +++ b/lib/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart @@ -0,0 +1,77 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; + +enum OkCancelResult { ok, cancel } + +Future showOkCancelAlertDialog({ + required BuildContext context, + required String title, + String? message, + String? okLabel, + String? cancelLabel, + bool isDestructive = false, + bool useRootNavigator = true, +}) => + showAdaptiveDialog( + context: context, + useRootNavigator: useRootNavigator, + builder: (context) => AlertDialog.adaptive( + title: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: Text(title), + ), + content: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: message == null ? null : Text(message), + ), + actions: [ + AdaptiveDialogAction( + onPressed: () => Navigator.of(context) + .pop(OkCancelResult.cancel), + child: Text(cancelLabel ?? L10n.of(context).cancel), + ), + AdaptiveDialogAction( + onPressed: () => + Navigator.of(context).pop(OkCancelResult.ok), + child: Text( + okLabel ?? L10n.of(context).ok, + style: isDestructive + ? TextStyle(color: Theme.of(context).colorScheme.error) + : null, + ), + ), + ], + ), + ); + +Future showOkAlertDialog({ + required BuildContext context, + required String title, + String? message, + String? okLabel, + bool useRootNavigator = true, +}) => + showAdaptiveDialog( + context: context, + useRootNavigator: useRootNavigator, + builder: (context) => AlertDialog.adaptive( + title: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: Text(title), + ), + content: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: message == null ? null : Text(message), + ), + actions: [ + AdaptiveDialogAction( + onPressed: () => + Navigator.of(context).pop(OkCancelResult.ok), + child: Text(okLabel ?? L10n.of(context).close), + ), + ], + ), + ); diff --git a/lib/widgets/adaptive_dialogs/show_text_input_dialog.dart b/lib/widgets/adaptive_dialogs/show_text_input_dialog.dart new file mode 100644 index 0000000000..b7af8d9ad0 --- /dev/null +++ b/lib/widgets/adaptive_dialogs/show_text_input_dialog.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter_gen/gen_l10n/l10n.dart'; + +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; + +Future showTextInputDialog({ + required BuildContext context, + required String title, + String? message, + String? okLabel, + String? cancelLabel, + bool useRootNavigator = true, + String? hintText, + String? labelText, + String? initialText, + String? prefixText, + String? suffixText, + bool obscureText = false, + bool isDestructive = false, + int? minLines, + int? maxLines, + String? Function(String input)? validator, + TextInputType? keyboardType, + int? maxLength, + bool autocorrect = true, +}) => + showAdaptiveDialog( + context: context, + useRootNavigator: useRootNavigator, + builder: (context) { + final controller = TextEditingController(text: initialText); + final error = ValueNotifier(null); + return ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 512), + child: AlertDialog.adaptive( + title: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: Text(title), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (message != null) + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 256), + child: Text(message), + ), + ), + ValueListenableBuilder( + valueListenable: error, + builder: (context, error, _) { + return TextField( + controller: controller, + obscureText: obscureText, + minLines: minLines, + maxLines: maxLines, + maxLength: maxLength, + keyboardType: keyboardType, + autocorrect: autocorrect, + decoration: InputDecoration( + errorText: error, + hintText: hintText, + labelText: labelText, + prefixText: prefixText, + suffixText: suffixText, + ), + ); + }, + ), + ], + ), + actions: [ + AdaptiveDialogAction( + onPressed: () => Navigator.of(context).pop(null), + child: Text(cancelLabel ?? L10n.of(context).cancel), + ), + AdaptiveDialogAction( + onPressed: () { + final input = controller.text; + final errorText = validator?.call(input); + if (errorText != null) { + error.value = errorText; + return; + } + Navigator.of(context).pop(input); + }, + child: Text( + okLabel ?? L10n.of(context).ok, + style: isDestructive + ? TextStyle(color: Theme.of(context).colorScheme.error) + : null, + ), + ), + ], + ), + ); + }, + ); diff --git a/lib/widgets/chat_settings_popup_menu.dart b/lib/widgets/chat_settings_popup_menu.dart index 8427ca40a5..a31b9e5a34 100644 --- a/lib/widgets/chat_settings_popup_menu.dart +++ b/lib/widgets/chat_settings_popup_menu.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'matrix.dart'; @@ -62,7 +62,7 @@ class ChatSettingsPopupMenuState extends State { okLabel: L10n.of(context).ok, cancelLabel: L10n.of(context).cancel, message: L10n.of(context).archiveRoomDescription, - isDestructiveAction: true, + isDestructive: true, ); if (confirmed == OkCancelResult.ok) { final success = await showFutureLoadingDialog( diff --git a/lib/widgets/future_loading_dialog.dart b/lib/widgets/future_loading_dialog.dart index feffd3b3e9..61a137c256 100644 --- a/lib/widgets/future_loading_dialog.dart +++ b/lib/widgets/future_loading_dialog.dart @@ -6,7 +6,7 @@ import 'package:async/async.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; -import 'package:fluffychat/widgets/adaptive_dialog_action.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/adaptive_dialog_action.dart'; /// Displays a loading dialog which reacts to the given [future]. The dialog /// will be dismissed and the value will be returned when the future completes. diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 891fff9f9a..1dac4ae9cf 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -4,7 +4,6 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:collection/collection.dart'; import 'package:desktop_notifications/desktop_notifications.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -24,6 +23,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dar import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/uia_request_manager.dart'; import 'package:fluffychat/utils/voip_plugin.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/fluffy_chat_app.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import '../config/app_config.dart'; @@ -344,13 +344,11 @@ class MatrixState extends State with WidgetsBindingObserver { this, onFcmError: (errorMsg, {Uri? link}) async { final result = await showOkCancelAlertDialog( - barrierDismissible: true, context: FluffyChatApp .router.routerDelegate.navigatorKey.currentContext ?? context, title: L10n.of(context).pushNotificationsNotAvailable, message: errorMsg, - fullyCapitalizedForMaterial: false, okLabel: link == null ? L10n.of(context).ok : L10n.of(context).learnMore, cancelLabel: L10n.of(context).doNotShowAgain, @@ -470,7 +468,7 @@ class MatrixState extends State with WidgetsBindingObserver { Future dehydrateAction(BuildContext context) async { final response = await showOkCancelAlertDialog( context: context, - isDestructiveAction: true, + isDestructive: true, title: L10n.of(context).dehydrate, message: L10n.of(context).dehydrateWarning, ); diff --git a/lib/widgets/permission_slider_dialog.dart b/lib/widgets/permission_slider_dialog.dart index e568717aa0..cdff7b5cbf 100644 --- a/lib/widgets/permission_slider_dialog.dart +++ b/lib/widgets/permission_slider_dialog.dart @@ -1,9 +1,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart'; + Future showPermissionChooser( BuildContext context, { int currentLevel = 0, @@ -11,24 +12,20 @@ Future showPermissionChooser( final customLevel = await showTextInputDialog( context: context, title: L10n.of(context).setPermissionsLevel, - textFields: [ - DialogTextField( - initialText: currentLevel.toString(), - keyboardType: TextInputType.number, - autocorrect: false, - validator: (text) { - if (text == null) { - return L10n.of(context).pleaseEnterANumber; - } - final level = int.tryParse(text); - if (level == null) { - return L10n.of(context).pleaseEnterANumber; - } - return null; - }, - ), - ], + initialText: currentLevel.toString(), + keyboardType: TextInputType.number, + autocorrect: false, + validator: (text) { + if (text.isEmpty) { + return L10n.of(context).pleaseEnterANumber; + } + final level = int.tryParse(text); + if (level == null) { + return L10n.of(context).pleaseEnterANumber; + } + return null; + }, ); if (customLevel == null) return null; - return int.tryParse(customLevel.first); + return int.tryParse(customLevel); } diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 50894732e6..b737356f93 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,7 +5,6 @@ import FlutterMacOS import Foundation -import appkit_ui_element_colors import audio_session import desktop_drop import device_info_plus @@ -19,8 +18,6 @@ import flutter_web_auth_2 import flutter_webrtc import geolocator_apple import just_audio -import macos_ui -import macos_window_utils import package_info_plus import pasteboard import path_provider_foundation @@ -36,7 +33,6 @@ import wakelock_plus import window_to_front func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - AppkitUiElementColorsPlugin.register(with: registry.registrar(forPlugin: "AppkitUiElementColorsPlugin")) AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) @@ -50,8 +46,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) - MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) - MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 6e60615bf8..cdd398ede2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,14 +14,6 @@ packages: description: dart source: sdk version: "0.3.2" - adaptive_dialog: - dependency: "direct main" - description: - name: adaptive_dialog - sha256: b02055729c225c369f90fdbc9564452e183cb919f83a971f512199084474530f - url: "https://pub.dev" - source: hosted - version: "2.2.1+2" analyzer: dependency: transitive description: @@ -46,14 +38,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - appkit_ui_element_colors: - dependency: transitive - description: - name: appkit_ui_element_colors - sha256: c3e50f900aae314d339de489535736238627071457c4a4a2dbbb1545b4f04f22 - url: "https://pub.dev" - source: hosted - version: "1.0.0" archive: dependency: "direct main" description: @@ -342,14 +326,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.4" - equatable: - dependency: transitive - description: - name: equatable - sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 - url: "https://pub.dev" - source: hosted - version: "2.0.5" fake_async: dependency: transitive description: @@ -861,14 +837,6 @@ packages: url: "https://pub.dev" source: hosted version: "14.3.0" - gradient_borders: - dependency: transitive - description: - name: gradient_borders - sha256: b1cd969552c83f458ff755aa68e13a0327d09f06c3f42f471b423b01427f21f8 - url: "https://pub.dev" - source: hosted - version: "1.0.1" handy_window: dependency: "direct main" description: @@ -1026,14 +994,6 @@ packages: description: flutter source: sdk version: "0.0.0" - intersperse: - dependency: transitive - description: - name: intersperse - sha256: "2f8a905c96f6cbba978644a3d5b31b8d86ddc44917662df7d27a61f3df66a576" - url: "https://pub.dev" - source: hosted - version: "2.0.0" intl: dependency: "direct main" description: @@ -1178,22 +1138,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - macos_ui: - dependency: transitive - description: - name: macos_ui - sha256: "80f6539aba5a3a1182d5225a6c27969a780bcb1d2d8135b4ffb708570cf0c854" - url: "https://pub.dev" - source: hosted - version: "2.0.9" - macos_window_utils: - dependency: transitive - description: - name: macos_window_utils - sha256: "230be594d26f6dee92c5a1544f4242d25138a5bfb9f185b27f14de3949ef0be8" - url: "https://pub.dev" - source: hosted - version: "1.5.0" macros: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8a4f4ba521..ac2dcb8013 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,6 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - adaptive_dialog: ^2.1.0 animations: ^2.0.11 archive: ^3.4.10 async: ^2.11.0