High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(mobile): long-press delete button to permanently delete asset (#6240)
shenlongf62678f58f3e
diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dartindex 760af3e06f..4109412b4a 100644--- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart+++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart@@ -633,6 +633,7 @@ class GalleryViewerPage extends HookConsumerWidget {);}+ // TODO: Migrate to a custom bottom bar and handle long press to deleteWidget buildBottomBar() {// !!!! itemsList and actionlist should always be in syncfinal itemsList = [diff --git a/mobile/lib/modules/home/ui/control_bottom_app_bar.dart b/mobile/lib/modules/home/ui/control_bottom_app_bar.dartindex b24aad5a3d..119a94d9e7 100644--- a/mobile/lib/modules/home/ui/control_bottom_app_bar.dart+++ b/mobile/lib/modules/home/ui/control_bottom_app_bar.dart@@ -63,27 +63,35 @@ class ControlBottomAppBar extends ConsumerWidget {ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash));final albums = ref.watch(albumProvider).where((a) => a.isRemote).toList();final sharedAlbums = ref.watch(sharedAlbumProvider);+ const bottomPadding = 0.20;- void handleRemoteDelete(- bool force,+ void showForceDeleteDialog(Function(bool) deleteCb, {String? alertMsg,}) {- if (!force) {- deleteCb(force);- return;- }showDialog(context: context,builder: (BuildContext context) {return DeleteDialog(alert: alertMsg,- onDelete: () => deleteCb(force),+ onDelete: () => deleteCb(true),);},);}+ void handleRemoteDelete(+ bool force,+ Function(bool) deleteCb, {+ String? alertMsg,+ }) {+ if (!force) {+ deleteCb(force);+ return;+ }+ return showForceDeleteDialog(deleteCb, alertMsg: alertMsg);+ }+List<Widget> renderActionButtons() {return [if (hasRemote)@@ -132,6 +140,12 @@ class ControlBottomAppBar extends ConsumerWidget {alertMsg: "delete_dialog_alert_remote",): null,+ onLongPressed: enabled+ ? () => showForceDeleteDialog(+ onDeleteServer!,+ alertMsg: "delete_dialog_alert_remote",+ )+ : null,),),if (hasLocal && onDeleteLocal != null)@@ -167,6 +181,8 @@ class ControlBottomAppBar extends ConsumerWidget {onPressed: enabled? () => handleRemoteDelete(!trashEnabled, onDelete!): null,+ onLongPressed:+ enabled ? () => showForceDeleteDialog(onDelete!) : null,),),if (hasRemote && onEditTime != null)@@ -214,9 +230,9 @@ class ControlBottomAppBar extends ConsumerWidget {}return DraggableScrollableSheet(- initialChildSize: hasRemote ? 0.30 : 0.18,- minChildSize: 0.18,- maxChildSize: hasRemote ? 0.60 : 0.18,+ initialChildSize: hasRemote ? 0.30 : bottomPadding,+ minChildSize: bottomPadding,+ maxChildSize: hasRemote ? 0.60 : bottomPadding,snap: true,builder: (BuildContext context,diff --git a/mobile/lib/shared/ui/asset_grid/multiselect_grid.dart b/mobile/lib/shared/ui/asset_grid/multiselect_grid.dartindex 0dafc435bd..342bc397d3 100644--- a/mobile/lib/shared/ui/asset_grid/multiselect_grid.dart+++ b/mobile/lib/shared/ui/asset_grid/multiselect_grid.dart@@ -201,9 +201,9 @@ class MultiselectGrid extends HookConsumerWidget {msg: '${selection.value.length} $assetOrAssets $trashOrRemoved',gravity: ToastGravity.BOTTOM,);+ selectionEnabledHook.value = false;}} finally {- selectionEnabledHook.value = false;processing.value = false;}}@@ -224,9 +224,9 @@ class MultiselectGrid extends HookConsumerWidget {'${localIds.length} $assetOrAssets removed permanently from your device',gravity: ToastGravity.BOTTOM,);+ selectionEnabledHook.value = false;}} finally {- selectionEnabledHook.value = false;processing.value = false;}}diff --git a/mobile/lib/shared/ui/drag_sheet.dart b/mobile/lib/shared/ui/drag_sheet.dartindex fd4a3c2cf9..9c717202d9 100644--- a/mobile/lib/shared/ui/drag_sheet.dart+++ b/mobile/lib/shared/ui/drag_sheet.dart@@ -23,11 +23,13 @@ class ControlBoxButton extends StatelessWidget {required this.label,required this.iconData,this.onPressed,+ this.onLongPressed,}) : super(key: key);final String label;final IconData iconData;final void Function()? onPressed;+ final void Function()? onLongPressed;@overrideWidget build(BuildContext context) {@@ -35,6 +37,7 @@ class ControlBoxButton extends StatelessWidget {padding: const EdgeInsets.all(10),shape: const CircleBorder(),onPressed: onPressed,+ onLongPress: onLongPressed,minWidth: 75.0,child: Column(mainAxisAlignment: MainAxisAlignment.start,