[mob][photos] feat: enable album selection actions for incoming collections
This commit is contained in:
@@ -75,7 +75,8 @@ class _CollectionListPageState extends State<CollectionListPage> {
|
||||
(widget.tag.isEmpty && _searchQuery.isEmpty ? 1 : 0);
|
||||
final bool enableSelectionMode =
|
||||
widget.sectionType == UISectionType.homeCollections ||
|
||||
widget.sectionType == UISectionType.outgoingCollections;
|
||||
widget.sectionType == UISectionType.outgoingCollections ||
|
||||
widget.sectionType == UISectionType.incomingCollections;
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
@@ -121,6 +122,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
|
||||
),
|
||||
AlbumSelectionOverlayBar(
|
||||
_selectedAlbum,
|
||||
widget.sectionType,
|
||||
collections!,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,6 +2,7 @@ import "package:flutter/material.dart";
|
||||
import "package:photos/core/constants.dart";
|
||||
import "package:photos/models/selected_albums.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
import "package:photos/ui/collections/collection_list_page.dart";
|
||||
import "package:photos/ui/components/bottom_action_bar/album_action_bar_widget.dart";
|
||||
import "package:photos/ui/components/divider_widget.dart";
|
||||
import "package:photos/ui/viewer/actions/album_selection_action_widget.dart";
|
||||
@@ -10,9 +11,11 @@ class AlbumBottomActionBarWidget extends StatelessWidget {
|
||||
final SelectedAlbums selectedAlbums;
|
||||
final VoidCallback? onCancel;
|
||||
final Color? backgroundColor;
|
||||
final UISectionType sectionType;
|
||||
|
||||
const AlbumBottomActionBarWidget(
|
||||
this.selectedAlbums, {
|
||||
this.selectedAlbums,
|
||||
this.sectionType, {
|
||||
super.key,
|
||||
this.backgroundColor,
|
||||
this.onCancel,
|
||||
@@ -43,7 +46,7 @@ class AlbumBottomActionBarWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
AlbumSelectionActionWidget(selectedAlbums),
|
||||
AlbumSelectionActionWidget(selectedAlbums, sectionType),
|
||||
const DividerWidget(dividerType: DividerType.bottomBar),
|
||||
AlbumActionBarWidget(
|
||||
selectedAlbums: selectedAlbums,
|
||||
|
||||
@@ -7,14 +7,21 @@ import "package:photos/models/metadata/common_keys.dart";
|
||||
import "package:photos/models/selected_albums.dart";
|
||||
import "package:photos/services/collections_service.dart";
|
||||
import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
|
||||
import "package:photos/ui/collections/collection_list_page.dart";
|
||||
import "package:photos/ui/components/action_sheet_widget.dart";
|
||||
import "package:photos/ui/components/bottom_action_bar/selection_action_button_widget.dart";
|
||||
import "package:photos/ui/components/buttons/button_widget.dart";
|
||||
import "package:photos/ui/components/models/button_type.dart";
|
||||
import "package:photos/utils/dialog_util.dart";
|
||||
import "package:photos/utils/magic_util.dart";
|
||||
|
||||
class AlbumSelectionActionWidget extends StatefulWidget {
|
||||
final SelectedAlbums selectedAlbums;
|
||||
final UISectionType sectionType;
|
||||
|
||||
const AlbumSelectionActionWidget(
|
||||
this.selectedAlbums, {
|
||||
this.selectedAlbums,
|
||||
this.sectionType, {
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -40,34 +47,57 @@ class _AlbumSelectionActionWidgetState
|
||||
return const SizedBox();
|
||||
}
|
||||
final List<SelectionActionButton> items = [];
|
||||
|
||||
if (widget.sectionType == UISectionType.homeCollections ||
|
||||
widget.sectionType == UISectionType.outgoingCollections) {
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).share,
|
||||
icon: Icons.adaptive.share,
|
||||
onTap: _shareCollection,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: "Pin",
|
||||
icon: Icons.push_pin_rounded,
|
||||
onTap: _onPinClick,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).delete,
|
||||
icon: Icons.delete_outline,
|
||||
onTap: _trashCollection,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).hide,
|
||||
icon: Icons.visibility_off_outlined,
|
||||
onTap: _onHideClick,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).share,
|
||||
icon: Icons.adaptive.share,
|
||||
onTap: _shareCollection,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: "Pin",
|
||||
icon: Icons.push_pin_rounded,
|
||||
onTap: _onPinClick,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).delete,
|
||||
icon: Icons.delete_outline,
|
||||
onTap: _trashCollection,
|
||||
),
|
||||
);
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).hide,
|
||||
icon: Icons.visibility_off_outlined,
|
||||
onTap: _onHideClick,
|
||||
labelText: S.of(context).archive,
|
||||
icon: Icons.archive_outlined,
|
||||
onTap: _archiveClick,
|
||||
),
|
||||
);
|
||||
|
||||
if (widget.sectionType == UISectionType.incomingCollections) {
|
||||
items.add(
|
||||
SelectionActionButton(
|
||||
labelText: S.of(context).leaveAlbum,
|
||||
icon: Icons.logout,
|
||||
onTap: _leaveAlbum,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final scrollController = ScrollController();
|
||||
|
||||
return MediaQuery(
|
||||
@@ -176,4 +206,88 @@ class _AlbumSelectionActionWidgetState
|
||||
}
|
||||
widget.selectedAlbums.clearAll();
|
||||
}
|
||||
|
||||
Future<void> _archiveClick() async {
|
||||
for (final collection in widget.selectedAlbums.albums) {
|
||||
if (collection.type == CollectionType.favorites) {
|
||||
continue;
|
||||
}
|
||||
if (widget.sectionType == UISectionType.incomingCollections) {
|
||||
final hasShareeArchived = collection.hasShareeArchived();
|
||||
final int prevVisiblity =
|
||||
hasShareeArchived ? archiveVisibility : visibleVisibility;
|
||||
final int newVisiblity =
|
||||
hasShareeArchived ? visibleVisibility : archiveVisibility;
|
||||
|
||||
await changeCollectionVisibility(
|
||||
context,
|
||||
collection: collection,
|
||||
newVisibility: newVisiblity,
|
||||
prevVisibility: prevVisiblity,
|
||||
isOwner: false,
|
||||
);
|
||||
} else {
|
||||
final isArchived = collection.isArchived();
|
||||
final int prevVisiblity =
|
||||
isArchived ? archiveVisibility : visibleVisibility;
|
||||
final int newVisiblity =
|
||||
isArchived ? visibleVisibility : archiveVisibility;
|
||||
|
||||
await changeCollectionVisibility(
|
||||
context,
|
||||
collection: collection,
|
||||
newVisibility: newVisiblity,
|
||||
prevVisibility: prevVisiblity,
|
||||
);
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
widget.selectedAlbums.clearAll();
|
||||
}
|
||||
|
||||
Future<void> _leaveAlbum() async {
|
||||
final actionResult = await showActionSheet(
|
||||
context: context,
|
||||
buttons: [
|
||||
ButtonWidget(
|
||||
buttonType: ButtonType.critical,
|
||||
isInAlert: true,
|
||||
shouldStickToDarkTheme: true,
|
||||
buttonAction: ButtonAction.first,
|
||||
shouldSurfaceExecutionStates: true,
|
||||
labelText: S.of(context).leaveAlbum,
|
||||
onTap: () async {
|
||||
for (final collection in widget.selectedAlbums.albums) {
|
||||
if (collection.type == CollectionType.favorites) {
|
||||
continue;
|
||||
}
|
||||
await CollectionsService.instance.leaveAlbum(collection);
|
||||
}
|
||||
widget.selectedAlbums.clearAll();
|
||||
},
|
||||
),
|
||||
ButtonWidget(
|
||||
buttonType: ButtonType.secondary,
|
||||
buttonAction: ButtonAction.cancel,
|
||||
isInAlert: true,
|
||||
shouldStickToDarkTheme: true,
|
||||
labelText: S.of(context).cancel,
|
||||
),
|
||||
],
|
||||
title: S.of(context).leaveSharedAlbum,
|
||||
body: S.of(context).photosAddedByYouWillBeRemovedFromTheAlbum,
|
||||
);
|
||||
if (actionResult?.action != null && mounted) {
|
||||
if (actionResult!.action == ButtonAction.error) {
|
||||
await showGenericErrorDialog(
|
||||
context: context,
|
||||
error: actionResult.exception,
|
||||
);
|
||||
} else if (actionResult.action == ButtonAction.first) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import "package:photos/models/collection/collection.dart";
|
||||
import "package:photos/models/selected_albums.dart";
|
||||
import "package:photos/theme/effects.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
import "package:photos/ui/collections/collection_list_page.dart";
|
||||
import "package:photos/ui/components/bottom_action_bar/album_bottom_action_bar_widget.dart";
|
||||
|
||||
class AlbumSelectionOverlayBar extends StatefulWidget {
|
||||
@@ -11,9 +12,11 @@ class AlbumSelectionOverlayBar extends StatefulWidget {
|
||||
final SelectedAlbums selectedAlbums;
|
||||
final List<Collection> collections;
|
||||
final Color? backgroundColor;
|
||||
final UISectionType sectionType;
|
||||
|
||||
const AlbumSelectionOverlayBar(
|
||||
this.selectedAlbums,
|
||||
this.sectionType,
|
||||
this.collections, {
|
||||
super.key,
|
||||
this.onClose,
|
||||
@@ -70,6 +73,7 @@ class _AlbumSelectionOverlayBarState extends State<AlbumSelectionOverlayBar> {
|
||||
decoration: BoxDecoration(boxShadow: shadowFloatFaintLight),
|
||||
child: AlbumBottomActionBarWidget(
|
||||
widget.selectedAlbums,
|
||||
widget.sectionType,
|
||||
onCancel: () {
|
||||
if (widget.selectedAlbums.albums.isNotEmpty) {
|
||||
widget.selectedAlbums.clearAll();
|
||||
|
||||
Reference in New Issue
Block a user