From 733b36387f7726d2a6644607018ed8de810c29aa Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 14:30:02 +0530 Subject: [PATCH 01/22] Made EmptyStateItem component --- .../components/empty_state_item_widget.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/ui/components/empty_state_item_widget.dart diff --git a/lib/ui/components/empty_state_item_widget.dart b/lib/ui/components/empty_state_item_widget.dart new file mode 100644 index 000000000..ec5f78162 --- /dev/null +++ b/lib/ui/components/empty_state_item_widget.dart @@ -0,0 +1,29 @@ +import "package:flutter/material.dart"; +import "package:photos/theme/ente_theme.dart"; + +class EmptyStateItemWidget extends StatelessWidget { + final String textContent; + const EmptyStateItemWidget(this.textContent, {super.key}); + + @override + Widget build(BuildContext context) { + final colorScheme = getEnteColorScheme(context); + final textTheme = getEnteTextTheme(context); + return Row( + children: [ + Icon( + Icons.check_outlined, + size: 17, + color: colorScheme.strokeFaint, + ), + const SizedBox(width: 6), + Text( + textContent, + style: textTheme.small.copyWith( + color: colorScheme.textFaint, + ), + ), + ], + ); + } +} From e001ae0a4c3f4519c924b558ad174bd7e56ad010 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 14:51:45 +0530 Subject: [PATCH 02/22] Created screen for empty state for shared collection gallery --- lib/ui/new_shared_collections_gallery.dart | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 lib/ui/new_shared_collections_gallery.dart diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart new file mode 100644 index 000000000..efb1d1adf --- /dev/null +++ b/lib/ui/new_shared_collections_gallery.dart @@ -0,0 +1,92 @@ +import "package:flutter/material.dart"; +import "package:photos/theme/ente_theme.dart"; +import "package:photos/ui/components/button_widget.dart"; +import "package:photos/ui/components/empty_state_item_widget.dart"; +import "package:photos/ui/components/models/button_type.dart"; + +class NewSharedCollectionsGallery extends StatelessWidget { + const NewSharedCollectionsGallery({super.key}); + + @override + Widget build(BuildContext context) { + return const EmptyStateWidget(); + } +} + +class EmptyStateWidget extends StatelessWidget { + const EmptyStateWidget({super.key}); + + @override + Widget build(BuildContext context) { + final textTheme = getEnteTextTheme(context); + return Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 114), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Private sharing", + style: textTheme.h3Bold, + textAlign: TextAlign.start, + ), + const SizedBox(height: 24), + Column( + mainAxisSize: MainAxisSize.min, + children: const [ + EmptyStateItemWidget( + "Share only with the people you want", + ), + SizedBox(height: 12), + EmptyStateItemWidget( + "Use public links for people not on ente", + ), + SizedBox(height: 12), + EmptyStateItemWidget( + "Allow people to add photos", + ), + ], + ), + ], + ), + ), + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Column( + mainAxisSize: MainAxisSize.min, + children: const [ + ButtonWidget( + buttonType: ButtonType.trailingIconPrimary, + labelText: "Share an album now", + icon: Icons.arrow_forward_outlined, + ), + SizedBox(height: 6), + ButtonWidget( + buttonType: ButtonType.trailingIconSecondary, + labelText: "Collect event photos", + icon: Icons.add_photo_alternate_outlined, + ), + SizedBox(height: 6), + ButtonWidget( + buttonType: ButtonType.trailingIconSecondary, + labelText: "Invite your friends", + icon: Icons.ios_share_outlined, + ), + ], + ), + ), + ], + ), + ), + ); + } +} From 1c67e52da0276344f5b156523f06742ac200e2f7 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 15:03:30 +0530 Subject: [PATCH 03/22] Restricted width of Shared collections gallery --- lib/ui/new_shared_collections_gallery.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index efb1d1adf..61e75b34f 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -1,4 +1,5 @@ import "package:flutter/material.dart"; +import "package:photos/core/constants.dart"; import "package:photos/theme/ente_theme.dart"; import "package:photos/ui/components/button_widget.dart"; import "package:photos/ui/components/empty_state_item_widget.dart"; @@ -9,7 +10,12 @@ class NewSharedCollectionsGallery extends StatelessWidget { @override Widget build(BuildContext context) { - return const EmptyStateWidget(); + return Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: restrictedMaxWidth), + child: const EmptyStateWidget(), + ), + ); } } From b382a7007720bdf278ff5fd2b04fa113b7e6182d Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 15:18:28 +0530 Subject: [PATCH 04/22] Handle text overflow --- lib/ui/components/empty_state_item_widget.dart | 11 +++++++---- lib/ui/home/landing_page_widget.dart | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ui/components/empty_state_item_widget.dart b/lib/ui/components/empty_state_item_widget.dart index ec5f78162..8b0ad8e22 100644 --- a/lib/ui/components/empty_state_item_widget.dart +++ b/lib/ui/components/empty_state_item_widget.dart @@ -10,6 +10,7 @@ class EmptyStateItemWidget extends StatelessWidget { final colorScheme = getEnteColorScheme(context); final textTheme = getEnteTextTheme(context); return Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon( Icons.check_outlined, @@ -17,10 +18,12 @@ class EmptyStateItemWidget extends StatelessWidget { color: colorScheme.strokeFaint, ), const SizedBox(width: 6), - Text( - textContent, - style: textTheme.small.copyWith( - color: colorScheme.textFaint, + Flexible( + child: Text( + textContent, + style: textTheme.small.copyWith( + color: colorScheme.textFaint, + ), ), ), ], diff --git a/lib/ui/home/landing_page_widget.dart b/lib/ui/home/landing_page_widget.dart index aa3e44aac..6e03e7257 100644 --- a/lib/ui/home/landing_page_widget.dart +++ b/lib/ui/home/landing_page_widget.dart @@ -219,7 +219,7 @@ class _LandingPageWidgetState extends State { ButtonWidget( buttonType: ButtonType.neutral, buttonAction: ButtonAction.first, - labelText: "Ok", + labelText: "OK", isInAlert: true, ), ], From 6a09972c43d26fc9d30cb34492e000aca7956590 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 15:21:18 +0530 Subject: [PATCH 05/22] Handled possible render over flow error on small devices --- lib/ui/new_shared_collections_gallery.dart | 129 +++++++++++---------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index 61e75b34f..b750d9469 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -25,72 +25,75 @@ class EmptyStateWidget extends StatelessWidget { @override Widget build(BuildContext context) { final textTheme = getEnteTextTheme(context); - return Padding( - padding: const EdgeInsets.fromLTRB(16, 12, 16, 114), + return SingleChildScrollView( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 16), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Private sharing", - style: textTheme.h3Bold, - textAlign: TextAlign.start, - ), - const SizedBox(height: 24), - Column( - mainAxisSize: MainAxisSize.min, - children: const [ - EmptyStateItemWidget( - "Share only with the people you want", - ), - SizedBox(height: 12), - EmptyStateItemWidget( - "Use public links for people not on ente", - ), - SizedBox(height: 12), - EmptyStateItemWidget( - "Allow people to add photos", - ), - ], - ), - ], + padding: const EdgeInsets.fromLTRB(16, 12, 16, 114), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Private sharing", + style: textTheme.h3Bold, + textAlign: TextAlign.start, + ), + const SizedBox(height: 24), + Column( + mainAxisSize: MainAxisSize.min, + children: const [ + EmptyStateItemWidget( + "Share only with the people you want", + ), + SizedBox(height: 12), + EmptyStateItemWidget( + "Use public links for people not on ente", + ), + SizedBox(height: 12), + EmptyStateItemWidget( + "Allow people to add photos", + ), + ], + ), + ], + ), ), - ), - const SizedBox(height: 16), - Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: Column( - mainAxisSize: MainAxisSize.min, - children: const [ - ButtonWidget( - buttonType: ButtonType.trailingIconPrimary, - labelText: "Share an album now", - icon: Icons.arrow_forward_outlined, - ), - SizedBox(height: 6), - ButtonWidget( - buttonType: ButtonType.trailingIconSecondary, - labelText: "Collect event photos", - icon: Icons.add_photo_alternate_outlined, - ), - SizedBox(height: 6), - ButtonWidget( - buttonType: ButtonType.trailingIconSecondary, - labelText: "Invite your friends", - icon: Icons.ios_share_outlined, - ), - ], + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Column( + mainAxisSize: MainAxisSize.min, + children: const [ + ButtonWidget( + buttonType: ButtonType.trailingIconPrimary, + labelText: "Share an album now", + icon: Icons.arrow_forward_outlined, + ), + SizedBox(height: 6), + ButtonWidget( + buttonType: ButtonType.trailingIconSecondary, + labelText: "Collect event photos", + icon: Icons.add_photo_alternate_outlined, + ), + SizedBox(height: 6), + ButtonWidget( + buttonType: ButtonType.trailingIconSecondary, + labelText: "Invite your friends", + icon: Icons.ios_share_outlined, + ), + ], + ), ), - ), - ], + ], + ), ), ), ); From 7daba6326b83e43a292d808128960e1bdaaada08 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 15:43:34 +0530 Subject: [PATCH 06/22] Minor refactoring --- lib/ui/create_collection_sheet.dart | 16 +++++++------- lib/ui/home_widget.dart | 5 ++--- .../file_selection_actions_widget.dart | 21 +++++++------------ .../actions/file_selection_overlay_bar.dart | 5 ++--- lib/ui/viewer/file/fading_app_bar.dart | 9 ++++---- lib/ui/viewer/file/fading_bottom_bar.dart | 5 ++--- 6 files changed, 25 insertions(+), 36 deletions(-) diff --git a/lib/ui/create_collection_sheet.dart b/lib/ui/create_collection_sheet.dart index 8effafe02..34e4ed00b 100644 --- a/lib/ui/create_collection_sheet.dart +++ b/lib/ui/create_collection_sheet.dart @@ -54,17 +54,17 @@ String _actionName(CollectionActionType type, bool plural) { return addTitleSuffix ? text + titleSuffix : text; } -void createCollectionSheet( +void showCollectionActionSheet( + BuildContext context, { SelectedFiles? selectedFiles, List? sharedFiles, - BuildContext context, { CollectionActionType actionType = CollectionActionType.addFiles, bool showOptionToCreateNewAlbum = true, }) { showBarModalBottomSheet( context: context, builder: (context) { - return CreateCollectionSheet( + return CollectionActionSheet( selectedFiles: selectedFiles, sharedFiles: sharedFiles, actionType: actionType, @@ -84,12 +84,12 @@ void createCollectionSheet( ); } -class CreateCollectionSheet extends StatefulWidget { +class CollectionActionSheet extends StatefulWidget { final SelectedFiles? selectedFiles; final List? sharedFiles; final CollectionActionType actionType; final bool showOptionToCreateNewAlbum; - const CreateCollectionSheet({ + const CollectionActionSheet({ required this.selectedFiles, required this.sharedFiles, required this.actionType, @@ -98,11 +98,11 @@ class CreateCollectionSheet extends StatefulWidget { }); @override - State createState() => _CreateCollectionSheetState(); + State createState() => _CollectionActionSheetState(); } -class _CreateCollectionSheetState extends State { - final _logger = Logger((_CreateCollectionSheetState).toString()); +class _CollectionActionSheetState extends State { + final _logger = Logger((_CollectionActionSheetState).toString()); @override Widget build(BuildContext context) { diff --git a/lib/ui/home_widget.dart b/lib/ui/home_widget.dart index 8cd9da256..90f0e009c 100644 --- a/lib/ui/home_widget.dart +++ b/lib/ui/home_widget.dart @@ -336,10 +336,9 @@ class _HomeWidgetState extends State { _shouldRenderCreateCollectionSheet = false; ReceiveSharingIntent.reset(); Future.delayed(const Duration(milliseconds: 10), () { - createCollectionSheet( - null, - _sharedFiles, + showCollectionActionSheet( context, + sharedFiles: _sharedFiles, actionType: CollectionActionType.addFiles, ); }); diff --git a/lib/ui/viewer/actions/file_selection_actions_widget.dart b/lib/ui/viewer/actions/file_selection_actions_widget.dart index ef5a69451..e7279db4c 100644 --- a/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -283,10 +283,9 @@ class _FileSelectionActionWidgetState extends State { widget.selectedFiles .unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true); } - createCollectionSheet( - widget.selectedFiles, - null, + showCollectionActionSheet( context, + selectedFiles: widget.selectedFiles, actionType: CollectionActionType.moveFiles, ); } @@ -296,11 +295,7 @@ class _FileSelectionActionWidgetState extends State { widget.selectedFiles .unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true); } - createCollectionSheet( - widget.selectedFiles, - null, - context, - ); + showCollectionActionSheet(context, selectedFiles: widget.selectedFiles); } Future _onDeleteClick() async { @@ -381,10 +376,9 @@ class _FileSelectionActionWidgetState extends State { widget.selectedFiles .unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true); } - createCollectionSheet( - widget.selectedFiles, - null, + showCollectionActionSheet( context, + selectedFiles: widget.selectedFiles, actionType: CollectionActionType.unHide, ); } @@ -459,10 +453,9 @@ class _FileSelectionActionWidgetState extends State { } void _restore() { - createCollectionSheet( - widget.selectedFiles, - null, + showCollectionActionSheet( context, + selectedFiles: widget.selectedFiles, actionType: CollectionActionType.restoreFiles, ); } diff --git a/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/lib/ui/viewer/actions/file_selection_overlay_bar.dart index 3b36dad98..444fcb224 100644 --- a/lib/ui/viewer/actions/file_selection_overlay_bar.dart +++ b/lib/ui/viewer/actions/file_selection_overlay_bar.dart @@ -85,10 +85,9 @@ class _FileSelectionOverlayBarState extends State { iconButtonType: IconButtonType.primary, iconColor: iconColor, onTap: () { - createCollectionSheet( - widget.selectedFiles, - null, + showCollectionActionSheet( context, + selectedFiles: widget.selectedFiles, actionType: CollectionActionType.unHide, ); }, diff --git a/lib/ui/viewer/file/fading_app_bar.dart b/lib/ui/viewer/file/fading_app_bar.dart index a9d674970..33e87892f 100644 --- a/lib/ui/viewer/file/fading_app_bar.dart +++ b/lib/ui/viewer/file/fading_app_bar.dart @@ -269,12 +269,11 @@ class FadingAppBarState extends State { } Future _handleUnHideRequest(BuildContext context) async { - final s = SelectedFiles(); - s.files.add(widget.file); - createCollectionSheet( - s, - null, + final selectedFiles = SelectedFiles(); + selectedFiles.files.add(widget.file); + showCollectionActionSheet( context, + selectedFiles: selectedFiles, actionType: CollectionActionType.unHide, ); } diff --git a/lib/ui/viewer/file/fading_bottom_bar.dart b/lib/ui/viewer/file/fading_bottom_bar.dart index 6820edebd..03ae9c63e 100644 --- a/lib/ui/viewer/file/fading_bottom_bar.dart +++ b/lib/ui/viewer/file/fading_bottom_bar.dart @@ -237,10 +237,9 @@ class FadingBottomBarState extends State { onPressed: () { final selectedFiles = SelectedFiles(); selectedFiles.toggleSelection(widget.file); - createCollectionSheet( - selectedFiles, - null, + showCollectionActionSheet( context, + selectedFiles: selectedFiles, actionType: CollectionActionType.restoreFiles, ); }, From 328a29da63670197395ceab16afc8e0cfbe85d0f Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 14 Feb 2023 16:02:56 +0530 Subject: [PATCH 07/22] Renamed file --- ..._collection_sheet.dart => collection_action_sheet.dart} | 0 lib/ui/home_widget.dart | 7 ++++--- lib/ui/viewer/actions/file_selection_actions_widget.dart | 2 +- lib/ui/viewer/actions/file_selection_overlay_bar.dart | 2 +- lib/ui/viewer/file/fading_app_bar.dart | 2 +- lib/ui/viewer/file/fading_bottom_bar.dart | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) rename lib/ui/{create_collection_sheet.dart => collection_action_sheet.dart} (100%) diff --git a/lib/ui/create_collection_sheet.dart b/lib/ui/collection_action_sheet.dart similarity index 100% rename from lib/ui/create_collection_sheet.dart rename to lib/ui/collection_action_sheet.dart diff --git a/lib/ui/home_widget.dart b/lib/ui/home_widget.dart index 90f0e009c..3a316513f 100644 --- a/lib/ui/home_widget.dart +++ b/lib/ui/home_widget.dart @@ -28,9 +28,9 @@ import 'package:photos/services/user_service.dart'; import 'package:photos/states/user_details_state.dart'; import 'package:photos/theme/colors.dart'; import 'package:photos/theme/ente_theme.dart'; +import 'package:photos/ui/collection_action_sheet.dart'; import 'package:photos/ui/collections_gallery_widget.dart'; import 'package:photos/ui/common/bottom_shadow.dart'; -import 'package:photos/ui/create_collection_sheet.dart'; import 'package:photos/ui/extents_page_view.dart'; import 'package:photos/ui/home/grant_permissions_widget.dart'; import 'package:photos/ui/home/header_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,7 +59,8 @@ class HomeWidget extends StatefulWidget { class _HomeWidgetState extends State { static const _deviceFolderGalleryWidget = CollectionsGalleryWidget(); - static const _sharedCollectionGallery = SharedCollectionGallery(); + // static const _sharedCollectionGallery = SharedCollectionGallery(); + static const _sharedCollectionGallery = NewSharedCollectionsGallery(); static final _settingsPage = SettingsPage( emailNotifier: UserService.instance.emailValueNotifier, ); diff --git a/lib/ui/viewer/actions/file_selection_actions_widget.dart b/lib/ui/viewer/actions/file_selection_actions_widget.dart index e7279db4c..bd4d0c68f 100644 --- a/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -14,12 +14,12 @@ import 'package:photos/services/hidden_service.dart'; import 'package:photos/theme/ente_theme.dart'; import 'package:photos/ui/actions/collection/collection_file_actions.dart'; import 'package:photos/ui/actions/collection/collection_sharing_actions.dart'; +import 'package:photos/ui/collection_action_sheet.dart'; import 'package:photos/ui/components/action_sheet_widget.dart'; import 'package:photos/ui/components/blur_menu_item_widget.dart'; import 'package:photos/ui/components/bottom_action_bar/expanded_menu_widget.dart'; import 'package:photos/ui/components/button_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; -import 'package:photos/ui/create_collection_sheet.dart'; import 'package:photos/ui/sharing/manage_links_widget.dart'; import 'package:photos/utils/delete_file_util.dart'; import 'package:photos/utils/magic_util.dart'; diff --git a/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/lib/ui/viewer/actions/file_selection_overlay_bar.dart index 444fcb224..81f82c153 100644 --- a/lib/ui/viewer/actions/file_selection_overlay_bar.dart +++ b/lib/ui/viewer/actions/file_selection_overlay_bar.dart @@ -5,9 +5,9 @@ import 'package:photos/models/gallery_type.dart'; import 'package:photos/models/magic_metadata.dart'; import 'package:photos/models/selected_files.dart'; import 'package:photos/theme/ente_theme.dart'; +import 'package:photos/ui/collection_action_sheet.dart'; import 'package:photos/ui/components/bottom_action_bar/bottom_action_bar_widget.dart'; import 'package:photos/ui/components/icon_button_widget.dart'; -import 'package:photos/ui/create_collection_sheet.dart'; import 'package:photos/ui/viewer/actions/file_selection_actions_widget.dart'; import 'package:photos/utils/delete_file_util.dart'; import 'package:photos/utils/magic_util.dart'; diff --git a/lib/ui/viewer/file/fading_app_bar.dart b/lib/ui/viewer/file/fading_app_bar.dart index 33e87892f..8ef731c4d 100644 --- a/lib/ui/viewer/file/fading_app_bar.dart +++ b/lib/ui/viewer/file/fading_app_bar.dart @@ -21,11 +21,11 @@ import 'package:photos/services/favorites_service.dart'; import 'package:photos/services/hidden_service.dart'; import 'package:photos/services/ignored_files_service.dart'; import 'package:photos/services/local_sync_service.dart'; +import 'package:photos/ui/collection_action_sheet.dart'; import 'package:photos/ui/common/progress_dialog.dart'; import 'package:photos/ui/components/action_sheet_widget.dart'; import 'package:photos/ui/components/button_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; -import 'package:photos/ui/create_collection_sheet.dart'; import 'package:photos/ui/viewer/file/custom_app_bar.dart'; import 'package:photos/utils/delete_file_util.dart'; import 'package:photos/utils/dialog_util.dart'; diff --git a/lib/ui/viewer/file/fading_bottom_bar.dart b/lib/ui/viewer/file/fading_bottom_bar.dart index 03ae9c63e..f3c999192 100644 --- a/lib/ui/viewer/file/fading_bottom_bar.dart +++ b/lib/ui/viewer/file/fading_bottom_bar.dart @@ -12,7 +12,7 @@ import 'package:photos/models/trash_file.dart'; import 'package:photos/services/collections_service.dart'; import 'package:photos/theme/colors.dart'; import 'package:photos/theme/ente_theme.dart'; -import 'package:photos/ui/create_collection_sheet.dart'; +import 'package:photos/ui/collection_action_sheet.dart'; import 'package:photos/ui/viewer/file/file_info_widget.dart'; import 'package:photos/utils/delete_file_util.dart'; import 'package:photos/utils/magic_util.dart'; From 50710595828c4e6857f2a970a04da640029fd17b Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Feb 2023 07:20:51 +0530 Subject: [PATCH 08/22] Made 'Share album now' of empty state functional --- lib/ui/collection_action_sheet.dart | 75 +++++++++++++++++----- lib/ui/new_shared_collections_gallery.dart | 24 ++++--- 2 files changed, 74 insertions(+), 25 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 34e4ed00b..8d24e97c8 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -1,3 +1,4 @@ +import "dart:async"; import 'dart:math'; import 'package:collection/collection.dart'; @@ -22,6 +23,7 @@ import 'package:photos/ui/components/button_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; import 'package:photos/ui/components/new_album_list_widget.dart'; import 'package:photos/ui/components/title_bar_title_widget.dart'; +import "package:photos/ui/sharing/share_collection_page.dart"; import 'package:photos/ui/viewer/gallery/collection_page.dart'; import 'package:photos/utils/dialog_util.dart'; import 'package:photos/utils/navigation_util.dart'; @@ -29,7 +31,13 @@ import 'package:photos/utils/share_util.dart'; import 'package:photos/utils/toast_util.dart'; import 'package:receive_sharing_intent/receive_sharing_intent.dart'; -enum CollectionActionType { addFiles, moveFiles, restoreFiles, unHide } +enum CollectionActionType { + addFiles, + moveFiles, + restoreFiles, + unHide, + shareCollection +} String _actionName(CollectionActionType type, bool plural) { bool addTitleSuffix = false; @@ -50,6 +58,9 @@ String _actionName(CollectionActionType type, bool plural) { case CollectionActionType.unHide: text = "Unhide to album"; break; + case CollectionActionType.shareCollection: + text = "Share album"; + break; } return addTitleSuffix ? text + titleSuffix : text; } @@ -108,7 +119,7 @@ class _CollectionActionSheetState extends State { Widget build(BuildContext context) { final filesCount = widget.sharedFiles != null ? widget.sharedFiles!.length - : widget.selectedFiles!.files.length; + : widget.selectedFiles?.files.length ?? 0; return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -125,7 +136,9 @@ class _CollectionActionSheetState extends State { title: TitleBarTitleWidget( title: _actionName(widget.actionType, filesCount > 1), ), - caption: "Create or select album", + caption: widget.showOptionToCreateNewAlbum + ? "Create or select album" + : "Select album", ), Flexible( child: Column( @@ -249,7 +262,7 @@ class _CollectionActionSheetState extends State { final collection = await _createAlbum(albumName); if (collection != null) { if (await _runCollectionAction( - collectionID: collection.id, + collection: collection, showProgressDialog: false, )) { if (widget.actionType == CollectionActionType.restoreFiles) { @@ -281,13 +294,22 @@ class _CollectionActionSheetState extends State { } Future _albumListItemOnTap(CollectionWithThumbnail item) async { - if (await _runCollectionAction(collectionID: item.collection.id)) { - showShortToast( - context, - widget.actionType == CollectionActionType.addFiles - ? "Added successfully to " + item.collection.name! - : "Moved successfully to " + item.collection.name!, - ); + if (await _runCollectionAction(collection: item.collection)) { + late final String toastMessage; + if (widget.actionType == CollectionActionType.addFiles) { + toastMessage = "Added successfully to " + item.collection.name!; + } else if (widget.actionType == CollectionActionType.moveFiles) { + toastMessage = "Moved successfully to " + item.collection.name!; + } else { + toastMessage = ""; + } + if (toastMessage.isNotEmpty) { + showShortToast( + context, + toastMessage, + ); + } + _navigateToCollection( item.collection, ); @@ -327,24 +349,45 @@ class _CollectionActionSheetState extends State { } Future _runCollectionAction({ - required int collectionID, + required Collection collection, bool showProgressDialog = true, }) async { switch (widget.actionType) { case CollectionActionType.addFiles: return _addToCollection( - collectionID: collectionID, + collectionID: collection.id, showProgressDialog: showProgressDialog, ); case CollectionActionType.moveFiles: - return _moveFilesToCollection(collectionID); + return _moveFilesToCollection(collection.id); case CollectionActionType.unHide: - return _moveFilesToCollection(collectionID); + return _moveFilesToCollection(collection.id); case CollectionActionType.restoreFiles: - return _restoreFilesToCollection(collectionID); + return _restoreFilesToCollection(collection.id); + case CollectionActionType.shareCollection: + return _showShareCollectionPage(collection); } } + Future _showShareCollectionPage(Collection collection) { + try { + if (Configuration.instance.getUserID() == collection.owner!.id) { + unawaited( + routeToPage( + context, + ShareCollectionPage(collection), + ), + ); + } else { + showGenericErrorDialog(context: context); + throw Exception("Cannot share collections owned by others"); + } + } catch (e, s) { + _logger.severe(e, s); + } + return Future.value(false); + } + Future _addToCollection({ required int collectionID, required bool showProgressDialog, diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index b750d9469..8b0775a5a 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -1,6 +1,7 @@ import "package:flutter/material.dart"; import "package:photos/core/constants.dart"; import "package:photos/theme/ente_theme.dart"; +import "package:photos/ui/collection_action_sheet.dart"; import "package:photos/ui/components/button_widget.dart"; import "package:photos/ui/components/empty_state_item_widget.dart"; import "package:photos/ui/components/models/button_type.dart"; @@ -71,20 +72,25 @@ class EmptyStateWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 4), child: Column( mainAxisSize: MainAxisSize.min, - children: const [ - ButtonWidget( - buttonType: ButtonType.trailingIconPrimary, - labelText: "Share an album now", - icon: Icons.arrow_forward_outlined, - ), - SizedBox(height: 6), + children: [ ButtonWidget( + buttonType: ButtonType.trailingIconPrimary, + labelText: "Share an album now", + icon: Icons.arrow_forward_outlined, + onTap: () async { + showCollectionActionSheet( + context, + actionType: CollectionActionType.shareCollection, + ); + }), + const SizedBox(height: 6), + const ButtonWidget( buttonType: ButtonType.trailingIconSecondary, labelText: "Collect event photos", icon: Icons.add_photo_alternate_outlined, ), - SizedBox(height: 6), - ButtonWidget( + const SizedBox(height: 6), + const ButtonWidget( buttonType: ButtonType.trailingIconSecondary, labelText: "Invite your friends", icon: Icons.ios_share_outlined, From 29b2cf75302fb8c4cafc0f7a0743dac8aa961496 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Feb 2023 11:07:47 +0530 Subject: [PATCH 09/22] Code refactoring --- lib/ui/collection_action_sheet.dart | 15 ++++++++++----- lib/ui/new_shared_collections_gallery.dart | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 8d24e97c8..6509f6f32 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -296,10 +296,13 @@ class _CollectionActionSheetState extends State { Future _albumListItemOnTap(CollectionWithThumbnail item) async { if (await _runCollectionAction(collection: item.collection)) { late final String toastMessage; + bool shouldNavigateToCollection = false; if (widget.actionType == CollectionActionType.addFiles) { toastMessage = "Added successfully to " + item.collection.name!; + shouldNavigateToCollection = true; } else if (widget.actionType == CollectionActionType.moveFiles) { toastMessage = "Moved successfully to " + item.collection.name!; + shouldNavigateToCollection = true; } else { toastMessage = ""; } @@ -309,10 +312,11 @@ class _CollectionActionSheetState extends State { toastMessage, ); } - - _navigateToCollection( - item.collection, - ); + if (shouldNavigateToCollection) { + _navigateToCollection( + item.collection, + ); + } } } @@ -382,10 +386,11 @@ class _CollectionActionSheetState extends State { showGenericErrorDialog(context: context); throw Exception("Cannot share collections owned by others"); } + return Future.value(true); } catch (e, s) { _logger.severe(e, s); + rethrow; } - return Future.value(false); } Future _addToCollection({ diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index 8b0775a5a..b6f6c76cf 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -74,15 +74,16 @@ class EmptyStateWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ ButtonWidget( - buttonType: ButtonType.trailingIconPrimary, - labelText: "Share an album now", - icon: Icons.arrow_forward_outlined, - onTap: () async { - showCollectionActionSheet( - context, - actionType: CollectionActionType.shareCollection, - ); - }), + buttonType: ButtonType.trailingIconPrimary, + labelText: "Share an album now", + icon: Icons.arrow_forward_outlined, + onTap: () async { + showCollectionActionSheet( + context, + actionType: CollectionActionType.shareCollection, + ); + }, + ), const SizedBox(height: 6), const ButtonWidget( buttonType: ButtonType.trailingIconSecondary, From 665be75fcacb255b7d8f3cefd483cdc46babc6b7 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Feb 2023 12:01:07 +0530 Subject: [PATCH 10/22] Made 'Collect event photos' of empty state functional --- lib/ui/collection_action_sheet.dart | 46 +++++++++++++++++----- lib/ui/new_shared_collections_gallery.dart | 8 +++- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 6509f6f32..d5a859065 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -16,6 +16,7 @@ import 'package:photos/services/ignored_files_service.dart'; import 'package:photos/services/remote_sync_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/common/loading_widget.dart'; import 'package:photos/ui/components/album_list_item_widget.dart'; import 'package:photos/ui/components/bottom_of_title_bar_widget.dart'; @@ -36,7 +37,8 @@ enum CollectionActionType { moveFiles, restoreFiles, unHide, - shareCollection + shareCollection, + collectPhotos, } String _actionName(CollectionActionType type, bool plural) { @@ -59,7 +61,10 @@ String _actionName(CollectionActionType type, bool plural) { text = "Unhide to album"; break; case CollectionActionType.shareCollection: - text = "Share album"; + text = "Share"; + break; + case CollectionActionType.collectPhotos: + text = "Share"; break; } return addTitleSuffix ? text + titleSuffix : text; @@ -303,6 +308,8 @@ 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 = "Created a public link for " + item.collection.name!; } else { toastMessage = ""; } @@ -370,11 +377,20 @@ class _CollectionActionSheetState extends State { return _restoreFilesToCollection(collection.id); case CollectionActionType.shareCollection: return _showShareCollectionPage(collection); + case CollectionActionType.collectPhotos: + return _createCollectPublicLink(collection); } } - Future _showShareCollectionPage(Collection collection) { - try { + Future _createCollectPublicLink(Collection collection) async { + final CollectionActions collectionActions = + CollectionActions(CollectionsService.instance); + final bool result = await collectionActions.enableUrl( + context, + collection, + enableCollect: true, + ); + if (result) { if (Configuration.instance.getUserID() == collection.owner!.id) { unawaited( routeToPage( @@ -384,13 +400,25 @@ class _CollectionActionSheetState extends State { ); } else { showGenericErrorDialog(context: context); - throw Exception("Cannot share collections owned by others"); + _logger.severe("Cannot share collections owned by others"); } - return Future.value(true); - } catch (e, s) { - _logger.severe(e, s); - rethrow; } + return result; + } + + Future _showShareCollectionPage(Collection collection) { + if (Configuration.instance.getUserID() == collection.owner!.id) { + unawaited( + routeToPage( + context, + ShareCollectionPage(collection), + ), + ); + } else { + showGenericErrorDialog(context: context); + _logger.severe("Cannot share collections owned by others"); + } + return Future.value(true); } Future _addToCollection({ diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index b6f6c76cf..3682af433 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -85,10 +85,16 @@ class EmptyStateWidget extends StatelessWidget { }, ), const SizedBox(height: 6), - const ButtonWidget( + ButtonWidget( buttonType: ButtonType.trailingIconSecondary, labelText: "Collect event photos", icon: Icons.add_photo_alternate_outlined, + onTap: () async { + showCollectionActionSheet( + context, + actionType: CollectionActionType.collectPhotos, + ); + }, ), const SizedBox(height: 6), const ButtonWidget( From 17e058e25795958b694811f6adb8086a37b5db5e Mon Sep 17 00:00:00 2001 From: ashilkn Date: Wed, 15 Feb 2023 13:01:26 +0530 Subject: [PATCH 11/22] Removed incoming shared collections from collectionActionSheet for 'Share an album now' & 'Collect event photos' --- lib/ui/collection_action_sheet.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index d5a859065..568e30c6b 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -165,6 +165,9 @@ class _CollectionActionSheetState extends State { } else if (snapshot.hasData) { final collectionsWithThumbnail = snapshot .data as List; + _removeIncomingCollections( + collectionsWithThumbnail, + ); return ListView.separated( itemBuilder: (context, index) { if (index == 0 && @@ -359,6 +362,16 @@ class _CollectionActionSheetState extends State { ); } + _removeIncomingCollections(List items) { + if (widget.actionType == CollectionActionType.shareCollection || + widget.actionType == CollectionActionType.collectPhotos) { + final ownerID = Configuration.instance.getUserID(); + items.removeWhere( + (e) => !e.collection.isOwner(ownerID!), + ); + } + } + Future _runCollectionAction({ required Collection collection, bool showProgressDialog = true, From 6824b80f1123a8cdeadeafc9c0612f6d7591bb75 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 17 Feb 2023 12:43:37 +0530 Subject: [PATCH 12/22] Show longer toast on making a collab link + change copy of toast --- lib/ui/collection_action_sheet.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 568e30c6b..79dcf287e 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -302,6 +302,7 @@ 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; @@ -312,15 +313,19 @@ class _CollectionActionSheetState extends State { toastMessage = "Moved successfully to " + item.collection.name!; shouldNavigateToCollection = true; } else if (widget.actionType == CollectionActionType.collectPhotos) { - toastMessage = "Created a public link for " + item.collection.name!; + toastMessage = + "Collaborative link created for " + item.collection.name!; + showLongToast = true; } else { toastMessage = ""; } if (toastMessage.isNotEmpty) { - showShortToast( - context, - toastMessage, - ); + showLongToast + ? showToast(context, toastMessage) + : showShortToast( + context, + toastMessage, + ); } if (shouldNavigateToCollection) { _navigateToCollection( From 0d031f1c3fdd3e1cf67d19fa441e32053f52a27b Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 17 Feb 2023 12:51:55 +0530 Subject: [PATCH 13/22] Renamed method --- lib/ui/collection_action_sheet.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index 79dcf287e..fe38b424e 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -396,11 +396,11 @@ class _CollectionActionSheetState extends State { case CollectionActionType.shareCollection: return _showShareCollectionPage(collection); case CollectionActionType.collectPhotos: - return _createCollectPublicLink(collection); + return _createCollaborativeLink(collection); } } - Future _createCollectPublicLink(Collection collection) async { + Future _createCollaborativeLink(Collection collection) async { final CollectionActions collectionActions = CollectionActions(CollectionsService.instance); final bool result = await collectionActions.enableUrl( From e8098cbe2af744ed32b0c99632292e6000f003b7 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 17 Feb 2023 14:57:43 +0530 Subject: [PATCH 14/22] Handled cases where an album already has a collab link + enabling collab links for exiting public links --- lib/ui/collection_action_sheet.dart | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index fe38b424e..aa2216bb3 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -403,6 +403,29 @@ class _CollectionActionSheetState extends State { Future _createCollaborativeLink(Collection collection) async { final CollectionActions collectionActions = CollectionActions(CollectionsService.instance); + + if (collection.hasLink) { + if (collection.publicURLs!.first!.enableCollect) { + if (Configuration.instance.getUserID() == collection.owner!.id) { + unawaited( + routeToPage( + context, + ShareCollectionPage(collection), + ), + ); + } + showToast(context, "This album already has a collaborative link"); + return Future.value(false); + } else { + CollectionsService.instance + .updateShareUrl(collection, {'enableCollect': true}).then( + (value) => true, + onError: (e, s) { + return false; + }, + ); + } + } final bool result = await collectionActions.enableUrl( context, collection, From a1506ce1922764c5ccdc6a475019c4e207ed7cea Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 20 Feb 2023 11:14:57 +0530 Subject: [PATCH 15/22] Made 'Invite your friends' button functional --- lib/ui/new_shared_collections_gallery.dart | 6 +++++- lib/ui/sharing/manage_links_widget.dart | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ui/new_shared_collections_gallery.dart b/lib/ui/new_shared_collections_gallery.dart index 3682af433..28b0183e3 100644 --- a/lib/ui/new_shared_collections_gallery.dart +++ b/lib/ui/new_shared_collections_gallery.dart @@ -5,6 +5,7 @@ import "package:photos/ui/collection_action_sheet.dart"; import "package:photos/ui/components/button_widget.dart"; import "package:photos/ui/components/empty_state_item_widget.dart"; import "package:photos/ui/components/models/button_type.dart"; +import "package:photos/utils/share_util.dart"; class NewSharedCollectionsGallery extends StatelessWidget { const NewSharedCollectionsGallery({super.key}); @@ -97,10 +98,13 @@ class EmptyStateWidget extends StatelessWidget { }, ), const SizedBox(height: 6), - const ButtonWidget( + ButtonWidget( buttonType: ButtonType.trailingIconSecondary, labelText: "Invite your friends", icon: Icons.ios_share_outlined, + onTap: () async { + shareText("Check out https://ente.io"); + }, ), ], ), diff --git a/lib/ui/sharing/manage_links_widget.dart b/lib/ui/sharing/manage_links_widget.dart index eb0508ea5..ee24157e9 100644 --- a/lib/ui/sharing/manage_links_widget.dart +++ b/lib/ui/sharing/manage_links_widget.dart @@ -272,8 +272,10 @@ class _ManageSharedLinkWidgetState extends State { } Future _updateUrlSettings( - BuildContext context, Map prop, - {bool showProgressDialog = true}) async { + BuildContext context, + Map prop, { + bool showProgressDialog = true, + }) async { final dialog = showProgressDialog ? createProgressDialog(context, "Please wait...") : null; From d7fc4b9b01cfcc71c4590df24c387a57a54db68e Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 20 Feb 2023 12:35:41 +0530 Subject: [PATCH 16/22] Fixed error handling on 'Collect event photos' --- lib/services/collections_service.dart | 2 +- lib/ui/collection_action_sheet.dart | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index f35c29d63..a613a8064 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -646,7 +646,7 @@ class CollectionsService { } rethrow; } catch (e, s) { - _logger.severe("failed to rename collection", e, s); + _logger.severe("failed to update ShareUrl", e, s); rethrow; } } diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index aa2216bb3..af489ebcd 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -417,13 +417,14 @@ class _CollectionActionSheetState extends State { showToast(context, "This album already has a collaborative link"); return Future.value(false); } else { - CollectionsService.instance - .updateShareUrl(collection, {'enableCollect': true}).then( - (value) => true, - onError: (e, s) { - return false; - }, - ); + try { + await CollectionsService.instance + .updateShareUrl(collection, {'enableCollect': true}); + return true; + } catch (e) { + showGenericErrorDialog(context: context); + return false; + } } } final bool result = await collectionActions.enableUrl( From 35bcfbe201fb68541c84162c158da43afc3d2895 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 20 Feb 2023 14:17:10 +0530 Subject: [PATCH 17/22] Added link of componnt in figma --- lib/ui/components/empty_state_item_widget.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ui/components/empty_state_item_widget.dart b/lib/ui/components/empty_state_item_widget.dart index 8b0ad8e22..cbac9ecee 100644 --- a/lib/ui/components/empty_state_item_widget.dart +++ b/lib/ui/components/empty_state_item_widget.dart @@ -1,6 +1,8 @@ import "package:flutter/material.dart"; import "package:photos/theme/ente_theme.dart"; +///https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=11379%3A67490&t=VI5KulbW3HMM5MVz-4 + class EmptyStateItemWidget extends StatelessWidget { final String textContent; const EmptyStateItemWidget(this.textContent, {super.key}); From f45235d31112310dba844177c14181b368f23a0f Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 20 Feb 2023 14:52:05 +0530 Subject: [PATCH 18/22] Fixed 'create new album' on 'Share an album now' & 'Collect event photos' --- lib/ui/collection_action_sheet.dart | 60 ++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/lib/ui/collection_action_sheet.dart b/lib/ui/collection_action_sheet.dart index af489ebcd..9966736ce 100644 --- a/lib/ui/collection_action_sheet.dart +++ b/lib/ui/collection_action_sheet.dart @@ -3,10 +3,13 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import "package:fluttertoast/fluttertoast.dart"; import 'package:logging/logging.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:photos/core/configuration.dart'; +import "package:photos/core/event_bus.dart"; import 'package:photos/db/files_db.dart'; +import "package:photos/events/tab_changed_event.dart"; import 'package:photos/models/collection.dart'; import 'package:photos/models/collection_items.dart'; import 'package:photos/models/file.dart'; @@ -174,26 +177,9 @@ class _CollectionActionSheetState extends State { widget.showOptionToCreateNewAlbum) { return GestureDetector( onTap: () async { - final result = - await showTextInputDialog( - context, - title: "Album title", - submitButtonLabel: "OK", - hintText: "Enter album name", - onSubmit: _nameAlbum, - showOnlyLoadingState: true, - textCapitalization: - TextCapitalization.words, + await _createNewAlbumOnTap( + filesCount, ); - if (result is Exception) { - showGenericErrorDialog( - context: context, - ); - _logger.severe( - "Failed to name album", - result, - ); - } }, behavior: HitTestBehavior.opaque, child: @@ -265,6 +251,42 @@ class _CollectionActionSheetState extends State { ); } + Future _createNewAlbumOnTap(int filesCount) async { + if (filesCount > 0) { + final result = await showTextInputDialog( + context, + title: "Album title", + submitButtonLabel: "OK", + hintText: "Enter album name", + onSubmit: _nameAlbum, + showOnlyLoadingState: true, + textCapitalization: TextCapitalization.words, + ); + if (result is Exception) { + showGenericErrorDialog( + context: context, + ); + _logger.severe( + "Failed to name album", + result, + ); + } + } else { + Navigator.pop(context); + await showToast( + context, + "Long press to select photos and click + to create an album", + toastLength: Toast.LENGTH_LONG, + ); + Bus.instance.fire( + TabChangedEvent( + 0, + TabChangedEventSource.collectionsPage, + ), + ); + } + } + Future _nameAlbum(String albumName) async { if (albumName.isNotEmpty) { final collection = await _createAlbum(albumName); From 907c7b791c16646c07cdf1d74ca7e6ef8d6208cb Mon Sep 17 00:00:00 2001 From: ashilkn Date: Thu, 23 Feb 2023 18:49:15 +0530 Subject: [PATCH 19/22] 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 20/22] 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 21/22] 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 22/22] 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(