diff --git a/lib/ui/collection_page.dart b/lib/ui/collection_page.dart index 1249f5232..9265267b2 100644 --- a/lib/ui/collection_page.dart +++ b/lib/ui/collection_page.dart @@ -14,9 +14,13 @@ import 'gallery_app_bar_widget.dart'; class CollectionPage extends StatelessWidget { final CollectionWithThumbnail c; final String tagPrefix; + final GalleryAppBarType appBarType; final _selectedFiles = SelectedFiles(); - CollectionPage(this.c, {this.tagPrefix = "collection", Key key}) + CollectionPage(this.c, + {this.tagPrefix = "collection", + this.appBarType = GalleryAppBarType.owned_collection, + Key key}) : super(key: key); @override @@ -44,7 +48,7 @@ class CollectionPage extends StatelessWidget { Container( height: Platform.isAndroid ? 80 : 100, child: GalleryAppBarWidget( - GalleryAppBarType.collection, + appBarType, c.collection.name, _selectedFiles, collection: c.collection, diff --git a/lib/ui/gallery_app_bar_widget.dart b/lib/ui/gallery_app_bar_widget.dart index b1dd84bba..68a3639bd 100644 --- a/lib/ui/gallery_app_bar_widget.dart +++ b/lib/ui/gallery_app_bar_widget.dart @@ -20,9 +20,10 @@ import 'package:photos/utils/toast_util.dart'; enum GalleryAppBarType { homepage, local_folder, + // indicator for gallery view of collections shared with the user shared_collection, - collection, - search_results, + owned_collection, + search_results } class GalleryAppBarWidget extends StatefulWidget { @@ -105,7 +106,7 @@ class _GalleryAppBarWidgetState extends State { List actions = []; if (Configuration.instance.hasConfiguredAccount() && (widget.type == GalleryAppBarType.local_folder || - widget.type == GalleryAppBarType.collection)) { + widget.type == GalleryAppBarType.owned_collection)) { actions.add(IconButton( icon: Icon(Icons.person_add), onPressed: () { @@ -165,7 +166,9 @@ class _GalleryAppBarWidgetState extends State { List _getActions(BuildContext context) { List actions = []; - if (Configuration.instance.hasConfiguredAccount()) { + // skip add button for incoming collection till this feature is implemented + if (Configuration.instance.hasConfiguredAccount() && + widget.type != GalleryAppBarType.shared_collection) { actions.add(IconButton( icon: Icon(Platform.isAndroid ? Icons.add_outlined : CupertinoIcons.add), @@ -190,9 +193,7 @@ class _GalleryAppBarWidgetState extends State { _showDeleteSheet(context); }, )); - } else if (widget.type == GalleryAppBarType.collection || - (widget.type == GalleryAppBarType.shared_collection && - widget.collection.owner.id == Configuration.instance.getUserID())) { + } else if (widget.type == GalleryAppBarType.owned_collection) { if (widget.collection.type == CollectionType.folder) { actions.add(IconButton( icon: Icon(Platform.isAndroid diff --git a/lib/ui/share_collection_widget.dart b/lib/ui/share_collection_widget.dart index fe7dde223..e30bf0e7d 100644 --- a/lib/ui/share_collection_widget.dart +++ b/lib/ui/share_collection_widget.dart @@ -32,6 +32,7 @@ class _SharingDialogState extends State { bool _showEntryField = false; List _sharees; String _email; + final Logger _logger = Logger("SharingDialogState"); @override Widget build(BuildContext context) { @@ -208,14 +209,14 @@ class _SharingDialogState extends State { final dialog = createProgressDialog(context, "sharing..."); await dialog.show(); final collection = widget.collection; - if (collection.type == CollectionType.folder) { - final path = - CollectionsService.instance.decryptCollectionPath(collection); - if (!Configuration.instance.getPathsToBackUp().contains(path)) { - await Configuration.instance.addPathToFoldersToBeBackedUp(path); - } - } try { + if (collection.type == CollectionType.folder) { + final path = + CollectionsService.instance.decryptCollectionPath(collection); + if (!Configuration.instance.getPathsToBackUp().contains(path)) { + await Configuration.instance.addPathToFoldersToBeBackedUp(path); + } + } await CollectionsService.instance .share(widget.collection.id, email, publicKey); await dialog.hide(); @@ -260,6 +261,7 @@ class _SharingDialogState extends State { }, ); } else { + _logger.severe("failed to share collection", e); showGenericErrorDialog(context); } } diff --git a/lib/ui/shared_collections_gallery.dart b/lib/ui/shared_collections_gallery.dart index 11f75fc8b..14deb8e8e 100644 --- a/lib/ui/shared_collections_gallery.dart +++ b/lib/ui/shared_collections_gallery.dart @@ -14,6 +14,7 @@ import 'package:photos/models/collection_items.dart'; import 'package:photos/services/collections_service.dart'; import 'package:photos/ui/collection_page.dart'; import 'package:photos/ui/collections_gallery_widget.dart'; +import 'package:photos/ui/gallery_app_bar_widget.dart'; import 'package:photos/ui/loading_widget.dart'; import 'package:photos/ui/thumbnail_widget.dart'; import 'package:photos/utils/navigation_util.dart'; @@ -346,6 +347,7 @@ class OutgoingCollectionItem extends StatelessWidget { onTap: () { final page = CollectionPage( c, + appBarType: GalleryAppBarType.owned_collection, tagPrefix: "outgoing_collection", ); routeToPage(context, page); @@ -418,7 +420,11 @@ class IncomingCollectionItem extends StatelessWidget { ], ), onTap: () { - routeToPage(context, CollectionPage(c, tagPrefix: "shared_collection")); + routeToPage( + context, + CollectionPage(c, + appBarType: GalleryAppBarType.shared_collection, + tagPrefix: "shared_collection")); }, ); }