diff --git a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 54ab543b0..d30da3bf7 100644 --- a/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -4,12 +4,15 @@ import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:photos/core/configuration.dart'; import 'package:photos/core/event_bus.dart'; +import 'package:photos/db/files_db.dart'; +import 'package:photos/ente_theme_data.dart'; import 'package:photos/events/subscription_purchased_event.dart'; import 'package:photos/models/collection.dart'; import 'package:photos/models/gallery_type.dart'; import 'package:photos/models/magic_metadata.dart'; import 'package:photos/models/selected_files.dart'; import 'package:photos/services/collections_service.dart'; +import 'package:photos/ui/common/dialogs.dart'; import 'package:photos/ui/common/rename_dialog.dart'; import 'package:photos/ui/sharing/share_collection_widget.dart'; import 'package:photos/utils/dialog_util.dart'; @@ -128,8 +131,25 @@ class _GalleryAppBarWidgetState extends State { message: "Share", child: IconButton( icon: Icon(Icons.adaptive.share), - onPressed: () { - _showShareCollectionDialog(); + onPressed: () async { + if (await _collectionHasSharedFiles()) { + final choice = await showChoiceDialog( + context, + 'Share hidden items?', + "Looks like you're trying to share an album that has some hidden items.\n\nThese hidden items can be seen by the recipient.", + firstAction: "Cancel", + secondAction: "Share anyway", + secondActionColor: + Theme.of(context).colorScheme.defaultTextColor, + ); + if (choice != DialogUserChoice.secondChoice) { + return; + } else { + _showShareCollectionDialog(); + } + } else { + _showShareCollectionDialog(); + } }, ), ), @@ -225,4 +245,12 @@ class _GalleryAppBarWidgetState extends State { showGenericErrorDialog(context); } } + + Future _collectionHasSharedFiles() async { + final collectionIDsWithHiddenFiles = + await FilesDB.instance.getCollectionIDsOfHiddenFiles( + Configuration.instance.getUserID(), + ); + return collectionIDsWithHiddenFiles.contains(widget.collection.id); + } }