Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refactor shared album interaction to use bottom sheet for add confirmation

AmanRajSinghMourya01273a8abbcd
diff --git a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
index 98d9b3c41b..647c53ec33 100644
--- a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
@@ -21,8 +21,6 @@ import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
import "package:photos/ui/collections/album/column_item.dart";
import "package:photos/ui/collections/album/new_list_item.dart";
import 'package:photos/ui/collections/collection_action_sheet.dart';
-import "package:photos/ui/components/buttons/button_widget.dart"
- show ButtonAction;
import 'package:photos/ui/notification/toast.dart';
import "package:photos/ui/sharing/share_collection_page.dart";
import 'package:photos/ui/viewer/gallery/collection_page.dart';
@@ -234,34 +232,53 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
}
Future<void> _sharedAlbumOnTap(BuildContext context, Collection item) async {
- // Show dialog asking if user wants to add instead of move
- final result = await showChoiceActionSheet(
- context,
- title: AppLocalizations.of(context).cannotMoveToSharedAlbums,
- body: AppLocalizations.of(context).cannotMoveToSharedAlbumsMessage,
- icon: Icons.info_outline,
- firstButtonLabel: AppLocalizations.of(context).add,
- secondButtonLabel: AppLocalizations.of(context).cancel,
- );
- if (result?.action == ButtonAction.first) {
- // Perform add operation after dialog is dismissed
- final success = await _addToCollection(context, item.id, true);
- if (success) {
- showShortToast(
+ final shouldAdd = await _showAddToSharedAlbumSheet(context);
+ if (!shouldAdd) {
+ return;
+ }
+
+ final success = await _addToCollection(context, item.id, true);
+ if (success) {
+ showShortToast(
+ context,
+ AppLocalizations.of(
context,
- AppLocalizations.of(
- context,
- ).addedSuccessfullyTo(albumName: item.displayName),
- );
- Navigator.pop(context);
- await _navigateToCollection(context, item);
- }
- } else if (result?.action == ButtonAction.error &&
- result?.exception != null) {
- await showGenericErrorDialog(context: context, error: result!.exception);
+ ).addedSuccessfullyTo(albumName: item.displayName),
+ );
+ Navigator.pop(context);
+ await _navigateToCollection(context, item);
}
}
+ Future<bool> _showAddToSharedAlbumSheet(BuildContext context) async {
+ final l10n = AppLocalizations.of(context);
+ final result = await showBottomSheetComponent<bool>(
+ context: context,
+ builder: (sheetContext) => BottomSheetComponent(
+ title: l10n.cannotMoveToSharedAlbums,
+ content: Text(
+ l10n.cannotMoveToSharedAlbumsMessage,
+ style: TextStyles.body.copyWith(
+ color: sheetContext.componentColors.textLight,
+ ),
+ ),
+ closeTooltip: l10n.close,
+ closeResult: false,
+ actions: [
+ ButtonComponent(
+ label: l10n.add,
+ variant: ButtonComponentVariant.neutral,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ Navigator.of(sheetContext).pop(true);
+ },
+ ),
+ ],
+ ),
+ );
+ return result ?? false;
+ }
+
Future<void> _toggleCollectionSelection(Collection collection) async {
if (widget.selectedCollections.contains(collection)) {
widget.selectedCollections.remove(collection);