Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Show downloaded and finished as clearer icon badges on covers, and say Downloaded instead of Saved

Barnabas0a1e9b25d2c8
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index caef0c85..db40c9db 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -1436,7 +1436,7 @@
"removeDownloadContent": "This will be removed from your device.",
"downloadRemoved": "Download removed",
"finished": "Finished",
- "saved": "Saved",
+ "saved": "Downloaded",
"selectLibrary": "Select Library",
"switchLibraryTooltip": "Switch library",
"noBooksFound": "No books found",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 1651f422..efb37ea1 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -5407,7 +5407,7 @@ abstract class AppLocalizations {
/// No description provided for @saved.
///
/// In en, this message translates to:
- /// **'Saved'**
+ /// **'Downloaded'**
String get saved;
/// No description provided for @selectLibrary.
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index f602cd23..1f75efe5 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsEl extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 70c35276..305d63b2 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index e3615700..4b7a92a1 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsEs extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index 37d3dd85..c7b5bdda 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -2936,7 +2936,7 @@ class AppLocalizationsFr extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index 3061e983..e36e623a 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsIt extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index 8a585fab..39dff29d 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsJa extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index 9d87217e..b7bf29fc 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsNo extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index 02d0f651..09d84807 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsPt extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index 69d460d1..a9c8cd29 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -2934,7 +2934,7 @@ class AppLocalizationsRo extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index d154fdb9..873ec468 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -2937,7 +2937,7 @@ class AppLocalizationsRu extends AppLocalizations {
String get finished => 'Finished';
@override
- String get saved => 'Saved';
+ String get saved => 'Downloaded';
@override
String get selectLibrary => 'Select Library';
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index eb1fb002..bda00ef4 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
import '../services/download_service.dart';
@@ -137,17 +138,9 @@ class BookCard extends StatelessWidget {
),
),
if (DownloadService().isDownloaded(item['id'] as String? ?? ''))
- Positioned(
- top: 4, right: 4,
- child: Container(
- padding: const EdgeInsets.all(3),
- decoration: BoxDecoration(
- color: Colors.black54,
- borderRadius: BorderRadius.circular(6),
- ),
- child: Icon(Icons.download_done_rounded,
- size: 14, color: cs.primary),
- ),
+ const Positioned(
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(isDownloaded: true, isFinished: false),
),
],
),
@@ -308,50 +301,11 @@ class BookCard extends StatelessWidget {
),
if (isFinished || isDownloaded)
Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- if (isFinished) ...[
- Icon(Icons.check_circle_rounded,
- size: 10, color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700),
- const SizedBox(width: 3),
- Text(l.bookCardDone,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700)),
- ],
- if (isFinished && isDownloaded)
- const SizedBox(width: 6),
- if (isDownloaded) ...[
- Icon(Icons.download_done_rounded,
- size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.bookCardSaved,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: cs.primary)),
- ],
- ],
- ),
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(
+ isDownloaded: isDownloaded,
+ isFinished: isFinished,
+ borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
),
),
],
diff --git a/lib/widgets/collection_detail_sheet.dart b/lib/widgets/collection_detail_sheet.dart
index fec2dd3d..785b0351 100644
--- a/lib/widgets/collection_detail_sheet.dart
+++ b/lib/widgets/collection_detail_sheet.dart
@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'overlay_toast.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../services/wording.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
@@ -322,9 +323,6 @@ class _CollectionDetailSheetState extends State<CollectionDetailSheet> {
}
Widget _buildItemList(ColorScheme cs, TextTheme tt, LibraryProvider lib, List<dynamic> books, AppLocalizations l, {required bool canEditCollection}) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
-
return ListView.builder(
controller: widget.scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4).copyWith(bottom: 40),
@@ -396,33 +394,7 @@ class _CollectionDetailSheetState extends State<CollectionDetailSheet> {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.check_circle_rounded, size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.collectionDetailDone, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: doneColor)),
- ]),
- if (isDownloaded)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.download_done_rounded, size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
]),
),
@@ -516,9 +488,6 @@ class _CollectionDetailSheetState extends State<CollectionDetailSheet> {
}
Widget _buildGrid(ColorScheme cs, TextTheme tt, LibraryProvider lib, List<dynamic> books, AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
-
return GridView.builder(
controller: widget.scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4)
@@ -591,33 +560,7 @@ class _CollectionDetailSheetState extends State<CollectionDetailSheet> {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.check_circle_rounded, size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.collectionDetailDone, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: doneColor)),
- ]),
- if (isDownloaded)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.download_done_rounded, size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
]),
),
diff --git a/lib/widgets/cover_badges.dart b/lib/widgets/cover_badges.dart
new file mode 100644
index 00000000..f1711780
--- /dev/null
+++ b/lib/widgets/cover_badges.dart
@@ -0,0 +1,69 @@
+import 'package:flutter/material.dart';
+import '../l10n/app_localizations.dart';
+
+/// State banner across the bottom of cover art: a finished check + "Finished"
+/// (green) and a downloaded arrow + "Downloaded" (white), stacked, over a strong
+/// dark scrim so they stay legible on any artwork. Place across the bottom of a
+/// cover Stack:
+/// Positioned(left: 0, right: 0, bottom: 0, child: CoverStateBadges(...))
+class CoverStateBadges extends StatelessWidget {
+ final bool isDownloaded;
+ final bool isFinished;
+ final double iconSize;
+
+ /// Rounds the banner's bottom corners to match covers that aren't clipped by
+ /// a parent ClipRRect (e.g. some cards).
+ final BorderRadius? borderRadius;
+
+ const CoverStateBadges({
+ super.key,
+ required this.isDownloaded,
+ required this.isFinished,
+ this.iconSize = 13,
+ this.borderRadius,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ if (!isDownloaded && !isFinished) return const SizedBox.shrink();
+ final l = AppLocalizations.of(context)!;
+ final green = Colors.greenAccent.shade400;
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 5),
+ decoration: BoxDecoration(
+ borderRadius: borderRadius,
+ gradient: LinearGradient(
+ begin: Alignment.bottomCenter,
+ end: Alignment.topCenter,
+ colors: [
+ Colors.black.withValues(alpha: 0.92),
+ Colors.black.withValues(alpha: 0.55),
+ Colors.black.withValues(alpha: 0.0),
+ ],
+ stops: const [0.0, 0.6, 1.0],
+ ),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ if (isFinished) _row(Icons.check_circle_rounded, l.finished, green),
+ if (isFinished && isDownloaded) const SizedBox(height: 2),
+ if (isDownloaded) _row(Icons.download_rounded, l.saved, Colors.white),
+ ],
+ ),
+ );
+ }
+
+ Widget _row(IconData icon, String label, Color color) {
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(icon, size: iconSize, color: color),
+ const SizedBox(width: 3),
+ Text(label, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: color)),
+ ],
+ );
+ }
+}
diff --git a/lib/widgets/finished_books_this_year_sheet.dart b/lib/widgets/finished_books_this_year_sheet.dart
index 8cadeae8..033657b6 100644
--- a/lib/widgets/finished_books_this_year_sheet.dart
+++ b/lib/widgets/finished_books_this_year_sheet.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
import '../providers/auth_provider.dart';
+import 'cover_badges.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
import '../services/download_service.dart';
@@ -213,8 +214,6 @@ class _FinishedBooksThisYearSheetState
Widget _buildList(ColorScheme cs, TextTheme tt, LibraryProvider lib,
AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
final bottomPad = 24 + MediaQuery.of(context).viewPadding.bottom;
return ListView.builder(
@@ -256,7 +255,7 @@ class _FinishedBooksThisYearSheetState
aspectRatio: 1.0,
child: Stack(children: [
Positioned.fill(child: _cover(coverUrl, lib, cs)),
- _finishedBadge(doneColor, isDownloaded, cs, l),
+ _finishedBadge(isDownloaded),
]),
),
Expanded(
@@ -303,8 +302,6 @@ class _FinishedBooksThisYearSheetState
Widget _buildGrid(ColorScheme cs, TextTheme tt, LibraryProvider lib,
AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
final bottomPad = 24 + MediaQuery.of(context).viewPadding.bottom;
return GridView.builder(
@@ -343,7 +340,7 @@ class _FinishedBooksThisYearSheetState
borderRadius: BorderRadius.circular(10),
child: Stack(children: [
Positioned.fill(child: _cover(coverUrl, lib, cs)),
- _finishedBadge(doneColor, isDownloaded, cs, l),
+ _finishedBadge(isDownloaded),
]),
),
),
@@ -421,52 +418,10 @@ class _FinishedBooksThisYearSheetState
return '${months[d.month - 1]} ${d.day}, ${d.year}';
}
- Widget _finishedBadge(Color doneColor, bool isDownloaded, ColorScheme cs,
- AppLocalizations l) =>
- Positioned(
+ Widget _finishedBadge(bool isDownloaded) => Positioned(
left: 0,
right: 0,
bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(Icons.check_circle_rounded, size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.sectionDetailDoneBadge,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: doneColor)),
- ]),
- if (isDownloaded)
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(Icons.download_done_rounded,
- size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: true),
);
}
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index c494202b..12128a74 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
-import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../providers/library_provider.dart';
import '../services/download_service.dart';
import 'absorbing_shared.dart';
@@ -250,7 +250,6 @@ class _EpisodeCard extends StatelessWidget {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final l = AppLocalizations.of(context)!;
final itemId = item['id'] as String? ?? '';
final media = item['media'] as Map<String, dynamic>? ?? {};
@@ -340,47 +339,10 @@ class _EpisodeCard extends StatelessWidget {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- if (isFinished) ...[
- Icon(Icons.check_circle_rounded,
- size: 10, color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700),
- const SizedBox(width: 3),
- Text(l.homeSectionDoneBadge,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700)),
- ],
- if (isFinished && isDownloaded)
- const SizedBox(width: 6),
- if (isDownloaded) ...[
- Icon(Icons.download_done_rounded,
- size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: cs.primary)),
- ],
- ],
- ),
+ child: CoverStateBadges(
+ isDownloaded: isDownloaded,
+ isFinished: isFinished,
+ borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
),
),
// Subscribed bell
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index e9209a99..dbd18176 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
@@ -185,53 +186,13 @@ class _GridBookTileState extends State<GridBookTile> {
),
),
- // ── Banners ──
+ // ── State badges (downloaded / finished) ──
if (isFinished || isDownloaded)
Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- if (isFinished) ...[
- Icon(Icons.check_circle_rounded,
- size: 10, color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700),
- const SizedBox(width: 3),
- Text(l.libraryGridTilesDone,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700)),
- ],
- if (isFinished && isDownloaded)
- const SizedBox(width: 6),
- if (isDownloaded) ...[
- Icon(Icons.download_done_rounded,
- size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.libraryGridTilesSaved,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: cs.primary)),
- ],
- ],
- ),
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(
+ isDownloaded: isDownloaded,
+ isFinished: isFinished,
),
),
],
@@ -321,7 +282,6 @@ class _StackedCovers extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final l = AppLocalizations.of(context)!;
// Cap at 3 stacked covers (front + two back). 4 was visually busy and the
// extra image decodes + per-shadow blur repaints made the Series grid
// visibly janky during scroll.
@@ -389,34 +349,9 @@ class _StackedCovers extends StatelessWidget {
),
// Finished banner
if (booksFinished > 0 && booksFinished >= numBooks)
- Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.7),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.check_circle_rounded, size: 10,
- color: Colors.greenAccent),
- const SizedBox(width: 3),
- Text(l.finished,
- style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600,
- color: Colors.white.withValues(alpha: 0.9))),
- ],
- ),
- ),
+ const Positioned(
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(isDownloaded: false, isFinished: true),
),
// Book count badge
Positioned(
diff --git a/lib/widgets/library_search_results.dart b/lib/widgets/library_search_results.dart
index 76c92226..d91e47dd 100644
--- a/lib/widgets/library_search_results.dart
+++ b/lib/widgets/library_search_results.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
import '../services/download_service.dart';
@@ -42,7 +43,6 @@ class BookResultTile extends StatelessWidget {
final isExplicit = PlayerSettings.showExplicitBadge && metadata['explicit'] == true;
final isDownloaded = itemId != null && DownloadService().isDownloaded(itemId);
final isFinished = itemId != null && lib.getProgressData(itemId)?['isFinished'] == true;
- final greenColor = Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400]! : Colors.green.shade700;
String? coverUrl;
if (itemId != null && serverUrl != null && token != null) {
@@ -119,33 +119,7 @@ class BookResultTile extends StatelessWidget {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [Colors.black.withValues(alpha: 0.85), Colors.black.withValues(alpha: 0.0)],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- if (isFinished) ...[
- Icon(Icons.check_circle_rounded, size: 8, color: greenColor),
- const SizedBox(width: 2),
- Text(l.librarySearchResultsDone, style: TextStyle(fontSize: 7, fontWeight: FontWeight.w600, color: greenColor)),
- ],
- if (isFinished && isDownloaded) const SizedBox(width: 4),
- if (isDownloaded) ...[
- Icon(Icons.download_done_rounded, size: 8, color: cs.primary),
- const SizedBox(width: 2),
- Text(l.librarySearchResultsSaved, style: TextStyle(fontSize: 7, fontWeight: FontWeight.w600, color: cs.primary)),
- ],
- ],
- ),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
],
),
diff --git a/lib/widgets/playlist_detail_sheet.dart b/lib/widgets/playlist_detail_sheet.dart
index 1c7df58c..5d9170cf 100644
--- a/lib/widgets/playlist_detail_sheet.dart
+++ b/lib/widgets/playlist_detail_sheet.dart
@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'overlay_toast.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../services/wording.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
@@ -614,9 +615,6 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
}
Widget _buildItemList(ColorScheme cs, TextTheme tt, LibraryProvider lib, List<dynamic> items, AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
-
return ListView.builder(
controller: widget.scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4).copyWith(bottom: 40),
@@ -720,33 +718,7 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.check_circle_rounded, size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.playlistDetailDone, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: doneColor)),
- ]),
- if (isDownloaded)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.download_done_rounded, size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
]),
),
@@ -779,9 +751,6 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
}
Widget _buildGrid(ColorScheme cs, TextTheme tt, LibraryProvider lib, List<dynamic> items, AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
-
return GridView.builder(
controller: widget.scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4)
@@ -864,33 +833,7 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
if (isFinished || isDownloaded)
Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.check_circle_rounded, size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.playlistDetailDone, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: doneColor)),
- ]),
- if (isDownloaded)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.download_done_rounded, size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
]),
),
diff --git a/lib/widgets/section_detail_sheet.dart b/lib/widgets/section_detail_sheet.dart
index bd767ce4..706eb291 100644
--- a/lib/widgets/section_detail_sheet.dart
+++ b/lib/widgets/section_detail_sheet.dart
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../services/wording.dart';
import '../providers/library_provider.dart';
import '../services/audio_player_service.dart';
@@ -128,9 +129,6 @@ class _SectionDetailSheetState extends State<SectionDetailSheet> {
}
Widget _buildList(ColorScheme cs, TextTheme tt, LibraryProvider lib, AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
-
return ListView.builder(
controller: widget.scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4)
@@ -184,7 +182,10 @@ class _SectionDetailSheetState extends State<SectionDetailSheet> {
if (isExplicit) _explicitBadge(l),
if (progress > 0 && !isFinished) _progressBar(cs, progress),
if (isFinished || isDownloaded)
- _badges(cs, doneColor, isFinished, isDownloaded, l),
+ Positioned(
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
+ ),
]),
),
Expanded(
@@ -248,8 +249,6 @@ class _SectionDetailSheetState extends State<SectionDetailSheet> {
}
Widget _buildGrid(ColorScheme cs, TextTheme tt, LibraryProvider lib, AppLocalizations l) {
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final doneColor = isDark ? Colors.greenAccent[400]! : Colors.green.shade700;
final isRect = widget.coverAspectRatio < 1.0;
// Text area is ~50px; cover uses aspect ratio to determine height
final childAspectRatio = isRect ? 0.45 : 0.62;
@@ -304,7 +303,10 @@ class _SectionDetailSheetState extends State<SectionDetailSheet> {
if (progress > 0 && !isFinished)
_progressBar(cs, progress),
if (isFinished || isDownloaded)
- _badges(cs, doneColor, isFinished, isDownloaded, l),
+ Positioned(
+ left: 0, right: 0, bottom: 0,
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
+ ),
]),
),
),
@@ -373,53 +375,4 @@ class _SectionDetailSheetState extends State<SectionDetailSheet> {
valueColor: AlwaysStoppedAnimation(cs.primary),
),
);
-
- Widget _badges(ColorScheme cs, Color doneColor, bool isFinished,
- bool isDownloaded, AppLocalizations l) =>
- Positioned(
- left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.85),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(Icons.check_circle_rounded,
- size: 10, color: doneColor),
- const SizedBox(width: 3),
- Text(l.sectionDetailDoneBadge,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: doneColor)),
- ]),
- if (isDownloaded)
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(Icons.download_done_rounded,
- size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved,
- style: TextStyle(
- fontSize: 9,
- fontWeight: FontWeight.w600,
- color: cs.primary)),
- ]),
- ]),
- ),
- );
}
diff --git a/lib/widgets/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 641d5c4e..86e02bf4 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -5,6 +5,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'overlay_toast.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../services/wording.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
@@ -1142,29 +1143,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
),
if (isFinished || isDownloaded)
Positioned(left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(begin: Alignment.bottomCenter, end: Alignment.topCenter,
- colors: [Colors.black.withValues(alpha: 0.85), Colors.black.withValues(alpha: 0.0)]),
- ),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- if (isFinished)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.check_circle_rounded, size: 10,
- color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700),
- const SizedBox(width: 3),
- Text(l.seriesBooksDone, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600,
- color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700)),
- ]),
- if (isDownloaded)
- Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
- Icon(Icons.download_done_rounded, size: 10, color: cs.primary),
- const SizedBox(width: 3),
- Text(l.saved, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.primary)),
- ]),
- ]),
- ),
+ child: CoverStateBadges(isDownloaded: isDownloaded, isFinished: isFinished),
),
]),
),
diff --git a/lib/widgets/series_card.dart b/lib/widgets/series_card.dart
index a635ff39..e3d93cba 100644
--- a/lib/widgets/series_card.dart
+++ b/lib/widgets/series_card.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../l10n/app_localizations.dart';
+import 'cover_badges.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import 'series_books_sheet.dart';
@@ -133,7 +134,6 @@ class _StackedCovers extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final l = AppLocalizations.of(context)!;
final count = coverUrls.length.clamp(1, 4);
const inset = 5.0;
final totalOffset = count > 1 ? inset * (count - 1) : 0.0;
@@ -196,32 +196,9 @@ class _StackedCovers extends StatelessWidget {
),
),
if (booksFinished > 0 && booksFinished >= numBooks)
- Positioned(
+ const Positioned(
left: 0, right: 0, bottom: 0,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.bottomCenter,
- end: Alignment.topCenter,
- colors: [
- Colors.black.withValues(alpha: 0.7),
- Colors.black.withValues(alpha: 0.0),
- ],
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.check_circle_rounded, size: 10,
- color: Colors.greenAccent),
- const SizedBox(width: 3),
- Text(l.finished,
- style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600,
- color: Colors.white.withValues(alpha: 0.9))),
- ],
- ),
- ),
+ child: CoverStateBadges(isDownloaded: false, isFinished: true),
),
Positioned(
top: 4, right: 4,