From 907c7b791c16646c07cdf1d74ca7e6ef8d6208cb Mon Sep 17 00:00:00 2001 From: ashilkn Date: Thu, 23 Feb 2023 18:49:15 +0530 Subject: [PATCH 1/4] Route to ShareCollectionPage after enabling collect photos for an album which hasLink --- lib/ui/collection_action_sheet.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 9966736ce..1bf7cfc2d 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -440,6 +440,12 @@ class _CollectionActionSheetState extends State { return Future.value(false); } else { try { + unawaited( + routeToPage( + context, + ShareCollectionPage(collection), + ), + ); await CollectionsService.instance .updateShareUrl(collection, {'enableCollect': true}); return true; From c338219789422af1ce5be08b498d4e349d699a7c Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 24 Feb 2023 13:20:35 +0530 Subject: [PATCH 2/4] Show empty state of sharing screen only when incoming and outgoing albums are 0 --- lib/ui/home_widget.dart | 5 ++--- lib/ui/shared_collections_gallery.dart | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ui/home_widget.dart b/lib/ui/home_widget.dart index 3a316513f..0ee01b9bc 100644 --- a/lib/ui/home_widget.dart +++ b/lib/ui/home_widget.dart @@ -40,10 +40,10 @@ import 'package:photos/ui/home/landing_page_widget.dart'; import 'package:photos/ui/home/preserve_footer_widget.dart'; import 'package:photos/ui/home/start_backup_hook_widget.dart'; import 'package:photos/ui/loading_photos_widget.dart'; -import "package:photos/ui/new_shared_collections_gallery.dart"; import 'package:photos/ui/notification/update/change_log_page.dart'; import 'package:photos/ui/settings/app_update_dialog.dart'; import 'package:photos/ui/settings_page.dart'; +import "package:photos/ui/shared_collections_gallery.dart"; import 'package:photos/utils/dialog_util.dart'; import 'package:receive_sharing_intent/receive_sharing_intent.dart'; import 'package:uni_links/uni_links.dart'; @@ -59,8 +59,7 @@ class HomeWidget extends StatefulWidget { class _HomeWidgetState extends State { static const _deviceFolderGalleryWidget = CollectionsGalleryWidget(); - // static const _sharedCollectionGallery = SharedCollectionGallery(); - static const _sharedCollectionGallery = NewSharedCollectionsGallery(); + static const _sharedCollectionGallery = SharedCollectionGallery(); static final _settingsPage = SettingsPage( emailNotifier: UserService.instance.emailValueNotifier, ); diff --git a/lib/ui/shared_collections_gallery.dart b/lib/ui/shared_collections_gallery.dart index 2820e60b4..0c05335c2 100644 --- a/lib/ui/shared_collections_gallery.dart +++ b/lib/ui/shared_collections_gallery.dart @@ -19,6 +19,7 @@ import 'package:photos/theme/colors.dart'; import 'package:photos/ui/collections/section_title.dart'; import 'package:photos/ui/common/gradient_button.dart'; import 'package:photos/ui/common/loading_widget.dart'; +import "package:photos/ui/new_shared_collections_gallery.dart"; import 'package:photos/ui/sharing/user_avator_widget.dart'; import 'package:photos/ui/viewer/file/thumbnail_widget.dart'; import 'package:photos/ui/viewer/gallery/collection_page.dart'; @@ -122,6 +123,10 @@ class _SharedCollectionGalleryState extends State }), builder: (context, snapshot) { if (snapshot.hasData) { + if ((snapshot.data?.incoming.length ?? 0) == 0 && + (snapshot.data?.outgoing.length ?? 0) == 0) { + return const Center(child: EmptyStateWidget()); + } return _getSharedCollectionsGallery(snapshot.data!); } else if (snapshot.hasError) { _logger.severe( From 588be9e4fa505516c27278839f7a4334dc51a0e0 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 24 Feb 2023 13:46:27 +0530 Subject: [PATCH 3/4] Refactored code --- lib/ui/collection_action_sheet.dart | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 1bf7cfc2d..ec012a355 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -324,7 +324,6 @@ class _CollectionActionSheetState extends State { } Future _albumListItemOnTap(CollectionWithThumbnail item) async { - bool showLongToast = false; if (await _runCollectionAction(collection: item.collection)) { late final String toastMessage; bool shouldNavigateToCollection = false; @@ -334,20 +333,14 @@ class _CollectionActionSheetState extends State { } else if (widget.actionType == CollectionActionType.moveFiles) { toastMessage = "Moved successfully to " + item.collection.name!; shouldNavigateToCollection = true; - } else if (widget.actionType == CollectionActionType.collectPhotos) { - toastMessage = - "Collaborative link created for " + item.collection.name!; - showLongToast = true; } else { toastMessage = ""; } if (toastMessage.isNotEmpty) { - showLongToast - ? showToast(context, toastMessage) - : showShortToast( - context, - toastMessage, - ); + showShortToast( + context, + toastMessage, + ); } if (shouldNavigateToCollection) { _navigateToCollection( @@ -446,8 +439,13 @@ class _CollectionActionSheetState extends State { ShareCollectionPage(collection), ), ); - await CollectionsService.instance - .updateShareUrl(collection, {'enableCollect': true}); + CollectionsService.instance + .updateShareUrl(collection, {'enableCollect': true}).then( + (value) => showToast( + context, + "Collaborative link created for " + collection.name!, + ), + ); return true; } catch (e) { showGenericErrorDialog(context: context); @@ -460,6 +458,10 @@ class _CollectionActionSheetState extends State { collection, enableCollect: true, ); + showToast( + context, + "Collaborative link created for " + collection.name!, + ); if (result) { if (Configuration.instance.getUserID() == collection.owner!.id) { unawaited( From 9970099fc5a2033ce35e4c93de418896500a563c Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 24 Feb 2023 14:00:03 +0530 Subject: [PATCH 4/4] Minor change --- lib/ui/collection_action_sheet.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index ec012a355..5dab5d3e8 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -458,11 +458,11 @@ class _CollectionActionSheetState extends State { collection, enableCollect: true, ); - showToast( - context, - "Collaborative link created for " + collection.name!, - ); if (result) { + showToast( + context, + "Collaborative link created for " + collection.name!, + ); if (Configuration.instance.getUserID() == collection.owner!.id) { unawaited( routeToPage(