From a9cf33a8eb6e2134bbb48bd5c2a4154a11b902c8 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:54:09 +0530 Subject: [PATCH 01/11] Update dialog for leaving shared albums --- .../gallery/gallery_app_bar_widget.dart | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 85cfef0d7..c81fb0778 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -18,6 +18,7 @@ import 'package:photos/services/sync_service.dart'; import 'package:photos/services/update_service.dart'; import 'package:photos/ui/actions/collection/collection_sharing_actions.dart'; import 'package:photos/ui/common/rename_dialog.dart'; +import 'package:photos/ui/components/action_sheet_widget.dart'; import 'package:photos/ui/components/button_widget.dart'; import 'package:photos/ui/components/dialog_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; @@ -138,21 +139,37 @@ class _GalleryAppBarWidgetState extends State { } Future _leaveAlbum(BuildContext context) async { - final result = await showChoiceDialog( - context, - title: "Leave shared album", - body: "You will leave the album, and it will stop being visible to you", - firstButtonLabel: "Yes, leave", - isCritical: true, - firstButtonOnTap: () async { - await CollectionsService.instance.leaveAlbum(widget.collection!); - if (mounted) { - Navigator.of(context).pop(); - } - }, + final ButtonAction? result = await showActionSheet( + context: context, + buttons: [ + ButtonWidget( + buttonType: ButtonType.critical, + isInAlert: true, + shouldStickToDarkTheme: true, + buttonAction: ButtonAction.first, + shouldSurfaceExecutionStates: true, + labelText: "Leave album", + onTap: () async { + await CollectionsService.instance.leaveAlbum(widget.collection!); + }, + ), + const ButtonWidget( + buttonType: ButtonType.secondary, + buttonAction: ButtonAction.cancel, + isInAlert: true, + shouldStickToDarkTheme: true, + labelText: "Cancel", + ) + ], + title: "Leave shared album??", + body: "Photos added by you will be removed from the album", ); - if (result == ButtonAction.error) { - showGenericErrorDialog(context: context); + if (result != null && mounted) { + if (result == ButtonAction.error) { + showGenericErrorDialog(context: context); + } else if (result == ButtonAction.first) { + Navigator.of(context).pop(); + } } } From 80db5af7b8d60e60e9a41b0221f759cd84f4ce39 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 17:07:10 +0530 Subject: [PATCH 02/11] Add confirmation dialog while deleting shared albums --- .../collection_sharing_actions.dart | 39 +++++++++++++++++++ .../gallery/gallery_app_bar_widget.dart | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index c29506ecc..e193e716e 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -279,6 +279,7 @@ class CollectionActions { } } + // deleteCollectionSheet returns true if the album is successfully deleted Future deleteCollectionSheet( BuildContext bContext, Collection collection, @@ -288,6 +289,13 @@ class CollectionActions { if (collection.owner!.id != currentUserID) { throw AssertionError("Can not delete album owned by others"); } + if (collection.hasSharees) { + final bool confirmDelete = + await _confirmSharedAlbumDeletion(bContext, collection); + if (!confirmDelete) { + return false; + } + } final actionResult = await showActionSheet( context: bContext, buttons: [ @@ -368,6 +376,37 @@ class CollectionActions { return false; } + // _confirmSharedAlbumDeletion should be shown when user tries to delete an + // album shared with other ente users. + Future _confirmSharedAlbumDeletion( + BuildContext context, + Collection collection, + ) async { + final ButtonAction? result = await showActionSheet( + context: context, + buttons: [ + const ButtonWidget( + buttonType: ButtonType.critical, + isInAlert: true, + shouldStickToDarkTheme: true, + buttonAction: ButtonAction.first, + labelText: "Delete album", + ), + const ButtonWidget( + buttonType: ButtonType.secondary, + buttonAction: ButtonAction.cancel, + isInAlert: true, + shouldStickToDarkTheme: true, + labelText: "Cancel", + ) + ], + title: "Delete shared album?", + body: "The album will be deleted for everyone\n\nYou will lose access to " + "shared photos in this album that are owned by others", + ); + return result != null && result == ButtonAction.first; + } + /* _moveFilesFromCurrentCollection removes the file from the current collection. Based on the file and collection ownership, files will be diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index c81fb0778..8d723222f 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -161,7 +161,7 @@ class _GalleryAppBarWidgetState extends State { labelText: "Cancel", ) ], - title: "Leave shared album??", + title: "Leave shared album?", body: "Photos added by you will be removed from the album", ); if (result != null && mounted) { From 13f7a07d31d5a62c5a70a52c87a08db98127572c Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 30 Jan 2023 15:18:24 +0530 Subject: [PATCH 03/11] minor layout and copy change --- lib/ui/components/action_sheet_widget.dart | 2 +- lib/ui/components/dialog_widget.dart | 2 +- lib/utils/dialog_util.dart | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ui/components/action_sheet_widget.dart b/lib/ui/components/action_sheet_widget.dart index 305905a33..b20aea7bb 100644 --- a/lib/ui/components/action_sheet_widget.dart +++ b/lib/ui/components/action_sheet_widget.dart @@ -105,7 +105,7 @@ class ActionSheetWidget extends StatelessWidget { isTitleAndBodyNull ? const SizedBox.shrink() : Padding( - padding: const EdgeInsets.only(bottom: 28), + padding: const EdgeInsets.only(bottom: 36), child: ContentContainerWidget( title: title, bodyWidget: bodyWidget, diff --git a/lib/ui/components/dialog_widget.dart b/lib/ui/components/dialog_widget.dart index 0999c3664..df26b12da 100644 --- a/lib/ui/components/dialog_widget.dart +++ b/lib/ui/components/dialog_widget.dart @@ -112,7 +112,7 @@ class ContentContainer extends StatelessWidget { children: [ Icon( icon, - size: 48, + size: 32, ), ], ), diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dart index 7e2f350b0..d94764de6 100644 --- a/lib/utils/dialog_util.dart +++ b/lib/utils/dialog_util.dart @@ -44,7 +44,8 @@ Future showGenericErrorDialog({ context: context, title: "Error", icon: Icons.error_outline_outlined, - body: "It looks like something went wrong. Please try again.", + body: + "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.", isDismissible: isDismissible, buttons: const [ ButtonWidget( From 59cd4fe01903d54db4316b4650f8fca019a98aea Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 20:48:05 +0530 Subject: [PATCH 04/11] Show collect photos in separate section --- lib/ui/sharing/share_collection_page.dart | 44 +++++++++++------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/lib/ui/sharing/share_collection_page.dart b/lib/ui/sharing/share_collection_page.dart index 61b2be7cb..2627ac0c8 100644 --- a/lib/ui/sharing/share_collection_page.dart +++ b/lib/ui/sharing/share_collection_page.dart @@ -72,7 +72,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.add, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, borderRadius: 4.0, isTopBorderRadiusRemoved: _sharees.isNotEmpty, isBottomBorderRadiusRemoved: true, @@ -102,7 +101,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.add, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, borderRadius: 4.0, isTopBorderRadiusRemoved: _sharees.isNotEmpty, onTap: () async { @@ -132,9 +130,7 @@ class _ShareCollectionPageState extends State { height: 24, ), MenuSectionTitle( - title: hasUrl - ? "Public link enabled" - : (_sharees.isEmpty ? "Or share a link" : "Share a link"), + title: hasUrl ? "Public link enabled" : "Share a link", iconData: Icons.public, ), ]); @@ -149,7 +145,6 @@ class _ShareCollectionPageState extends State { leadingIcon: Icons.error_outline, leadingIconColor: getEnteColorScheme(context).warning500, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async {}, isBottomBorderRadiusRemoved: true, ), @@ -169,7 +164,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.copy, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { await Clipboard.setData(ClipboardData(text: url)); showShortToast(context, "Link copied to clipboard"); @@ -187,7 +181,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.adaptive.share, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { shareText(url); }, @@ -212,7 +205,6 @@ class _ShareCollectionPageState extends State { leadingIcon: Icons.link, trailingIcon: Icons.navigate_next, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIconIsMuted: true, onTap: () async { routeToPage( @@ -237,7 +229,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.link, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, isBottomBorderRadiusRemoved: true, onTap: () async { final bool result = @@ -247,9 +238,17 @@ class _ShareCollectionPageState extends State { } }, ), - DividerWidget( - dividerType: DividerType.menu, - bgColor: getEnteColorScheme(context).fillFaint, + _sharees.isEmpty + ? const MenuSectionDescriptionWidget( + content: "Share with non-ente users", + ) + : const SizedBox.shrink(), + const SizedBox( + height: 24, + ), + const MenuSectionTitle( + title: "Collaborative links", + iconData: Icons.public, ), MenuItemWidget( captionedTextWidget: const CaptionedTextWidget( @@ -258,7 +257,6 @@ class _ShareCollectionPageState extends State { ), leadingIcon: Icons.link, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { final bool result = await collectionActions.enableUrl( context, @@ -270,15 +268,14 @@ class _ShareCollectionPageState extends State { } }, ), + _sharees.isEmpty + ? const MenuSectionDescriptionWidget( + content: + "Create a link to allow people to add and view photos in " + "your shared album without needing an ente app or account. Great for collecting event photos.", + ) + : const SizedBox.shrink(), ]); - if (_sharees.isEmpty && !hasUrl) { - children.add( - const MenuSectionDescriptionWidget( - content: - "Links allow people without an ente account to view and add photos to your shared albums.", - ), - ); - } } return Scaffold( @@ -297,6 +294,7 @@ class _ShareCollectionPageState extends State { padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: children, ), ), @@ -335,7 +333,6 @@ class EmailItemWidget extends StatelessWidget { ), leadingIconSize: 24, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIconIsMuted: true, trailingIcon: Icons.chevron_right, onTap: () async { @@ -361,7 +358,6 @@ class EmailItemWidget extends StatelessWidget { ), leadingIcon: Icons.people_outline, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIconIsMuted: true, trailingIcon: Icons.chevron_right, onTap: () async { From ee7f8c07d369735ad2f74bdef5e0fb3aa78a8721 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 20:55:20 +0530 Subject: [PATCH 05/11] Fixed pressedColor for various menu items --- lib/ui/sharing/album_participants_page.dart | 28 ++++++++++---------- lib/ui/sharing/manage_album_participant.dart | 2 -- lib/ui/sharing/manage_links_widget.dart | 4 --- lib/ui/tools/debug/app_storage_viewer.dart | 2 -- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/ui/sharing/album_participants_page.dart b/lib/ui/sharing/album_participants_page.dart index 4354e898e..e78b814e2 100644 --- a/lib/ui/sharing/album_participants_page.dart +++ b/lib/ui/sharing/album_participants_page.dart @@ -155,14 +155,15 @@ class _AlbumParticipantsPageState extends State { currentUserID: currentUserID, ), menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIcon: isOwner ? Icons.chevron_right : null, trailingIconIsMuted: true, - onTap: () async { - if (isOwner) { - await _navigateToManageUser(currentUser); - } - }, + onTap: isOwner + ? () async { + if (isOwner) { + await _navigateToManageUser(currentUser); + } + } + : null, isTopBorderRadiusRemoved: listIndex > 0, isBottomBorderRadiusRemoved: true, borderRadius: 8, @@ -183,7 +184,6 @@ class _AlbumParticipantsPageState extends State { ), leadingIcon: Icons.add_outlined, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { await _navigateToAddUser(false); }, @@ -229,14 +229,15 @@ class _AlbumParticipantsPageState extends State { currentUserID: currentUserID, ), menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIcon: isOwner ? Icons.chevron_right : null, trailingIconIsMuted: true, - onTap: () async { - if (isOwner) { - await _navigateToManageUser(currentUser); - } - }, + onTap: isOwner + ? () async { + if (isOwner) { + await _navigateToManageUser(currentUser); + } + } + : null, isTopBorderRadiusRemoved: listIndex > 0, isBottomBorderRadiusRemoved: !isLastItem, borderRadius: 8, @@ -257,7 +258,6 @@ class _AlbumParticipantsPageState extends State { ), leadingIcon: Icons.add_outlined, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { await _navigateToAddUser(true); }, diff --git a/lib/ui/sharing/manage_album_participant.dart b/lib/ui/sharing/manage_album_participant.dart index 0241f3131..213597aa5 100644 --- a/lib/ui/sharing/manage_album_participant.dart +++ b/lib/ui/sharing/manage_album_participant.dart @@ -69,7 +69,6 @@ class _ManageIndividualParticipantState ), leadingIcon: Icons.edit_outlined, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIcon: widget.user.isCollaborator ? Icons.check : null, onTap: widget.user.isCollaborator ? null @@ -102,7 +101,6 @@ class _ManageIndividualParticipantState leadingIcon: Icons.photo_outlined, leadingIconColor: getEnteColorScheme(context).strokeBase, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingIcon: widget.user.isViewer ? Icons.check : null, onTap: widget.user.isViewer ? null diff --git a/lib/ui/sharing/manage_links_widget.dart b/lib/ui/sharing/manage_links_widget.dart index bfa5ecb26..65e5365d4 100644 --- a/lib/ui/sharing/manage_links_widget.dart +++ b/lib/ui/sharing/manage_links_widget.dart @@ -81,7 +81,6 @@ class _ManageSharedLinkWidgetState extends State { ), alignCaptionedTextToLeft: true, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingWidget: Switch.adaptive( value: widget.collection!.publicURLs?.firstOrNull ?.enableCollect ?? @@ -153,7 +152,6 @@ class _ManageSharedLinkWidgetState extends State { isBottomBorderRadiusRemoved: true, isTopBorderRadiusRemoved: true, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingWidget: Switch.adaptive( value: widget.collection!.publicURLs?.firstOrNull ?.enableDownload ?? @@ -185,7 +183,6 @@ class _ManageSharedLinkWidgetState extends State { alignCaptionedTextToLeft: true, isTopBorderRadiusRemoved: true, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, trailingWidget: Switch.adaptive( value: widget.collection!.publicURLs?.firstOrNull ?.passwordEnabled ?? @@ -224,7 +221,6 @@ class _ManageSharedLinkWidgetState extends State { leadingIcon: Icons.remove_circle_outline, leadingIconColor: warning500, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { final bool result = await sharingActions.disableUrl( context, diff --git a/lib/ui/tools/debug/app_storage_viewer.dart b/lib/ui/tools/debug/app_storage_viewer.dart index b37b2c84c..d7b368e02 100644 --- a/lib/ui/tools/debug/app_storage_viewer.dart +++ b/lib/ui/tools/debug/app_storage_viewer.dart @@ -161,8 +161,6 @@ class _AppStorageViewerState extends State { ), menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: - getEnteColorScheme(context).fillFaintPressed, borderRadius: 8, onTap: () async { for (var pathItem in paths) { From 66e15ec3a1156ca16e00761a7da81d35b7ef5d0b Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 21:10:49 +0530 Subject: [PATCH 06/11] Fix: Removed pressed state color --- lib/ui/sharing/manage_album_participant.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ui/sharing/manage_album_participant.dart b/lib/ui/sharing/manage_album_participant.dart index 213597aa5..518085f6a 100644 --- a/lib/ui/sharing/manage_album_participant.dart +++ b/lib/ui/sharing/manage_album_participant.dart @@ -136,7 +136,6 @@ class _ManageIndividualParticipantState leadingIcon: Icons.not_interested_outlined, leadingIconColor: warning500, menuItemColor: getEnteColorScheme(context).fillFaint, - pressedColor: getEnteColorScheme(context).fillFaint, onTap: () async { final result = await collectionActions.removeParticipant( context, From 08c202a2611fa1c00ea30d708e794025f382fafa Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 21:43:21 +0530 Subject: [PATCH 07/11] Refactor addEmailToCollection --- .../collection_sharing_actions.dart | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index e193e716e..2bd7aecd3 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -192,7 +192,6 @@ class CollectionActions { String email, { CollectionParticipantRole role = CollectionParticipantRole.viewer, bool showProgress = false, - String? publicKey, }) async { if (!isValidEmail(email)) { await showErrorDialog( @@ -201,30 +200,28 @@ class CollectionActions { "Please enter a valid email address.", ); return null; - } else if (email == Configuration.instance.getEmail()) { + } else if (email.trim() == Configuration.instance.getEmail()) { await showErrorDialog(context, "Oops", "You cannot share with yourself"); return null; } ProgressDialog? dialog; - if (publicKey == null) { - if (showProgress) { - dialog = createProgressDialog(context, "Searching for user..."); - await dialog.show(); - } - - try { - publicKey = await UserService.instance.getPublicKey(email); - await dialog?.hide(); - } catch (e) { - await dialog?.hide(); - logger.severe("Failed to get public key", e); - showGenericErrorDialog(context: context); - return false; - } + String? publicKey; + if (showProgress) { + dialog = createProgressDialog(context, "Sharing...", isDismissible: true); + await dialog.show(); } - // getPublicKey can return null - // ignore: unnecessary_null_comparison + + try { + publicKey = await UserService.instance.getPublicKey(email); + } catch (e) { + await dialog?.hide(); + logger.severe("Failed to get public key", e); + showGenericErrorDialog(context: context); + return false; + } + // getPublicKey can return null when no user is associated with given + // email id if (publicKey == null || publicKey == '') { // todo: neeraj replace this as per the design where a new screen // is used for error. Do this change along with handling of network errors @@ -252,14 +249,6 @@ class CollectionActions { ); return null; } else { - if (showProgress) { - dialog = createProgressDialog( - context, - "Sharing...", - isDismissible: true, - ); - await dialog.show(); - } try { final newSharees = await CollectionsService.instance .share(collection.id, email, publicKey, role); From bab9a0ea3e4e17e11dd4b03ec3a90c7c1f04b5be Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 22:55:16 +0530 Subject: [PATCH 08/11] Refactor addEmailToCollection --- .../collection/collection_sharing_actions.dart | 13 +++++++------ lib/ui/sharing/add_partipant_page.dart | 4 ++-- lib/ui/sharing/manage_album_participant.dart | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index 2bd7aecd3..c94ef1829 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -186,11 +186,12 @@ class CollectionActions { } } - Future addEmailToCollection( + // addEmailToCollection returns true if add operation was successful + Future addEmailToCollection( BuildContext context, Collection collection, - String email, { - CollectionParticipantRole role = CollectionParticipantRole.viewer, + String email, + CollectionParticipantRole role, { bool showProgress = false, }) async { if (!isValidEmail(email)) { @@ -199,10 +200,10 @@ class CollectionActions { "Invalid email address", "Please enter a valid email address.", ); - return null; + return false; } else if (email.trim() == Configuration.instance.getEmail()) { await showErrorDialog(context, "Oops", "You cannot share with yourself"); - return null; + return false; } ProgressDialog? dialog; @@ -247,7 +248,7 @@ class CollectionActions { ), ], ); - return null; + return false; } else { try { final newSharees = await CollectionsService.instance diff --git a/lib/ui/sharing/add_partipant_page.dart b/lib/ui/sharing/add_partipant_page.dart index c535bee2e..ff2c5c5df 100644 --- a/lib/ui/sharing/add_partipant_page.dart +++ b/lib/ui/sharing/add_partipant_page.dart @@ -187,11 +187,11 @@ class _AddParticipantPage extends State { context, widget.collection, emailToAdd, - role: widget.isAddingViewer + widget.isAddingViewer ? CollectionParticipantRole.viewer : CollectionParticipantRole.collaborator, ); - if (result != null && result && mounted) { + if (result && mounted) { Navigator.of(context).pop(true); } }, diff --git a/lib/ui/sharing/manage_album_participant.dart b/lib/ui/sharing/manage_album_participant.dart index 518085f6a..71b179577 100644 --- a/lib/ui/sharing/manage_album_participant.dart +++ b/lib/ui/sharing/manage_album_participant.dart @@ -78,10 +78,10 @@ class _ManageIndividualParticipantState context, widget.collection, widget.user.email, - role: CollectionParticipantRole.collaborator, + CollectionParticipantRole.collaborator, showProgress: true, ); - if ((result ?? false) && mounted) { + if (result && mounted) { widget.user.role = CollectionParticipantRole .collaborator .toStringVal(); @@ -110,10 +110,10 @@ class _ManageIndividualParticipantState context, widget.collection, widget.user.email, - role: CollectionParticipantRole.viewer, + CollectionParticipantRole.viewer, showProgress: true, ); - if ((result ?? false) && mounted) { + if (result && mounted) { widget.user.role = CollectionParticipantRole.viewer.toStringVal(); setState(() => {}); From 8fc2224f62e6d197514af3ac549bfa7a995abb37 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:16:54 +0530 Subject: [PATCH 09/11] Add confirmation dialog for change permission --- .../collection_sharing_actions.dart | 3 +- lib/ui/sharing/manage_album_participant.dart | 60 +++++++++++++++---- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index c94ef1829..1eff29b6f 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -181,9 +181,8 @@ class CollectionActions { showGenericErrorDialog(context: context); } return result == ButtonAction.first; - } else { - return false; } + return false; } // addEmailToCollection returns true if add operation was successful diff --git a/lib/ui/sharing/manage_album_participant.dart b/lib/ui/sharing/manage_album_participant.dart index 71b179577..86aaae546 100644 --- a/lib/ui/sharing/manage_album_participant.dart +++ b/lib/ui/sharing/manage_album_participant.dart @@ -4,12 +4,16 @@ import 'package:photos/services/collections_service.dart'; import 'package:photos/theme/colors.dart'; import 'package:photos/theme/ente_theme.dart'; import 'package:photos/ui/actions/collection/collection_sharing_actions.dart'; +import 'package:photos/ui/components/action_sheet_widget.dart'; +import 'package:photos/ui/components/button_widget.dart'; import 'package:photos/ui/components/captioned_text_widget.dart'; import 'package:photos/ui/components/divider_widget.dart'; import 'package:photos/ui/components/menu_item_widget.dart'; import 'package:photos/ui/components/menu_section_description_widget.dart'; import 'package:photos/ui/components/menu_section_title.dart'; +import 'package:photos/ui/components/models/button_type.dart'; import 'package:photos/ui/components/title_bar_title_widget.dart'; +import 'package:photos/utils/dialog_util.dart'; class ManageIndividualParticipant extends StatefulWidget { final Collection collection; @@ -34,6 +38,7 @@ class _ManageIndividualParticipantState Widget build(BuildContext context) { final colorScheme = getEnteColorScheme(context); final textTheme = getEnteTextTheme(context); + bool isConvertToViewSuccess = false; return Scaffold( appBar: AppBar(), body: Padding( @@ -105,18 +110,51 @@ class _ManageIndividualParticipantState onTap: widget.user.isViewer ? null : () async { - final result = - await collectionActions.addEmailToCollection( - context, - widget.collection, - widget.user.email, - CollectionParticipantRole.viewer, - showProgress: true, + final ButtonAction? result = await showActionSheet( + context: context, + buttons: [ + ButtonWidget( + buttonType: ButtonType.critical, + isInAlert: true, + shouldStickToDarkTheme: true, + buttonAction: ButtonAction.first, + shouldSurfaceExecutionStates: true, + labelText: "Yes, convert to viewer", + onTap: () async { + isConvertToViewSuccess = + await collectionActions.addEmailToCollection( + context, + widget.collection, + widget.user.email, + CollectionParticipantRole.viewer, + ); + }, + ), + const ButtonWidget( + buttonType: ButtonType.secondary, + buttonAction: ButtonAction.cancel, + isInAlert: true, + shouldStickToDarkTheme: true, + labelText: "Cancel", + ) + ], + title: "Change permissions?", + body: + '${widget.user.email} will not be able to add more photos to this album\n\nThey will still be able to remove existing photos added by them', ); - if (result && mounted) { - widget.user.role = - CollectionParticipantRole.viewer.toStringVal(); - setState(() => {}); + if (result != null) { + if (result == ButtonAction.error) { + showGenericErrorDialog(context: context); + } + if (result == ButtonAction.first && + isConvertToViewSuccess && + mounted) { + // reset value + isConvertToViewSuccess = false; + widget.user.role = + CollectionParticipantRole.viewer.toStringVal(); + setState(() => {}); + } } }, isTopBorderRadiusRemoved: true, From 2595f74e44a79fadc58601a1e57cd7a30116cabf Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:18:13 +0530 Subject: [PATCH 10/11] bump version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index af89ffef6..6a999de17 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.7.16+416 +version: 0.7.18+418 environment: sdk: '>=2.17.0 <3.0.0' From 8d96247b052ceb2dae96a7dd804fc7e28f39b98d Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:25:35 +0530 Subject: [PATCH 11/11] Update copy --- lib/ui/sharing/share_collection_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/sharing/share_collection_page.dart b/lib/ui/sharing/share_collection_page.dart index 2627ac0c8..fe2681c02 100644 --- a/lib/ui/sharing/share_collection_page.dart +++ b/lib/ui/sharing/share_collection_page.dart @@ -247,7 +247,7 @@ class _ShareCollectionPageState extends State { height: 24, ), const MenuSectionTitle( - title: "Collaborative links", + title: "Collaborative link", iconData: Icons.public, ), MenuItemWidget(