mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-24 16:04:43 +01:00
Remove opened photo from an album
This commit is contained in:
parent
607e8a23ca
commit
ea8d351187
4 changed files with 68 additions and 10 deletions
|
@ -654,6 +654,10 @@
|
||||||
"configButtonLabel": "CONFIG",
|
"configButtonLabel": "CONFIG",
|
||||||
"useAsAlbumCoverTooltip": "Use as album cover",
|
"useAsAlbumCoverTooltip": "Use as album cover",
|
||||||
"helpTooltip": "Help",
|
"helpTooltip": "Help",
|
||||||
|
"removeFromAlbumTooltip": "Remove from album",
|
||||||
|
"@removeFromAlbumTooltip": {
|
||||||
|
"description": "Remove the opened photo from an album"
|
||||||
|
},
|
||||||
|
|
||||||
"changelogTitle": "Changelog",
|
"changelogTitle": "Changelog",
|
||||||
"@changelogTitle": {
|
"@changelogTitle": {
|
||||||
|
|
|
@ -20,18 +20,22 @@
|
||||||
"metadataTaskPauseNoWiFiNotification",
|
"metadataTaskPauseNoWiFiNotification",
|
||||||
"configButtonLabel",
|
"configButtonLabel",
|
||||||
"useAsAlbumCoverTooltip",
|
"useAsAlbumCoverTooltip",
|
||||||
"helpTooltip"
|
"helpTooltip",
|
||||||
|
"removeFromAlbumTooltip"
|
||||||
],
|
],
|
||||||
|
|
||||||
"es": [
|
"es": [
|
||||||
"helpTooltip"
|
"helpTooltip",
|
||||||
|
"removeFromAlbumTooltip"
|
||||||
],
|
],
|
||||||
|
|
||||||
"fr": [
|
"fr": [
|
||||||
"helpTooltip"
|
"helpTooltip",
|
||||||
|
"removeFromAlbumTooltip"
|
||||||
],
|
],
|
||||||
|
|
||||||
"ru": [
|
"ru": [
|
||||||
"helpTooltip"
|
"helpTooltip",
|
||||||
|
"removeFromAlbumTooltip"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
||||||
}
|
}
|
||||||
Navigator.pushNamed(context, Viewer.routeName,
|
Navigator.pushNamed(context, Viewer.routeName,
|
||||||
arguments: ViewerArguments(widget.account, _backingFiles, fileIndex,
|
arguments: ViewerArguments(widget.account, _backingFiles, fileIndex,
|
||||||
album: widget.album));
|
album: _album));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||||
|
@ -508,6 +508,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
||||||
if (ev.album.albumFile!.path == _album?.albumFile?.path) {
|
if (ev.album.albumFile!.path == _album?.albumFile?.path) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_album = ev.album;
|
_album = ev.album;
|
||||||
|
_transformItems();
|
||||||
initCover(widget.account, ev.album);
|
initCover(widget.account, ev.album);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,15 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (widget.album != null &&
|
||||||
|
widget.album!.albumFile?.isOwned(widget.account.username) ==
|
||||||
|
true &&
|
||||||
|
widget.album!.provider is AlbumStaticProvider)
|
||||||
|
_DetailPaneButton(
|
||||||
|
icon: Icons.remove_outlined,
|
||||||
|
label: L10n.of(context).removeFromAlbumTooltip,
|
||||||
|
onPressed: () => _onRemoveFromAlbumPressed(context),
|
||||||
|
),
|
||||||
if (widget.album != null &&
|
if (widget.album != null &&
|
||||||
widget.album!.albumFile?.isOwned(widget.account.username) ==
|
widget.album!.albumFile?.isOwned(widget.account.username) ==
|
||||||
true)
|
true)
|
||||||
|
@ -245,6 +254,43 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _onRemoveFromAlbumPressed(BuildContext context) async {
|
||||||
|
assert(widget.album!.provider is AlbumStaticProvider);
|
||||||
|
await _onAction(
|
||||||
|
context,
|
||||||
|
null,
|
||||||
|
L10n.of(context).removeSelectedFromAlbumSuccessNotification(1),
|
||||||
|
() async {
|
||||||
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||||
|
try {
|
||||||
|
final newItems =
|
||||||
|
AlbumStaticProvider.of(widget.album!).items.where((element) {
|
||||||
|
if (element is AlbumFileItem) {
|
||||||
|
return element.file.path != widget.file.path;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
await UpdateAlbum(albumRepo)(
|
||||||
|
widget.account,
|
||||||
|
widget.album!.copyWith(
|
||||||
|
provider: AlbumStaticProvider(
|
||||||
|
items: newItems,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
_log.shout("[_onRemoveFromAlbumPressed] Failed while updating album",
|
||||||
|
e, stackTrace);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failureText: L10n.of(context).removeSelectedFromAlbumFailureNotification,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _onSetAlbumCoverPressed(BuildContext context) async {
|
Future<void> _onSetAlbumCoverPressed(BuildContext context) async {
|
||||||
assert(widget.album != null);
|
assert(widget.album != null);
|
||||||
_log.info(
|
_log.info(
|
||||||
|
@ -401,15 +447,18 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
|
|
||||||
Future<void> _onAction(
|
Future<void> _onAction(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
String processingText,
|
String? processingText,
|
||||||
String successText,
|
String successText,
|
||||||
FutureOr<void> Function() action, {
|
FutureOr<void> Function() action, {
|
||||||
String? failureText,
|
String? failureText,
|
||||||
}) async {
|
}) async {
|
||||||
var controller = SnackBarManager().showSnackBar(SnackBar(
|
ScaffoldFeatureController<SnackBar, SnackBarClosedReason>? controller;
|
||||||
content: Text(processingText),
|
if (processingText != null) {
|
||||||
duration: k.snackBarDurationShort,
|
controller = SnackBarManager().showSnackBar(SnackBar(
|
||||||
));
|
content: Text(processingText),
|
||||||
|
duration: k.snackBarDurationShort,
|
||||||
|
));
|
||||||
|
}
|
||||||
controller?.closed.whenComplete(() {
|
controller?.closed.whenComplete(() {
|
||||||
controller = null;
|
controller = null;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue