π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] feat: add support for sharing and deleting multiple collections with action sheets
Aman Raj Singh Mouryaf4580c8fdfb6
diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dartindex 87b552269d..24bad57a02 100644--- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart+++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart@@ -27,8 +27,10 @@ import 'package:photos/ui/components/dialog_widget.dart';import 'package:photos/ui/components/models/button_type.dart';import 'package:photos/ui/notification/toast.dart';import 'package:photos/ui/payment/subscription.dart';+import "package:photos/ui/sharing/add_participant_page.dart";import 'package:photos/utils/dialog_util.dart';import 'package:photos/utils/email_util.dart';+import "package:photos/utils/navigation_util.dart";import 'package:photos/utils/share_util.dart';import 'package:photos/utils/standalone/date_time.dart';import "package:styled_text/styled_text.dart";@@ -333,6 +335,157 @@ class CollectionActions {}}+ Future<bool> shareMultipleCollectionSheet(+ BuildContext bContext,+ List<Collection> collection,+ ) async {+ final textTheme = getEnteTextTheme(bContext);+ final actionResult = await showActionSheet(+ context: bContext,+ buttons: [+ ButtonWidget(+ labelText: S.of(bContext).addViewer,+ buttonType: ButtonType.primary,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.first,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ onTap: () async {+ await routeToPage(+ bContext,+ AddParticipantPage(collection[0], true),+ );+ },+ ),+ ButtonWidget(+ labelText: S.of(bContext).addCollaborator,+ buttonType: ButtonType.neutral,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.second,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ onTap: () async {+ await routeToPage(+ bContext,+ AddParticipantPage(collection[0], false),+ );+ },+ ),+ ],+ bodyWidget: StyledText(+ text:+ "<bold>Share ${collection.length} ${collection.length == 1 ? 'album' : 'albums'}</bold>",+ style: textTheme.body.copyWith(color: textMutedDark),+ tags: {+ 'bold': StyledTextTag(+ style: textTheme.body.copyWith(color: textBaseDark),+ ),+ },+ ),+ actionSheetType: ActionSheetType.defaultActionSheet,+ );++ if (actionResult?.action != null &&+ actionResult!.action == ButtonAction.error) {+ await showGenericErrorDialog(+ context: bContext,+ error: actionResult.exception,+ );+ return false;+ }+ if ((actionResult?.action != null) &&+ (actionResult!.action == ButtonAction.first ||+ actionResult.action == ButtonAction.second)) {+ return true;+ }+ return false;+ }++ Future<bool> deleteMultipleCollectionSheet(+ BuildContext bContext,+ List<Collection> collections,+ ) async {+ final textTheme = getEnteTextTheme(bContext);+ final actionResult = await showActionSheet(+ context: bContext,+ buttons: [+ ButtonWidget(+ labelText: S.of(bContext).keepPhotos,+ buttonType: ButtonType.neutral,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.first,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ onTap: () async {+ for (final collection in collections) {+ try {+ await trashCollectionKeepingPhotos(collection, bContext);+ } catch (e, s) {+ logger.severe(+ "Failed to keep photos & delete collection",+ e,+ s,+ );+ rethrow;+ }+ }+ },+ ),+ ButtonWidget(+ labelText: S.of(bContext).deletePhotos,+ buttonType: ButtonType.critical,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.second,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ onTap: () async {+ for (final collection in collections) {+ try {+ await collectionsService.trashNonEmptyCollection(collection);+ } catch (e) {+ logger.severe("Failed to delete collection", e);+ rethrow;+ }+ }+ },+ ),+ ButtonWidget(+ labelText: S.of(bContext).cancel,+ buttonType: ButtonType.secondary,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.third,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ ),+ ],+ bodyWidget: StyledText(+ text:+ "Also delete the photos (and videos) present in these ${collections.length} albums from <bold>all</bold> other albums they are part of?",+ style: textTheme.body.copyWith(color: textMutedDark),+ tags: {+ 'bold': StyledTextTag(+ style: textTheme.body.copyWith(color: textBaseDark),+ ),+ },+ ),+ actionSheetType: ActionSheetType.defaultActionSheet,+ );+ if (actionResult?.action != null &&+ actionResult!.action == ButtonAction.error) {+ await showGenericErrorDialog(+ context: bContext,+ error: actionResult.exception,+ );+ return false;+ }+ if ((actionResult?.action != null) &&+ (actionResult!.action == ButtonAction.first ||+ actionResult.action == ButtonAction.second)) {+ return true;+ }+ return false;+ }+// deleteCollectionSheet returns true if the album is successfully deletedFuture<bool> deleteCollectionSheet(BuildContext bContext,diff --git a/mobile/lib/ui/collections/collection_list_page.dart b/mobile/lib/ui/collections/collection_list_page.dartindex 034a8fd768..47b0da9466 100644--- a/mobile/lib/ui/collections/collection_list_page.dart+++ b/mobile/lib/ui/collections/collection_list_page.dart@@ -73,6 +73,9 @@ class _CollectionListPageState extends State<CollectionListPage> {Widget build(BuildContext context) {final displayLimitCount = (collections?.length ?? 0) +(widget.tag.isEmpty && _searchQuery.isEmpty ? 1 : 0);+ final bool enableSelectionMode =+ widget.sectionType == UISectionType.homeCollections ||+ widget.sectionType == UISectionType.outgoingCollections;return Scaffold(body: SafeArea(child: Stack(@@ -108,8 +111,7 @@ class _CollectionListPageState extends State<CollectionListPage> {collections,displayLimitCount: displayLimitCount,tag: widget.tag,- enableSelectionMode:- widget.sectionType == UISectionType.homeCollections,+ enableSelectionMode: enableSelectionMode,albumViewType: albumViewType ?? AlbumViewType.grid,shouldShowCreateAlbum:widget.sectionType == UISectionType.homeCollections,