mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +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": {
|
"@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"
|
"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": "Unauthenticated access. Please sign-in again if the problem continues",
|
||||||
"@errorUnauthenticated": {
|
"@errorUnauthenticated": {
|
||||||
|
|
|
@ -27,7 +27,10 @@
|
||||||
"useAsAlbumCoverTooltip",
|
"useAsAlbumCoverTooltip",
|
||||||
"helpTooltip",
|
"helpTooltip",
|
||||||
"removeFromAlbumTooltip",
|
"removeFromAlbumTooltip",
|
||||||
"fileSharedByDescription"
|
"fileSharedByDescription",
|
||||||
|
"emptyTrashbinTooltip",
|
||||||
|
"emptyTrashbinConfirmationDialogTitle",
|
||||||
|
"emptyTrashbinConfirmationDialogContent"
|
||||||
],
|
],
|
||||||
|
|
||||||
"es": [
|
"es": [
|
||||||
|
@ -38,7 +41,10 @@
|
||||||
"settingsForceRotationDescription",
|
"settingsForceRotationDescription",
|
||||||
"helpTooltip",
|
"helpTooltip",
|
||||||
"removeFromAlbumTooltip",
|
"removeFromAlbumTooltip",
|
||||||
"fileSharedByDescription"
|
"fileSharedByDescription",
|
||||||
|
"emptyTrashbinTooltip",
|
||||||
|
"emptyTrashbinConfirmationDialogTitle",
|
||||||
|
"emptyTrashbinConfirmationDialogContent"
|
||||||
],
|
],
|
||||||
|
|
||||||
"fr": [
|
"fr": [
|
||||||
|
@ -49,7 +55,10 @@
|
||||||
"settingsForceRotationDescription",
|
"settingsForceRotationDescription",
|
||||||
"helpTooltip",
|
"helpTooltip",
|
||||||
"removeFromAlbumTooltip",
|
"removeFromAlbumTooltip",
|
||||||
"fileSharedByDescription"
|
"fileSharedByDescription",
|
||||||
|
"emptyTrashbinTooltip",
|
||||||
|
"emptyTrashbinConfirmationDialogTitle",
|
||||||
|
"emptyTrashbinConfirmationDialogContent"
|
||||||
],
|
],
|
||||||
|
|
||||||
"ru": [
|
"ru": [
|
||||||
|
@ -60,6 +69,9 @@
|
||||||
"settingsForceRotationDescription",
|
"settingsForceRotationDescription",
|
||||||
"helpTooltip",
|
"helpTooltip",
|
||||||
"removeFromAlbumTooltip",
|
"removeFromAlbumTooltip",
|
||||||
"fileSharedByDescription"
|
"fileSharedByDescription",
|
||||||
|
"emptyTrashbinTooltip",
|
||||||
|
"emptyTrashbinConfirmationDialogTitle",
|
||||||
|
"emptyTrashbinConfirmationDialogContent"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,17 +169,17 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
_onSelectionAppBarRestorePressed();
|
_onSelectionAppBarRestorePressed();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
PopupMenuButton<_AppBarMenuOption>(
|
PopupMenuButton<_SelectionAppBarMenuOption>(
|
||||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) => [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: _AppBarMenuOption.delete,
|
value: _SelectionAppBarMenuOption.delete,
|
||||||
child: Text(L10n.of(context).deletePermanentlyTooltip),
|
child: Text(L10n.of(context).deletePermanentlyTooltip),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onSelected: (option) {
|
onSelected: (option) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case _AppBarMenuOption.delete:
|
case _SelectionAppBarMenuOption.delete:
|
||||||
_onSelectionAppBarDeletePressed(context);
|
_onSelectionAppBarDeletePressed(context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -209,6 +209,26 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
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));
|
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 {
|
Future<void> _onSelectionAppBarRestorePressed() async {
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.of(context)
|
content: Text(L10n.of(context)
|
||||||
|
@ -343,11 +382,6 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _deleteSelected(BuildContext context) async {
|
Future<void> _deleteSelected(BuildContext context) async {
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
|
||||||
content: Text(L10n.of(context)
|
|
||||||
.deleteSelectedProcessingNotification(selectedListItems.length)),
|
|
||||||
duration: k.snackBarDurationShort,
|
|
||||||
));
|
|
||||||
final selectedFiles = selectedListItems
|
final selectedFiles = selectedListItems
|
||||||
.whereType<_FileListItem>()
|
.whereType<_FileListItem>()
|
||||||
.map((e) => e.file)
|
.map((e) => e.file)
|
||||||
|
@ -355,14 +389,23 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
setState(() {
|
setState(() {
|
||||||
clearSelectedItems();
|
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 fileRepo = FileRepo(FileCachedDataSource());
|
||||||
final failures = <File>[];
|
final failures = <File>[];
|
||||||
for (final f in selectedFiles) {
|
for (final f in files) {
|
||||||
try {
|
try {
|
||||||
await Remove(fileRepo, null)(widget.account, f);
|
await Remove(fileRepo, null)(widget.account, f);
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
_log.shout(
|
_log.shout(
|
||||||
"[_deleteSelected] Failed while removing file" +
|
"[_deleteFiles] Failed while removing file" +
|
||||||
(kDebugMode ? ": ${f.path}" : ""),
|
(kDebugMode ? ": ${f.path}" : ""),
|
||||||
e,
|
e,
|
||||||
stacktrace);
|
stacktrace);
|
||||||
|
@ -486,5 +529,9 @@ class _VideoListItem extends _FileListItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum _AppBarMenuOption {
|
enum _AppBarMenuOption {
|
||||||
|
empty,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum _SelectionAppBarMenuOption {
|
||||||
delete,
|
delete,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue