Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mobile): incorrect remove action from the album assets detail view #11671

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 67 additions & 65 deletions mobile/lib/widgets/asset_viewer/bottom_gallery_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,58 +61,6 @@ class BottomGalleryBar extends ConsumerWidget {
navStack.length > 2 &&
navStack.elementAt(navStack.length - 2).name == TrashRoute.name;
final isInAlbum = ref.watch(currentAlbumProvider)?.isRemote ?? false;
// !!!! itemsList and actionlist should always be in sync
final itemsList = [
BottomNavigationBarItem(
icon: Icon(
Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
),
label: 'control_bottom_app_bar_share'.tr(),
tooltip: 'control_bottom_app_bar_share'.tr(),
),
if (asset.isImage)
BottomNavigationBarItem(
icon: const Icon(Icons.tune_outlined),
label: 'control_bottom_app_bar_edit'.tr(),
tooltip: 'control_bottom_app_bar_edit'.tr(),
),
if (isOwner)
asset.isArchived
? BottomNavigationBarItem(
icon: const Icon(Icons.unarchive_rounded),
label: 'control_bottom_app_bar_unarchive'.tr(),
tooltip: 'control_bottom_app_bar_unarchive'.tr(),
)
: BottomNavigationBarItem(
icon: const Icon(Icons.archive_outlined),
label: 'control_bottom_app_bar_archive'.tr(),
tooltip: 'control_bottom_app_bar_archive'.tr(),
),
if (isOwner && stack.isNotEmpty)
BottomNavigationBarItem(
icon: const Icon(Icons.burst_mode_outlined),
label: 'control_bottom_app_bar_stack'.tr(),
tooltip: 'control_bottom_app_bar_stack'.tr(),
),
if (isOwner && !isInAlbum)
BottomNavigationBarItem(
icon: const Icon(Icons.delete_outline),
label: 'control_bottom_app_bar_delete'.tr(),
tooltip: 'control_bottom_app_bar_delete'.tr(),
),
if (!isOwner)
BottomNavigationBarItem(
icon: const Icon(Icons.download_outlined),
label: 'download'.tr(),
tooltip: 'download'.tr(),
),
if (isInAlbum)
BottomNavigationBarItem(
icon: const Icon(Icons.remove_circle_outline),
label: 'album_viewer_appbar_share_remove'.tr(),
tooltip: 'album_viewer_appbar_share_remove'.tr(),
),
];

void removeAssetFromStack() {
if (stackIndex > 0 && showStack) {
Expand Down Expand Up @@ -366,16 +314,71 @@ class BottomGalleryBar extends ConsumerWidget {
}
}

List<Function(int)> actionslist = [
(_) => shareAsset(),
if (asset.isImage) (_) => handleEdit(),
if (isOwner) (_) => handleArchive(),
if (isOwner && stack.isNotEmpty) (_) => showStackActionItems(),
if (isOwner) (_) => handleDelete(),
if (!isOwner) (_) => handleDownload(),
if (isInAlbum) (_) => handleRemoveFromAlbum(),
final List<Map<BottomNavigationBarItem, Function(int)>> albumActions = [
{
BottomNavigationBarItem(
icon: Icon(
Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
),
label: 'control_bottom_app_bar_share'.tr(),
tooltip: 'control_bottom_app_bar_share'.tr(),
): (_) => shareAsset(),
},
if (asset.isImage)
{
BottomNavigationBarItem(
icon: const Icon(Icons.tune_outlined),
label: 'control_bottom_app_bar_edit'.tr(),
tooltip: 'control_bottom_app_bar_edit'.tr(),
): (_) => handleEdit(),
},
if (isOwner)
{
asset.isArchived
? BottomNavigationBarItem(
icon: const Icon(Icons.unarchive_rounded),
label: 'control_bottom_app_bar_unarchive'.tr(),
tooltip: 'control_bottom_app_bar_unarchive'.tr(),
)
: BottomNavigationBarItem(
icon: const Icon(Icons.archive_outlined),
label: 'control_bottom_app_bar_archive'.tr(),
tooltip: 'control_bottom_app_bar_archive'.tr(),
): (_) => handleArchive(),
},
if (isOwner && stack.isNotEmpty)
{
BottomNavigationBarItem(
icon: const Icon(Icons.burst_mode_outlined),
label: 'control_bottom_app_bar_stack'.tr(),
tooltip: 'control_bottom_app_bar_stack'.tr(),
): (_) => showStackActionItems(),
},
if (isOwner && !isInAlbum)
{
BottomNavigationBarItem(
icon: const Icon(Icons.delete_outline),
label: 'control_bottom_app_bar_delete'.tr(),
tooltip: 'control_bottom_app_bar_delete'.tr(),
): (_) => handleDelete(),
},
if (!isOwner)
{
BottomNavigationBarItem(
icon: const Icon(Icons.download_outlined),
label: 'download'.tr(),
tooltip: 'download'.tr(),
): (_) => handleDownload(),
},
if (isInAlbum)
{
BottomNavigationBarItem(
icon: const Icon(Icons.remove_circle_outline),
label: 'album_viewer_appbar_share_remove'.tr(),
tooltip: 'album_viewer_appbar_share_remove'.tr(),
): (_) => handleRemoveFromAlbum(),
},
];

return IgnorePointer(
ignoring: !ref.watch(showControlsProvider),
child: AnimatedOpacity(
Expand Down Expand Up @@ -407,11 +410,10 @@ class BottomGalleryBar extends ConsumerWidget {
unselectedItemColor: Colors.white,
showSelectedLabels: true,
showUnselectedLabels: true,
items: itemsList,
items:
albumActions.map((e) => e.keys.first).toList(growable: false),
onTap: (index) {
if (index < actionslist.length) {
actionslist[index].call(index);
}
albumActions[index].values.first.call(index);
},
),
],
Expand Down
Loading