mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +01:00
Empty trash
This commit is contained in:
parent
510e78cc3a
commit
9c0dea88c7
3 changed files with 85 additions and 14 deletions
|
@ -706,6 +706,18 @@
|
|||
"@fileSharedByDescription": {
|
||||
"description": "The app will show the owner of the file if it's being shared with you by others. The name of the owner is displayed above this line"
|
||||
},
|
||||
"emptyTrashbinTooltip": "Empty trash",
|
||||
"@emptyTrashbinTooltip": {
|
||||
"description": "Permanently delete all items from trashbin"
|
||||
},
|
||||
"emptyTrashbinConfirmationDialogTitle": "Empty trash",
|
||||
"@emptyTrashbinConfirmationDialogTitle": {
|
||||
"description": "Make sure the user wants to delete all items"
|
||||
},
|
||||
"emptyTrashbinConfirmationDialogContent": "All items will be deleted permanently from the server.\n\nThis action is nonreversible",
|
||||
"@emptyTrashbinConfirmationDialogContent": {
|
||||
"description": "Make sure the user wants to delete all items"
|
||||
},
|
||||
|
||||
"errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues",
|
||||
"@errorUnauthenticated": {
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
"useAsAlbumCoverTooltip",
|
||||
"helpTooltip",
|
||||
"removeFromAlbumTooltip",
|
||||
"fileSharedByDescription"
|
||||
"fileSharedByDescription",
|
||||
"emptyTrashbinTooltip",
|
||||
"emptyTrashbinConfirmationDialogTitle",
|
||||
"emptyTrashbinConfirmationDialogContent"
|
||||
],
|
||||
|
||||
"es": [
|
||||
|
@ -38,7 +41,10 @@
|
|||
"settingsForceRotationDescription",
|
||||
"helpTooltip",
|
||||
"removeFromAlbumTooltip",
|
||||
"fileSharedByDescription"
|
||||
"fileSharedByDescription",
|
||||
"emptyTrashbinTooltip",
|
||||
"emptyTrashbinConfirmationDialogTitle",
|
||||
"emptyTrashbinConfirmationDialogContent"
|
||||
],
|
||||
|
||||
"fr": [
|
||||
|
@ -49,7 +55,10 @@
|
|||
"settingsForceRotationDescription",
|
||||
"helpTooltip",
|
||||
"removeFromAlbumTooltip",
|
||||
"fileSharedByDescription"
|
||||
"fileSharedByDescription",
|
||||
"emptyTrashbinTooltip",
|
||||
"emptyTrashbinConfirmationDialogTitle",
|
||||
"emptyTrashbinConfirmationDialogContent"
|
||||
],
|
||||
|
||||
"ru": [
|
||||
|
@ -60,6 +69,9 @@
|
|||
"settingsForceRotationDescription",
|
||||
"helpTooltip",
|
||||
"removeFromAlbumTooltip",
|
||||
"fileSharedByDescription"
|
||||
"fileSharedByDescription",
|
||||
"emptyTrashbinTooltip",
|
||||
"emptyTrashbinConfirmationDialogTitle",
|
||||
"emptyTrashbinConfirmationDialogContent"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -169,17 +169,17 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
_onSelectionAppBarRestorePressed();
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_AppBarMenuOption>(
|
||||
PopupMenuButton<_SelectionAppBarMenuOption>(
|
||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: _AppBarMenuOption.delete,
|
||||
value: _SelectionAppBarMenuOption.delete,
|
||||
child: Text(L10n.of(context).deletePermanentlyTooltip),
|
||||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
switch (option) {
|
||||
case _AppBarMenuOption.delete:
|
||||
case _SelectionAppBarMenuOption.delete:
|
||||
_onSelectionAppBarDeletePressed(context);
|
||||
break;
|
||||
|
||||
|
@ -209,6 +209,26 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_AppBarMenuOption>(
|
||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: _AppBarMenuOption.empty,
|
||||
child: Text(L10n.of(context).emptyTrashbinTooltip),
|
||||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
switch (option) {
|
||||
case _AppBarMenuOption.empty:
|
||||
_onEmptyTrashPressed(context);
|
||||
break;
|
||||
|
||||
default:
|
||||
_log.shout("[_buildNormalAppBar] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -236,6 +256,25 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
TrashbinViewerArguments(widget.account, _backingFiles, index));
|
||||
}
|
||||
|
||||
void _onEmptyTrashPressed(BuildContext context) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(L10n.of(context).emptyTrashbinConfirmationDialogTitle),
|
||||
content: Text(L10n.of(context).emptyTrashbinConfirmationDialogContent),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_deleteFiles(context, _backingFiles);
|
||||
},
|
||||
child: Text(L10n.of(context).confirmButtonLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onSelectionAppBarRestorePressed() async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.of(context)
|
||||
|
@ -343,11 +382,6 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
}
|
||||
|
||||
Future<void> _deleteSelected(BuildContext context) async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.of(context)
|
||||
.deleteSelectedProcessingNotification(selectedListItems.length)),
|
||||
duration: k.snackBarDurationShort,
|
||||
));
|
||||
final selectedFiles = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
|
@ -355,14 +389,23 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
setState(() {
|
||||
clearSelectedItems();
|
||||
});
|
||||
return _deleteFiles(context, selectedFiles);
|
||||
}
|
||||
|
||||
Future<void> _deleteFiles(BuildContext context, List<File> files) async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
L10n.of(context).deleteSelectedProcessingNotification(files.length)),
|
||||
duration: k.snackBarDurationShort,
|
||||
));
|
||||
final fileRepo = FileRepo(FileCachedDataSource());
|
||||
final failures = <File>[];
|
||||
for (final f in selectedFiles) {
|
||||
for (final f in files) {
|
||||
try {
|
||||
await Remove(fileRepo, null)(widget.account, f);
|
||||
} catch (e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_deleteSelected] Failed while removing file" +
|
||||
"[_deleteFiles] Failed while removing file" +
|
||||
(kDebugMode ? ": ${f.path}" : ""),
|
||||
e,
|
||||
stacktrace);
|
||||
|
@ -486,5 +529,9 @@ class _VideoListItem extends _FileListItem {
|
|||
}
|
||||
|
||||
enum _AppBarMenuOption {
|
||||
empty,
|
||||
}
|
||||
|
||||
enum _SelectionAppBarMenuOption {
|
||||
delete,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue