mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 01:11:07 +03:00
feat(mobile): move buttons in the bottom sheet to the kebabu menu (#24175)
* refactor: remove bottom sheet buttons * feat: add iconOnly and menuItem parameters to action buttons * feat: enhance action button context and kebab menu integration * feat: use ActionButtonContext * fix: add missing options in some cases --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -9,8 +9,10 @@ import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
|||||||
|
|
||||||
class AdvancedInfoActionButton extends ConsumerWidget {
|
class AdvancedInfoActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const AdvancedInfoActionButton({super.key, required this.source});
|
const AdvancedInfoActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -26,6 +28,8 @@ class AdvancedInfoActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 115.0,
|
maxWidth: 115.0,
|
||||||
iconData: Icons.help_outline_rounded,
|
iconData: Icons.help_outline_rounded,
|
||||||
label: "troubleshoot".t(context: context),
|
label: "troubleshoot".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ Future<void> performArchiveAction(BuildContext context, WidgetRef ref, {required
|
|||||||
|
|
||||||
class ArchiveActionButton extends ConsumerWidget {
|
class ArchiveActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ArchiveActionButton({super.key, required this.source});
|
const ArchiveActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performArchiveAction(context, ref, source: source);
|
await performArchiveAction(context, ref, source: source);
|
||||||
@@ -47,6 +49,8 @@ class ArchiveActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.archive_outlined,
|
iconData: Icons.archive_outlined,
|
||||||
label: "to_archive".t(context: context),
|
label: "to_archive".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,15 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
class DeleteActionButton extends ConsumerWidget {
|
class DeleteActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
final bool showConfirmation;
|
final bool showConfirmation;
|
||||||
const DeleteActionButton({super.key, required this.source, this.showConfirmation = false});
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
const DeleteActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.source,
|
||||||
|
this.showConfirmation = false,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -74,6 +82,8 @@ class DeleteActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 110.0,
|
maxWidth: 110.0,
|
||||||
iconData: Icons.delete_sweep_outlined,
|
iconData: Icons.delete_sweep_outlined,
|
||||||
label: "delete".t(context: context),
|
label: "delete".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// - Prompt to delete the asset locally
|
/// - Prompt to delete the asset locally
|
||||||
class DeleteLocalActionButton extends ConsumerWidget {
|
class DeleteLocalActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const DeleteLocalActionButton({super.key, required this.source});
|
const DeleteLocalActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -55,6 +57,8 @@ class DeleteLocalActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 95.0,
|
maxWidth: 95.0,
|
||||||
iconData: Icons.no_cell_outlined,
|
iconData: Icons.no_cell_outlined,
|
||||||
label: "control_bottom_app_bar_delete_from_local".t(context: context),
|
label: "control_bottom_app_bar_delete_from_local".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// - Prompt to delete the asset locally
|
/// - Prompt to delete the asset locally
|
||||||
class DeletePermanentActionButton extends ConsumerWidget {
|
class DeletePermanentActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const DeletePermanentActionButton({super.key, required this.source});
|
const DeletePermanentActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -51,6 +53,8 @@ class DeletePermanentActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 110.0,
|
maxWidth: 110.0,
|
||||||
iconData: Icons.delete_forever,
|
iconData: Icons.delete_forever,
|
||||||
label: "delete_permanently".t(context: context),
|
label: "delete_permanently".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ Future<void> performMoveToLockFolderAction(BuildContext context, WidgetRef ref,
|
|||||||
|
|
||||||
class MoveToLockFolderActionButton extends ConsumerWidget {
|
class MoveToLockFolderActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const MoveToLockFolderActionButton({super.key, required this.source});
|
const MoveToLockFolderActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performMoveToLockFolderAction(context, ref, source: source);
|
await performMoveToLockFolderAction(context, ref, source: source);
|
||||||
@@ -51,6 +53,8 @@ class MoveToLockFolderActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 115.0,
|
maxWidth: 115.0,
|
||||||
iconData: Icons.lock_outline_rounded,
|
iconData: Icons.lock_outline_rounded,
|
||||||
label: "move_to_locked_folder".t(context: context),
|
label: "move_to_locked_folder".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
||||||
@@ -11,8 +13,16 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
class RemoveFromAlbumActionButton extends ConsumerWidget {
|
class RemoveFromAlbumActionButton extends ConsumerWidget {
|
||||||
final String albumId;
|
final String albumId;
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const RemoveFromAlbumActionButton({super.key, required this.albumId, required this.source});
|
const RemoveFromAlbumActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.albumId,
|
||||||
|
required this.source,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -22,6 +32,10 @@ class RemoveFromAlbumActionButton extends ConsumerWidget {
|
|||||||
final result = await ref.read(actionProvider.notifier).removeFromAlbum(source, albumId);
|
final result = await ref.read(actionProvider.notifier).removeFromAlbum(source, albumId);
|
||||||
ref.read(multiSelectProvider.notifier).reset();
|
ref.read(multiSelectProvider.notifier).reset();
|
||||||
|
|
||||||
|
if (source == ActionSource.viewer) {
|
||||||
|
EventStream.shared.emit(const ViewerReloadAssetEvent());
|
||||||
|
}
|
||||||
|
|
||||||
final successMessage = 'remove_from_album_action_prompt'.t(
|
final successMessage = 'remove_from_album_action_prompt'.t(
|
||||||
context: context,
|
context: context,
|
||||||
args: {'count': result.count.toString()},
|
args: {'count': result.count.toString()},
|
||||||
@@ -42,6 +56,8 @@ class RemoveFromAlbumActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.remove_circle_outline,
|
iconData: Icons.remove_circle_outline,
|
||||||
label: "remove_from_album".t(context: context),
|
label: "remove_from_album".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
maxWidth: 100,
|
maxWidth: 100,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,8 +10,15 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const RemoveFromLockFolderActionButton({super.key, required this.source});
|
const RemoveFromLockFolderActionButton({
|
||||||
|
super.key,
|
||||||
|
required this.source,
|
||||||
|
this.iconOnly = false,
|
||||||
|
this.menuItem = false,
|
||||||
|
});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -42,6 +49,8 @@ class RemoveFromLockFolderActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 100.0,
|
maxWidth: 100.0,
|
||||||
iconData: Icons.lock_open_rounded,
|
iconData: Icons.lock_open_rounded,
|
||||||
label: "remove_from_locked_folder".t(context: context),
|
label: "remove_from_locked_folder".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ class _SharePreparingDialog extends StatelessWidget {
|
|||||||
|
|
||||||
class ShareActionButton extends ConsumerWidget {
|
class ShareActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ShareActionButton({super.key, required this.source});
|
const ShareActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -74,6 +76,8 @@ class ShareActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
|
iconData: Platform.isAndroid ? Icons.share_rounded : Icons.ios_share_rounded,
|
||||||
label: 'share'.t(context: context),
|
label: 'share'.t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
|||||||
|
|
||||||
class ShareLinkActionButton extends ConsumerWidget {
|
class ShareLinkActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const ShareLinkActionButton({super.key, required this.source});
|
const ShareLinkActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
_onTap(BuildContext context, WidgetRef ref) async {
|
_onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -23,6 +25,8 @@ class ShareLinkActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.link_rounded,
|
iconData: Icons.link_rounded,
|
||||||
label: "share_link".t(context: context),
|
label: "share_link".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import 'package:immich_mobile/routing/router.dart';
|
|||||||
|
|
||||||
class SimilarPhotosActionButton extends ConsumerWidget {
|
class SimilarPhotosActionButton extends ConsumerWidget {
|
||||||
final String assetId;
|
final String assetId;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const SimilarPhotosActionButton({super.key, required this.assetId});
|
const SimilarPhotosActionButton({super.key, required this.assetId, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -44,6 +46,8 @@ class SimilarPhotosActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.compare,
|
iconData: Icons.compare,
|
||||||
label: "view_similar_photos".t(context: context),
|
label: "view_similar_photos".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
maxWidth: 100,
|
maxWidth: 100,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
/// which will be permanently deleted after the number of days configure by the admin
|
/// which will be permanently deleted after the number of days configure by the admin
|
||||||
class TrashActionButton extends ConsumerWidget {
|
class TrashActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const TrashActionButton({super.key, required this.source});
|
const TrashActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -48,6 +50,8 @@ class TrashActionButton extends ConsumerWidget {
|
|||||||
maxWidth: 85.0,
|
maxWidth: 85.0,
|
||||||
iconData: Icons.delete_outline_rounded,
|
iconData: Icons.delete_outline_rounded,
|
||||||
label: "control_bottom_app_bar_trash_from_immich".t(context: context),
|
label: "control_bottom_app_bar_trash_from_immich".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ Future<void> performUnArchiveAction(BuildContext context, WidgetRef ref, {requir
|
|||||||
|
|
||||||
class UnArchiveActionButton extends ConsumerWidget {
|
class UnArchiveActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UnArchiveActionButton({super.key, required this.source});
|
const UnArchiveActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
Future<void> _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
await performUnArchiveAction(context, ref, source: source);
|
await performUnArchiveAction(context, ref, source: source);
|
||||||
@@ -49,6 +51,8 @@ class UnArchiveActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.unarchive_outlined,
|
iconData: Icons.unarchive_outlined,
|
||||||
label: "unarchive".t(context: context),
|
label: "unarchive".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class UnStackActionButton extends ConsumerWidget {
|
class UnStackActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UnStackActionButton({super.key, required this.source});
|
const UnStackActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -38,6 +40,8 @@ class UnStackActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.layers_clear_outlined,
|
iconData: Icons.layers_clear_outlined,
|
||||||
label: "unstack".t(context: context),
|
label: "unstack".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
|||||||
|
|
||||||
class UploadActionButton extends ConsumerWidget {
|
class UploadActionButton extends ConsumerWidget {
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool iconOnly;
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
const UploadActionButton({super.key, required this.source});
|
const UploadActionButton({super.key, required this.source, this.iconOnly = false, this.menuItem = false});
|
||||||
|
|
||||||
void _onTap(BuildContext context, WidgetRef ref) async {
|
void _onTap(BuildContext context, WidgetRef ref) async {
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
@@ -39,6 +41,8 @@ class UploadActionButton extends ConsumerWidget {
|
|||||||
return BaseActionButton(
|
return BaseActionButton(
|
||||||
iconData: Icons.backup_outlined,
|
iconData: Icons.backup_outlined,
|
||||||
label: "upload".t(context: context),
|
label: "upload".t(context: context),
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
onPressed: () => _onTap(context, ref),
|
onPressed: () => _onTap(context, ref),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
const ShareActionButton(source: ActionSource.viewer),
|
const ShareActionButton(source: ActionSource.viewer),
|
||||||
|
|
||||||
|
if (!isInLockedView) ...[
|
||||||
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
||||||
if (asset.type == AssetType.image) const EditImageActionButton(),
|
if (asset.type == AssetType.image) const EditImageActionButton(),
|
||||||
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
||||||
@@ -51,6 +53,7 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
||||||
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
||||||
],
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
@@ -76,7 +79,7 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (asset.isVideo) const VideoControls(),
|
if (asset.isVideo) const VideoControls(),
|
||||||
if (!isInLockedView && !isReadonlyModeEnabled)
|
if (!isReadonlyModeEnabled)
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/setting.model.dart';
|
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
@@ -21,14 +20,9 @@ import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_shee
|
|||||||
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/action.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/routes.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/server_info.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/repositories/asset_media.repository.dart';
|
import 'package:immich_mobile/repositories/asset_media.repository.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
|
||||||
import 'package:immich_mobile/utils/bytes_units.dart';
|
import 'package:immich_mobile/utils/bytes_units.dart';
|
||||||
import 'package:immich_mobile/utils/timezone.dart';
|
import 'package:immich_mobile/utils/timezone.dart';
|
||||||
import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
import 'package:immich_mobile/widgets/common/immich_toast.dart';
|
||||||
@@ -48,29 +42,8 @@ class AssetDetailBottomSheet extends ConsumerWidget {
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
|
||||||
final isOwner = asset is RemoteAsset && asset.ownerId == ref.watch(currentUserProvider)?.id;
|
|
||||||
final isInLockedView = ref.watch(inLockedViewProvider);
|
|
||||||
final currentAlbum = ref.watch(currentRemoteAlbumProvider);
|
|
||||||
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
|
||||||
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
|
||||||
|
|
||||||
final buttonContext = ActionButtonContext(
|
|
||||||
asset: asset,
|
|
||||||
isOwner: isOwner,
|
|
||||||
isArchived: isArchived,
|
|
||||||
isTrashEnabled: isTrashEnable,
|
|
||||||
isInLockedView: isInLockedView,
|
|
||||||
isStacked: asset is RemoteAsset && asset.stackId != null,
|
|
||||||
currentAlbum: currentAlbum,
|
|
||||||
advancedTroubleshooting: advancedTroubleshooting,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
);
|
|
||||||
|
|
||||||
final actions = ActionButtonBuilder.build(buttonContext);
|
|
||||||
|
|
||||||
return BaseBottomSheet(
|
return BaseBottomSheet(
|
||||||
actions: actions,
|
actions: [],
|
||||||
slivers: const [_AssetDetailBottomSheet()],
|
slivers: const [_AssetDetailBottomSheet()],
|
||||||
controller: controller,
|
controller: controller,
|
||||||
initialChildSize: initialChildSize,
|
initialChildSize: initialChildSize,
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/setting.model.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/providers/cast.provider.dart';
|
import 'package:immich_mobile/providers/cast.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/server_info.provider.dart';
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
import 'package:immich_mobile/utils/action_button.utils.dart';
|
||||||
|
|
||||||
@@ -24,16 +30,28 @@ class ViewerKebabMenu extends ConsumerWidget {
|
|||||||
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
||||||
final isCasting = ref.watch(castProvider.select((c) => c.isCasting));
|
final isCasting = ref.watch(castProvider.select((c) => c.isCasting));
|
||||||
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
||||||
|
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
||||||
|
final isInLockedView = ref.watch(inLockedViewProvider);
|
||||||
|
final currentAlbum = ref.watch(currentRemoteAlbumProvider);
|
||||||
|
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
||||||
|
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
||||||
|
|
||||||
final kebabContext = ViewerKebabMenuButtonContext(
|
final actionContext = ActionButtonContext(
|
||||||
asset: asset,
|
asset: asset,
|
||||||
isOwner: isOwner,
|
isOwner: isOwner,
|
||||||
|
isArchived: isArchived,
|
||||||
|
isTrashEnabled: isTrashEnable,
|
||||||
|
isStacked: asset is RemoteAsset && asset.stackId != null,
|
||||||
|
isInLockedView: isInLockedView,
|
||||||
|
currentAlbum: currentAlbum,
|
||||||
|
advancedTroubleshooting: advancedTroubleshooting,
|
||||||
|
source: ActionSource.viewer,
|
||||||
isCasting: isCasting,
|
isCasting: isCasting,
|
||||||
timelineOrigin: timelineOrigin,
|
timelineOrigin: timelineOrigin,
|
||||||
originalTheme: originalTheme,
|
originalTheme: originalTheme,
|
||||||
);
|
);
|
||||||
|
|
||||||
final menuChildren = ViewerKebabMenuButtonBuilder.build(kebabContext, context, ref);
|
final menuChildren = ActionButtonBuilder.buildViewerKebabMenu(actionContext, context, ref);
|
||||||
|
|
||||||
return MenuAnchor(
|
return MenuAnchor(
|
||||||
consumeOutsideTap: true,
|
consumeOutsideTap: true,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|||||||
import 'package:immich_mobile/domain/models/events.model.dart';
|
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||||
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
||||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/advanced_info_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/advanced_info_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
@@ -40,6 +39,9 @@ class ActionButtonContext {
|
|||||||
final RemoteAlbum? currentAlbum;
|
final RemoteAlbum? currentAlbum;
|
||||||
final bool advancedTroubleshooting;
|
final bool advancedTroubleshooting;
|
||||||
final ActionSource source;
|
final ActionSource source;
|
||||||
|
final bool isCasting;
|
||||||
|
final TimelineOrigin timelineOrigin;
|
||||||
|
final ThemeData? originalTheme;
|
||||||
|
|
||||||
const ActionButtonContext({
|
const ActionButtonContext({
|
||||||
required this.asset,
|
required this.asset,
|
||||||
@@ -51,27 +53,33 @@ class ActionButtonContext {
|
|||||||
required this.currentAlbum,
|
required this.currentAlbum,
|
||||||
required this.advancedTroubleshooting,
|
required this.advancedTroubleshooting,
|
||||||
required this.source,
|
required this.source,
|
||||||
|
this.isCasting = false,
|
||||||
|
this.timelineOrigin = TimelineOrigin.main,
|
||||||
|
this.originalTheme,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActionButtonType {
|
enum ActionButtonType {
|
||||||
advancedInfo,
|
openInfo,
|
||||||
|
likeActivity,
|
||||||
share,
|
share,
|
||||||
shareLink,
|
shareLink,
|
||||||
|
cast,
|
||||||
similarPhotos,
|
similarPhotos,
|
||||||
|
viewInTimeline,
|
||||||
|
download,
|
||||||
|
upload,
|
||||||
|
unstack,
|
||||||
archive,
|
archive,
|
||||||
unarchive,
|
unarchive,
|
||||||
download,
|
|
||||||
trash,
|
|
||||||
deletePermanent,
|
|
||||||
delete,
|
|
||||||
moveToLockFolder,
|
moveToLockFolder,
|
||||||
removeFromLockFolder,
|
removeFromLockFolder,
|
||||||
deleteLocal,
|
|
||||||
upload,
|
|
||||||
removeFromAlbum,
|
removeFromAlbum,
|
||||||
unstack,
|
trash,
|
||||||
likeActivity;
|
deleteLocal,
|
||||||
|
deletePermanent,
|
||||||
|
delete,
|
||||||
|
advancedInfo;
|
||||||
|
|
||||||
bool shouldShow(ActionButtonContext context) {
|
bool shouldShow(ActionButtonContext context) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
@@ -138,132 +146,163 @@ enum ActionButtonType {
|
|||||||
ActionButtonType.similarPhotos =>
|
ActionButtonType.similarPhotos =>
|
||||||
!context.isInLockedView && //
|
!context.isInLockedView && //
|
||||||
context.asset is RemoteAsset,
|
context.asset is RemoteAsset,
|
||||||
};
|
ActionButtonType.openInfo => true,
|
||||||
}
|
ActionButtonType.viewInTimeline =>
|
||||||
|
|
||||||
Widget buildButton(ActionButtonContext context) {
|
|
||||||
return switch (this) {
|
|
||||||
ActionButtonType.advancedInfo => AdvancedInfoActionButton(source: context.source),
|
|
||||||
ActionButtonType.share => ShareActionButton(source: context.source),
|
|
||||||
ActionButtonType.shareLink => ShareLinkActionButton(source: context.source),
|
|
||||||
ActionButtonType.archive => ArchiveActionButton(source: context.source),
|
|
||||||
ActionButtonType.unarchive => UnArchiveActionButton(source: context.source),
|
|
||||||
ActionButtonType.download => DownloadActionButton(source: context.source),
|
|
||||||
ActionButtonType.trash => TrashActionButton(source: context.source),
|
|
||||||
ActionButtonType.deletePermanent => DeletePermanentActionButton(source: context.source),
|
|
||||||
ActionButtonType.delete => DeleteActionButton(source: context.source),
|
|
||||||
ActionButtonType.moveToLockFolder => MoveToLockFolderActionButton(source: context.source),
|
|
||||||
ActionButtonType.removeFromLockFolder => RemoveFromLockFolderActionButton(source: context.source),
|
|
||||||
ActionButtonType.deleteLocal => DeleteLocalActionButton(source: context.source),
|
|
||||||
ActionButtonType.upload => UploadActionButton(source: context.source),
|
|
||||||
ActionButtonType.removeFromAlbum => RemoveFromAlbumActionButton(
|
|
||||||
albumId: context.currentAlbum!.id,
|
|
||||||
source: context.source,
|
|
||||||
),
|
|
||||||
ActionButtonType.likeActivity => const LikeActivityActionButton(),
|
|
||||||
ActionButtonType.unstack => UnStackActionButton(source: context.source),
|
|
||||||
ActionButtonType.similarPhotos => SimilarPhotosActionButton(assetId: (context.asset as RemoteAsset).id),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActionButtonBuilder {
|
|
||||||
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
|
||||||
|
|
||||||
static List<Widget> build(ActionButtonContext context) {
|
|
||||||
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewerKebabMenuButtonContext {
|
|
||||||
final BaseAsset asset;
|
|
||||||
final bool isOwner;
|
|
||||||
final bool isCasting;
|
|
||||||
final TimelineOrigin timelineOrigin;
|
|
||||||
final ThemeData? originalTheme;
|
|
||||||
|
|
||||||
const ViewerKebabMenuButtonContext({
|
|
||||||
required this.asset,
|
|
||||||
required this.isOwner,
|
|
||||||
required this.isCasting,
|
|
||||||
required this.timelineOrigin,
|
|
||||||
this.originalTheme,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ViewerKebabMenuButtonType {
|
|
||||||
openInfo,
|
|
||||||
viewInTimeline,
|
|
||||||
cast,
|
|
||||||
download;
|
|
||||||
|
|
||||||
/// Defines which group each button belongs to.
|
|
||||||
/// Buttons in the same group will be displayed together,
|
|
||||||
/// with dividers separating different groups.
|
|
||||||
int get group => switch (this) {
|
|
||||||
ViewerKebabMenuButtonType.openInfo => 0,
|
|
||||||
ViewerKebabMenuButtonType.viewInTimeline => 1,
|
|
||||||
ViewerKebabMenuButtonType.cast => 1,
|
|
||||||
ViewerKebabMenuButtonType.download => 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool shouldShow(ViewerKebabMenuButtonContext context) {
|
|
||||||
return switch (this) {
|
|
||||||
ViewerKebabMenuButtonType.openInfo => true,
|
|
||||||
ViewerKebabMenuButtonType.viewInTimeline =>
|
|
||||||
context.timelineOrigin != TimelineOrigin.main &&
|
context.timelineOrigin != TimelineOrigin.main &&
|
||||||
context.timelineOrigin != TimelineOrigin.deepLink &&
|
context.timelineOrigin != TimelineOrigin.deepLink &&
|
||||||
context.timelineOrigin != TimelineOrigin.trash &&
|
context.timelineOrigin != TimelineOrigin.trash &&
|
||||||
|
context.timelineOrigin != TimelineOrigin.lockedFolder &&
|
||||||
context.timelineOrigin != TimelineOrigin.archive &&
|
context.timelineOrigin != TimelineOrigin.archive &&
|
||||||
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
||||||
context.isOwner,
|
context.isOwner,
|
||||||
ViewerKebabMenuButtonType.cast => context.isCasting || context.asset.hasRemote,
|
ActionButtonType.cast => context.isCasting || context.asset.hasRemote,
|
||||||
ViewerKebabMenuButtonType.download => context.asset.isRemoteOnly,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsumerWidget buildButton(ViewerKebabMenuButtonContext context, BuildContext buildContext) {
|
ConsumerWidget buildButton(
|
||||||
|
ActionButtonContext context, [
|
||||||
|
BuildContext? buildContext,
|
||||||
|
bool iconOnly = false,
|
||||||
|
bool menuItem = false,
|
||||||
|
]) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
ViewerKebabMenuButtonType.openInfo => BaseActionButton(
|
ActionButtonType.advancedInfo => AdvancedInfoActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.share => ShareActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.shareLink => ShareLinkActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.archive => ArchiveActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.unarchive => UnArchiveActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.download => DownloadActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.trash => TrashActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.deletePermanent => DeletePermanentActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.delete => DeleteActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.moveToLockFolder => MoveToLockFolderActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.removeFromLockFolder => RemoveFromLockFolderActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.deleteLocal => DeleteLocalActionButton(
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.upload => UploadActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.removeFromAlbum => RemoveFromAlbumActionButton(
|
||||||
|
albumId: context.currentAlbum!.id,
|
||||||
|
source: context.source,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.likeActivity => LikeActivityActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.unstack => UnStackActionButton(source: context.source, iconOnly: iconOnly, menuItem: menuItem),
|
||||||
|
ActionButtonType.similarPhotos => SimilarPhotosActionButton(
|
||||||
|
assetId: (context.asset as RemoteAsset).id,
|
||||||
|
iconOnly: iconOnly,
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
ActionButtonType.openInfo => BaseActionButton(
|
||||||
label: 'info'.tr(),
|
label: 'info'.tr(),
|
||||||
iconData: Icons.info_outline,
|
iconData: Icons.info_outline,
|
||||||
iconColor: context.originalTheme?.iconTheme.color,
|
iconColor: context.originalTheme?.iconTheme.color,
|
||||||
menuItem: true,
|
menuItem: true,
|
||||||
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent()),
|
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent()),
|
||||||
),
|
),
|
||||||
|
ActionButtonType.viewInTimeline => BaseActionButton(
|
||||||
ViewerKebabMenuButtonType.viewInTimeline => BaseActionButton(
|
label: 'view_in_timeline'.tr(),
|
||||||
label: 'view_in_timeline'.t(context: buildContext),
|
|
||||||
iconData: Icons.image_search,
|
iconData: Icons.image_search,
|
||||||
iconColor: context.originalTheme?.iconTheme.color,
|
iconColor: context.originalTheme?.iconTheme.color,
|
||||||
menuItem: true,
|
iconOnly: iconOnly,
|
||||||
onPressed: () async {
|
menuItem: menuItem,
|
||||||
|
onPressed: buildContext == null
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
await buildContext.maybePop();
|
await buildContext.maybePop();
|
||||||
await buildContext.navigateTo(const TabShellRoute(children: [MainTimelineRoute()]));
|
await buildContext.navigateTo(const TabShellRoute(children: [MainTimelineRoute()]));
|
||||||
EventStream.shared.emit(ScrollToDateEvent(context.asset.createdAt));
|
EventStream.shared.emit(ScrollToDateEvent(context.asset.createdAt));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ViewerKebabMenuButtonType.cast => const CastActionButton(menuItem: true),
|
ActionButtonType.cast => CastActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||||
ViewerKebabMenuButtonType.download => const DownloadActionButton(source: ActionSource.viewer, menuItem: true),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defines which group each button belongs to for kebab menu.
|
||||||
|
/// Buttons in the same group will be displayed together,
|
||||||
|
/// with dividers separating different groups.
|
||||||
|
int get kebabMenuGroup => switch (this) {
|
||||||
|
// 0: info
|
||||||
|
ActionButtonType.openInfo => 0,
|
||||||
|
// 10: move,remove, and delete
|
||||||
|
ActionButtonType.trash => 10,
|
||||||
|
ActionButtonType.deletePermanent => 10,
|
||||||
|
ActionButtonType.removeFromLockFolder => 10,
|
||||||
|
ActionButtonType.removeFromAlbum => 10,
|
||||||
|
ActionButtonType.unstack => 10,
|
||||||
|
ActionButtonType.archive => 10,
|
||||||
|
ActionButtonType.unarchive => 10,
|
||||||
|
ActionButtonType.moveToLockFolder => 10,
|
||||||
|
ActionButtonType.deleteLocal => 10,
|
||||||
|
ActionButtonType.delete => 10,
|
||||||
|
// 90: advancedInfo
|
||||||
|
ActionButtonType.advancedInfo => 90,
|
||||||
|
// 1: others
|
||||||
|
_ => 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewerKebabMenuButtonBuilder {
|
class ActionButtonBuilder {
|
||||||
static List<Widget> build(ViewerKebabMenuButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
||||||
final visibleButtons = ViewerKebabMenuButtonType.values.where((type) => type.shouldShow(context)).toList();
|
static const List<ActionButtonType> defaultViewerKebabMenuOrder = _actionTypes;
|
||||||
|
static const Set<ActionButtonType> defaultViewerBottomBarButtons = {
|
||||||
|
ActionButtonType.share,
|
||||||
|
ActionButtonType.moveToLockFolder,
|
||||||
|
ActionButtonType.upload,
|
||||||
|
ActionButtonType.delete,
|
||||||
|
ActionButtonType.archive,
|
||||||
|
ActionButtonType.unarchive,
|
||||||
|
};
|
||||||
|
|
||||||
if (visibleButtons.isEmpty) return [];
|
static List<Widget> build(ActionButtonContext context) {
|
||||||
|
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Widget> buildViewerKebabMenu(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||||
|
final visibleButtons = defaultViewerKebabMenuOrder
|
||||||
|
.where((type) => !defaultViewerBottomBarButtons.contains(type) && type.shouldShow(context))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (visibleButtons.isEmpty) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
final List<Widget> result = [];
|
final List<Widget> result = [];
|
||||||
int? lastGroup;
|
int? lastGroup;
|
||||||
|
|
||||||
for (final type in visibleButtons) {
|
for (final type in visibleButtons) {
|
||||||
if (lastGroup != null && type.group != lastGroup) {
|
if (lastGroup != null && type.kebabMenuGroup != lastGroup) {
|
||||||
result.add(const Divider(height: 1));
|
result.add(const Divider(height: 1));
|
||||||
}
|
}
|
||||||
result.add(type.buildButton(context, buildContext).build(buildContext, ref));
|
result.add(type.buildButton(context, buildContext, false, true).build(buildContext, ref));
|
||||||
lastGroup = type.group;
|
lastGroup = type.kebabMenuGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user