A cross platform Audiobookshelf client for Android and iOS
Dart
Let you remove a book's cover and leave it with none
Barnabascdebf81a1eb8
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex aee25b13..fd227510 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -1606,6 +1606,10 @@"asinLabel": "ASIN","isbnLabel": "ISBN","coverImage": "Cover Image",+ "coverRemove": "Remove cover",+ "coverRemoveConfirm": "Remove this book's cover? It will show the generated title card instead.",+ "coverRemoved": "Cover removed",+ "coverRemoveFailed": "Could not remove the cover","coverUrlLabel": "Cover URL","coverUrlHint": "https://...","localMetadata": "Local Metadata",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex cc9b77d5..42f8cb5c 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -5926,6 +5926,30 @@ abstract class AppLocalizations {/// **'Cover Image'**String get coverImage;+ /// No description provided for @coverRemove.+ ///+ /// In en, this message translates to:+ /// **'Remove cover'**+ String get coverRemove;++ /// No description provided for @coverRemoveConfirm.+ ///+ /// In en, this message translates to:+ /// **'Remove this book\'s cover? It will show the generated title card instead.'**+ String get coverRemoveConfirm;++ /// No description provided for @coverRemoved.+ ///+ /// In en, this message translates to:+ /// **'Cover removed'**+ String get coverRemoved;++ /// No description provided for @coverRemoveFailed.+ ///+ /// In en, this message translates to:+ /// **'Could not remove the cover'**+ String get coverRemoveFailed;+/// No description provided for @coverUrlLabel.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex a5059494..124dd691 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -3296,6 +3296,19 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get coverImage => 'Coverbild';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover-URL';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex 63f58093..6444a086 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 59e12402..7e4faa73 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex e58b5646..6eba56b7 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -3249,6 +3249,19 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex 4d09c3e1..6441e836 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -3294,6 +3294,19 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'URL de la couverture';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex 269a6996..79fcca54 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex de66685f..51a01981 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex a90d53fc..9a217443 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex b8a77fd8..2b5095bf 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 311b9f79..08dbb7b6 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -3247,6 +3247,19 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex b883b845..185e5738 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -3251,6 +3251,19 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get coverImage => 'Cover Image';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => 'Cover URL';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 11f106be..8fbca430 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -3176,6 +3176,19 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get coverImage => '封面图片';+ @override+ String get coverRemove => 'Remove cover';++ @override+ String get coverRemoveConfirm =>+ 'Remove this book\'s cover? It will show the generated title card instead.';++ @override+ String get coverRemoved => 'Cover removed';++ @override+ String get coverRemoveFailed => 'Could not remove the cover';+@overrideString get coverUrlLabel => '封面 URL';diff --git a/lib/services/api_service.dart b/lib/services/api_service.dartindex b7486fef..d19689fe 100644--- a/lib/services/api_service.dart+++ b/lib/services/api_service.dart@@ -3532,6 +3532,19 @@ class ApiService {return false;}+ /// Remove a library item's cover, leaving it with none (admin only).+ /// DELETE /api/items/:id/cover+ Future<bool> removeItemCover(String itemId) async {+ try {+ final r = await _authDelete(+ Uri.parse('$_cleanBaseUrl/api/items/$itemId/cover'),+ timeout: const Duration(seconds: 30));+ debugPrint('[API] removeItemCover $itemId -> ${r.statusCode}');+ return r.statusCode == 200;+ } catch (e) { debugPrint('removeItemCover error: $e'); }+ return false;+ }+/// Upload a cover image file for a library item (admin only)Future<bool> uploadItemCover(String itemId, String filePath) async {try {diff --git a/lib/widgets/edit_metadata_sheet.dart b/lib/widgets/edit_metadata_sheet.dartindex a900aabc..0654402d 100644--- a/lib/widgets/edit_metadata_sheet.dart+++ b/lib/widgets/edit_metadata_sheet.dart@@ -650,6 +650,55 @@ class _MetadataEditViewState extends State<MetadataEditView>}}+ /// Clear the cover entirely, so the book falls back to the generated+ /// title card. Every other control here replaces one cover with another;+ /// there was no way to end up with none.+ Future<void> _removeCover() async {+ final l = AppLocalizations.of(context)!;+ final confirmed = await showDialog<bool>(+ context: context,+ builder: (ctx) => AlertDialog(+ title: Text(l.coverRemove),+ content: Text(l.coverRemoveConfirm),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx, false),+ child: Text(l.cancel),+ ),+ FilledButton(+ onPressed: () => Navigator.pop(ctx, true),+ child: Text(l.remove),+ ),+ ],+ ),+ );+ if (confirmed != true || !mounted) return;++ final api = context.read<AuthProvider>().apiService;+ if (api == null) return;+ setState(() => _saving = true);+ final ok = await api.removeItemCover(widget.itemId);+ if (!mounted) return;+ setState(() {+ _saving = false;+ if (ok) {+ _coverVersion++;+ _coverFilePath = null;+ _coverUrlCtrl.clear();+ }+ });+ if (ok) {+ // The grid reads has-cover from the item payload, so refresh rather than+ // leaving stale art behind on the shelves.+ context.read<LibraryProvider>().refresh();+ }+ showOverlayToast(+ context,+ ok ? l.coverRemoved : l.coverRemoveFailed,+ icon: ok ? Icons.check_circle_outline_rounded : Icons.error_outline_rounded,+ );+ }+String _safeString(dynamic value) {if (value == null) return '';if (value is String) return value;@@ -1496,6 +1545,16 @@ class _MetadataEditViewState extends State<MetadataEditView>),),),+ if (base.isNotEmpty) ...[+ const SizedBox(height: 8),+ Center(+ child: TextButton.icon(+ onPressed: _saving ? null : _removeCover,+ icon: Icon(Icons.hide_image_outlined, size: 18, color: cs.error),+ label: Text(l.coverRemove, style: TextStyle(color: cs.error)),+ ),+ ),+ ],const SizedBox(height: 16),Text(l.coverImage, style: tt.titleSmall?.copyWith(fontWeight: FontWeight.w600)),const SizedBox(height: 8),