π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] remove photos from albums in info sheet
r4khuld7a88a723b69
diff --git a/mobile/apps/photos/lib/ui/actions/collection/collection_file_actions.dart b/mobile/apps/photos/lib/ui/actions/collection/collection_file_actions.dartindex cad94c9993..079bb184f5 100644--- a/mobile/apps/photos/lib/ui/actions/collection/collection_file_actions.dart+++ b/mobile/apps/photos/lib/ui/actions/collection/collection_file_actions.dart@@ -32,6 +32,7 @@ extension CollectionFileActions on CollectionActions {SelectedFiles selectedFiles,bool removingOthersFile, {bool isHidden = false,+ String? body,}) async {final actionResult = await showActionSheet(context: context,@@ -68,9 +69,11 @@ extension CollectionFileActions on CollectionActions {),],title: context.strings.removeFromAlbumTitle,- body: removingOthersFile- ? context.strings.removeShareItemsWarning- : context.strings.itemsWillBeRemovedFromAlbum,+ body:+ body ??+ (removingOthersFile+ ? context.strings.removeShareItemsWarning+ : context.strings.itemsWillBeRemovedFromAlbum),actionSheetType: ActionSheetType.defaultActionSheet,);if (actionResult?.action != null &&diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart b/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dartindex 99489ac455..48adcd23d3 100644--- a/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file_details/albums_item_widget.dart@@ -7,30 +7,38 @@ import "package:logging/logging.dart";import "package:photos/core/event_bus.dart";import "package:photos/db/files_db.dart";import "package:photos/events/pause_video_event.dart";+import 'package:photos/models/collection/collection.dart';import 'package:photos/models/collection/collection_items.dart';import 'package:photos/models/file/file.dart';import "package:photos/models/selected_files.dart";import "package:photos/services/collections_service.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/collections/collection_action_sheet.dart";import "package:photos/ui/viewer/gallery/collection_page.dart";-class AlbumsItemWidget extends StatelessWidget {+class AlbumsItemWidget extends StatefulWidget {final EnteFile file;final int currentUserID;const AlbumsItemWidget(this.file, this.currentUserID, {super.key});+ @override+ State<AlbumsItemWidget> createState() => _AlbumsItemWidgetState();+}++class _AlbumsItemWidgetState extends State<AlbumsItemWidget> {@overrideWidget build(BuildContext context) {final Future<List<Widget>> chipsFuture;- if (file.uploadedFileID != null) {+ if (widget.file.uploadedFileID != null) {chipsFuture = _collectionsListOfFile(context,- FilesDB.instance.getAllCollectionIDsOfFile(file.uploadedFileID!),- currentUserID,+ FilesDB.instance.getAllCollectionIDsOfFile(widget.file.uploadedFileID!),+ widget.currentUserID,);} else {chipsFuture = _deviceFoldersListOfFile(- Future.sync(() => {file.deviceFolder ?? ''}),+ Future.sync(() => {widget.file.deviceFolder ?? ''}),);}@@ -46,8 +54,10 @@ class AlbumsItemWidget extends StatelessWidget {builder: (context, snapshot) {final chips = snapshot.data ?? const <Widget>[];return Wrap(- spacing: Spacing.sm,- runSpacing: Spacing.sm,+ spacing: widget.file.uploadedFileID == null+ ? Spacing.sm+ : Spacing.xs,+ runSpacing: widget.file.uploadedFileID == null ? Spacing.sm : 0,children: chips,);},@@ -88,43 +98,48 @@ class AlbumsItemWidget extends StatelessWidget {for (var collectionID in collectionIDs) {final c = CollectionsService.instance.getCollectionByID(collectionID)!;chips.add(- FilterChipComponent(+ _AlbumChip(label: c.isHidden() ? context.strings.hidden : c.displayName,- onChanged: (_) {- if (c.isHidden()) {- return;- }+ onTap: () {+ if (c.isHidden()) return;Bus.instance.fire(PauseVideoEvent());routeToPage(context,CollectionPage(CollectionWithThumbnail(c, null),- fileToJumpTo: file,+ fileToJumpTo: widget.file,),);},+ onRemove: _canRemoveFrom(c)+ ? () => _removeFromCollection(context, c)+ : null,),);}chips.add(- IconButtonComponent(- size: FilterChipComponent.minHeight,- icon: HugeIcon(- icon: HugeIcons.strokeRoundedPlusSign,- size: IconSizes.small,- color: colors.textBase,+ Padding(+ padding: const EdgeInsetsDirectional.only(top: Spacing.sm),+ child: IconButtonComponent(+ size: FilterChipComponent.minHeight,+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedPlusSign,+ size: IconSizes.small,+ color: colors.textBase,+ ),+ variant: IconButtonComponentVariant.circular,+ shouldSurfaceExecutionStates: false,+ onTap: () async {+ final selectedFiles = SelectedFiles();+ selectedFiles.files.add(widget.file);+ await showCollectionActionSheet(+ context,+ selectedFiles: selectedFiles,+ actionType: CollectionActionType.addFiles,+ );+ if (mounted) setState(() {});+ },),- variant: IconButtonComponentVariant.circular,- shouldSurfaceExecutionStates: false,- onTap: () {- final selectedFiles = SelectedFiles();- selectedFiles.files.add(file);- showCollectionActionSheet(- context,- selectedFiles: selectedFiles,- actionType: CollectionActionType.addFiles,- );- },),);return chips;@@ -135,4 +150,151 @@ class AlbumsItemWidget extends StatelessWidget {return [];}}++ bool _canRemoveFrom(Collection collection) {+ if (collection.type == CollectionType.uncategorized ||+ collection.isQuickLinkCollection()) {+ return false;+ }+ if (collection.type == CollectionType.favorites) {+ return widget.file.ownerID == widget.currentUserID;+ }+ return widget.file.ownerID == widget.currentUserID ||+ CollectionsService.instance.canRemoveFilesFromAllParticipants(+ collection,+ );+ }++ Future<void> _removeFromCollection(+ BuildContext context,+ Collection collection,+ ) async {+ final selectedFiles = SelectedFiles();+ selectedFiles.files.add(widget.file);+ final collectionActions = CollectionActions(CollectionsService.instance);+ if (collection.type == CollectionType.favorites) {+ await collectionActions.updateFavorites(context, [widget.file], false);+ } else {+ final removingOthersFile =+ widget.file.ownerID != widget.currentUserID &&+ CollectionsService.instance.canRemoveFilesFromAllParticipants(+ collection,+ );+ await collectionActions.showRemoveFromCollectionSheetV2(+ context,+ collection,+ selectedFiles,+ removingOthersFile,+ isHidden: collection.isHidden(),+ body: removingOthersFile+ ? null+ : context.strings.itemWillBeRemovedFromThisFolder,+ );+ }+ if (mounted) setState(() {});+ }+}++class _AlbumChip extends StatelessWidget {+ const _AlbumChip({required this.label, required this.onTap, this.onRemove});++ final String label;+ final VoidCallback onTap;+ final Future<void> Function()? onRemove;++ @override+ Widget build(BuildContext context) {+ final chip = FilterChipComponent(label: label, onChanged: (_) => onTap());+ if (onRemove == null) {+ return Padding(+ padding: const EdgeInsetsDirectional.only(+ top: Spacing.sm,+ end: Spacing.sm,+ ),+ child: chip,+ );+ }++ return Stack(+ children: [+ Padding(+ padding: const EdgeInsetsDirectional.only(+ top: Spacing.sm,+ end: Spacing.sm,+ ),+ child: chip,+ ),+ PositionedDirectional(+ top: Spacing.xs / 2,+ end: Spacing.xs / 2,+ child: _RemoveAlbumButton(onTap: onRemove!),+ ),+ ],+ );+ }+}++class _RemoveAlbumButton extends StatefulWidget {+ const _RemoveAlbumButton({required this.onTap});++ final Future<void> Function() onTap;++ @override+ State<_RemoveAlbumButton> createState() => _RemoveAlbumButtonState();+}++class _RemoveAlbumButtonState extends State<_RemoveAlbumButton> {+ bool _isExecuting = false;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return Tooltip(+ message: context.strings.removeFromAlbum,+ child: Semantics(+ button: true,+ enabled: !_isExecuting,+ label: context.strings.removeFromAlbum,+ child: MouseRegion(+ cursor: _isExecuting+ ? SystemMouseCursors.basic+ : SystemMouseCursors.click,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: _isExecuting ? () {} : _handleTap,+ child: SizedBox.square(+ dimension: 24,+ child: Center(+ child: SizedBox.square(+ dimension: 16,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: colors.fillBase,+ shape: BoxShape.circle,+ ),+ child: Center(+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedCancel01,+ size: 10,+ color: colors.textReverse,+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ );+ }++ Future<void> _handleTap() async {+ setState(() => _isExecuting = true);+ try {+ await widget.onTap();+ } finally {+ if (mounted) setState(() => _isExecuting = false);+ }+ }}diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex b0ad4aabb0..60151f345b 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -2154,6 +2154,7 @@"count": {}}},+ "itemWillBeRemovedFromThisFolder": "Item will be removed from this folder","items": "{count} items","@items": {"description": "Number of items in a collection",