Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add Narrators tab; in-app language picker; misc UI

Nathan Poulson64f82aad671d
diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb
index cba4ee1e..e49bad16 100644
--- a/lib/l10n/app_de.arb
+++ b/lib/l10n/app_de.arb
@@ -91,6 +91,7 @@
"libraryTabLibrary": "Bibliothek",
"libraryTabSeries": "Serien",
"libraryTabAuthors": "Autoren",
+ "libraryTabNarrators": "Sprecher",
"libraryNoBooks": "Keine Bücher gefunden",
"libraryNoBooksInProgress": "Keine angefangenen Bücher",
"libraryNoFinishedBooks": "Keine beendeten Bücher",
@@ -102,6 +103,7 @@
"@libraryNoBooksInGenre": { "placeholders": { "genre": { "type": "String" } } },
"libraryClearFilter": "Filter zurücksetzen",
"libraryNoAuthorsFound": "Keine Autoren gefunden",
+ "libraryNoNarratorsFound": "Keine Sprecher gefunden",
"libraryNoResults": "Keine Ergebnisse gefunden",
"librarySearchBooks": "Bücher",
"librarySearchShows": "Sendungen",
@@ -112,6 +114,8 @@
"@librarySeriesCount": { "placeholders": { "count": { "type": "int" } } },
"libraryAuthorsCount": "{count} Autoren",
"@libraryAuthorsCount": { "placeholders": { "count": { "type": "int" } } },
+ "libraryNarratorsCount": "{count} Sprecher",
+ "@libraryNarratorsCount": { "placeholders": { "count": { "type": "int" } } },
"libraryBooksCount": "{loaded}/{total} Bücher",
"@libraryBooksCount": { "placeholders": { "loaded": { "type": "int" }, "total": { "type": "int" } } },
@@ -232,10 +236,15 @@
"appShellAbsorbingTab": "Absorbing",
"appShellStatsTab": "Statistiken",
"appShellSettingsTab": "Einstellungen",
+ "appShellDiscoverTab": "Entdecken",
+ "appShellShowsTab": "Sendungen",
"appShellPressBackToExit": "Erneut zurück drücken zum Beenden",
"settingsTitle": "Einstellungen",
"sectionAppearance": "Darstellung",
+ "languageLabel": "Sprache",
+ "languageSystemDefault": "Systemstandard",
+ "languageHelpTranslateInvite": "Möchtest du Absorb in deine Sprache übersetzen?",
"themeLabel": "Theme",
"themeDark": "Dunkel",
"themeOled": "OLED",
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index b4954340..9e7c0a5d 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -91,6 +91,7 @@
"libraryTabLibrary": "Library",
"libraryTabSeries": "Series",
"libraryTabAuthors": "Authors",
+ "libraryTabNarrators": "Narrators",
"libraryNoBooks": "No books found",
"libraryNoBooksInProgress": "No books in progress",
"libraryNoFinishedBooks": "No finished books",
@@ -102,6 +103,7 @@
"@libraryNoBooksInGenre": { "placeholders": { "genre": { "type": "String" } } },
"libraryClearFilter": "Clear filter",
"libraryNoAuthorsFound": "No authors found",
+ "libraryNoNarratorsFound": "No narrators found",
"libraryNoResults": "No results found",
"librarySearchBooks": "Books",
"librarySearchShows": "Shows",
@@ -112,6 +114,8 @@
"@librarySeriesCount": { "placeholders": { "count": { "type": "int" } } },
"libraryAuthorsCount": "{count} authors",
"@libraryAuthorsCount": { "placeholders": { "count": { "type": "int" } } },
+ "libraryNarratorsCount": "{count} narrators",
+ "@libraryNarratorsCount": { "placeholders": { "count": { "type": "int" } } },
"libraryBooksCount": "{loaded}/{total} books",
"@libraryBooksCount": { "placeholders": { "loaded": { "type": "int" }, "total": { "type": "int" } } },
@@ -232,10 +236,15 @@
"appShellAbsorbingTab": "Absorbing",
"appShellStatsTab": "Stats",
"appShellSettingsTab": "Settings",
+ "appShellDiscoverTab": "Discover",
+ "appShellShowsTab": "Shows",
"appShellPressBackToExit": "Press back again to exit",
"settingsTitle": "Settings",
"sectionAppearance": "Appearance",
+ "languageLabel": "Language",
+ "languageSystemDefault": "System default",
+ "languageHelpTranslateInvite": "Want to help translate Absorb into your language?",
"themeLabel": "Theme",
"themeDark": "Dark",
"themeOled": "OLED",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index b444eb3b..dabfe6a5 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -598,6 +598,12 @@ abstract class AppLocalizations {
/// **'Authors'**
String get libraryTabAuthors;
+ /// No description provided for @libraryTabNarrators.
+ ///
+ /// In en, this message translates to:
+ /// **'Narrators'**
+ String get libraryTabNarrators;
+
/// No description provided for @libraryNoBooks.
///
/// In en, this message translates to:
@@ -658,6 +664,12 @@ abstract class AppLocalizations {
/// **'No authors found'**
String get libraryNoAuthorsFound;
+ /// No description provided for @libraryNoNarratorsFound.
+ ///
+ /// In en, this message translates to:
+ /// **'No narrators found'**
+ String get libraryNoNarratorsFound;
+
/// No description provided for @libraryNoResults.
///
/// In en, this message translates to:
@@ -706,6 +718,12 @@ abstract class AppLocalizations {
/// **'{count} authors'**
String libraryAuthorsCount(int count);
+ /// No description provided for @libraryNarratorsCount.
+ ///
+ /// In en, this message translates to:
+ /// **'{count} narrators'**
+ String libraryNarratorsCount(int count);
+
/// No description provided for @libraryBooksCount.
///
/// In en, this message translates to:
@@ -1312,6 +1330,18 @@ abstract class AppLocalizations {
/// **'Settings'**
String get appShellSettingsTab;
+ /// No description provided for @appShellDiscoverTab.
+ ///
+ /// In en, this message translates to:
+ /// **'Discover'**
+ String get appShellDiscoverTab;
+
+ /// No description provided for @appShellShowsTab.
+ ///
+ /// In en, this message translates to:
+ /// **'Shows'**
+ String get appShellShowsTab;
+
/// No description provided for @appShellPressBackToExit.
///
/// In en, this message translates to:
@@ -1330,6 +1360,24 @@ abstract class AppLocalizations {
/// **'Appearance'**
String get sectionAppearance;
+ /// No description provided for @languageLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Language'**
+ String get languageLabel;
+
+ /// No description provided for @languageSystemDefault.
+ ///
+ /// In en, this message translates to:
+ /// **'System default'**
+ String get languageSystemDefault;
+
+ /// No description provided for @languageHelpTranslateInvite.
+ ///
+ /// In en, this message translates to:
+ /// **'Want to help translate Absorb into your language?'**
+ String get languageHelpTranslateInvite;
+
/// No description provided for @themeLabel.
///
/// In en, this message translates to:
@@ -3754,12 +3802,6 @@ abstract class AppLocalizations {
/// **'Year'**
String get yearLabel;
- /// No description provided for @languageLabel.
- ///
- /// In en, this message translates to:
- /// **'Language'**
- String get languageLabel;
-
/// No description provided for @genresLabel.
///
/// In en, this message translates to:
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index 123157c9..a9daabc0 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -273,6 +273,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get libraryTabAuthors => 'Autoren';
+ @override
+ String get libraryTabNarrators => 'Sprecher';
+
@override
String get libraryNoBooks => 'Keine Bücher gefunden';
@@ -305,6 +308,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get libraryNoAuthorsFound => 'Keine Autoren gefunden';
+ @override
+ String get libraryNoNarratorsFound => 'Keine Sprecher gefunden';
+
@override
String get libraryNoResults => 'Keine Ergebnisse gefunden';
@@ -333,6 +339,11 @@ class AppLocalizationsDe extends AppLocalizations {
return '$count Autoren';
}
+ @override
+ String libraryNarratorsCount(int count) {
+ return '$count Sprecher';
+ }
+
@override
String libraryBooksCount(int loaded, int total) {
return '$loaded/$total Bücher';
@@ -667,6 +678,12 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get appShellSettingsTab => 'Einstellungen';
+ @override
+ String get appShellDiscoverTab => 'Entdecken';
+
+ @override
+ String get appShellShowsTab => 'Sendungen';
+
@override
String get appShellPressBackToExit => 'Erneut zurück drücken zum Beenden';
@@ -676,6 +693,16 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get sectionAppearance => 'Darstellung';
+ @override
+ String get languageLabel => 'Sprache';
+
+ @override
+ String get languageSystemDefault => 'Systemstandard';
+
+ @override
+ String get languageHelpTranslateInvite =>
+ 'Möchtest du Absorb in deine Sprache übersetzen?';
+
@override
String get themeLabel => 'Theme';
@@ -2059,9 +2086,6 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get yearLabel => 'Jahr';
- @override
- String get languageLabel => 'Sprache';
-
@override
String get genresLabel => 'Genres';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index ae466e84..9558d88c 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -270,6 +270,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get libraryTabAuthors => 'Authors';
+ @override
+ String get libraryTabNarrators => 'Narrators';
+
@override
String get libraryNoBooks => 'No books found';
@@ -302,6 +305,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get libraryNoAuthorsFound => 'No authors found';
+ @override
+ String get libraryNoNarratorsFound => 'No narrators found';
+
@override
String get libraryNoResults => 'No results found';
@@ -330,6 +336,11 @@ class AppLocalizationsEn extends AppLocalizations {
return '$count authors';
}
+ @override
+ String libraryNarratorsCount(int count) {
+ return '$count narrators';
+ }
+
@override
String libraryBooksCount(int loaded, int total) {
return '$loaded/$total books';
@@ -662,6 +673,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get appShellSettingsTab => 'Settings';
+ @override
+ String get appShellDiscoverTab => 'Discover';
+
+ @override
+ String get appShellShowsTab => 'Shows';
+
@override
String get appShellPressBackToExit => 'Press back again to exit';
@@ -671,6 +688,16 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get sectionAppearance => 'Appearance';
+ @override
+ String get languageLabel => 'Language';
+
+ @override
+ String get languageSystemDefault => 'System default';
+
+ @override
+ String get languageHelpTranslateInvite =>
+ 'Want to help translate Absorb into your language?';
+
@override
String get themeLabel => 'Theme';
@@ -2035,9 +2062,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get yearLabel => 'Year';
- @override
- String get languageLabel => 'Language';
-
@override
String get genresLabel => 'Genres';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index 7982134c..cf353aa1 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -265,6 +265,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get libraryTabAuthors => '作者';
+ @override
+ String get libraryTabNarrators => '旁白';
+
@override
String get libraryNoBooks => '未找到书籍';
@@ -297,6 +300,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get libraryNoAuthorsFound => '未找到作者';
+ @override
+ String get libraryNoNarratorsFound => '未找到旁白';
+
@override
String get libraryNoResults => '未找到结果';
@@ -325,6 +331,11 @@ class AppLocalizationsZh extends AppLocalizations {
return '$count 位作者';
}
+ @override
+ String libraryNarratorsCount(int count) {
+ return '$count 位旁白';
+ }
+
@override
String libraryBooksCount(int loaded, int total) {
return '已加载 $loaded/$total 本书';
@@ -652,6 +663,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get appShellSettingsTab => '设置';
+ @override
+ String get appShellDiscoverTab => '发现';
+
+ @override
+ String get appShellShowsTab => '节目';
+
@override
String get appShellPressBackToExit => '再按一次返回键退出';
@@ -661,6 +678,15 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get sectionAppearance => '外观';
+ @override
+ String get languageLabel => '语言';
+
+ @override
+ String get languageSystemDefault => '跟随系统';
+
+ @override
+ String get languageHelpTranslateInvite => '想帮 Absorb 翻译成你的语言吗?';
+
@override
String get themeLabel => '主题';
@@ -1964,9 +1990,6 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get yearLabel => '年份';
- @override
- String get languageLabel => '语言';
-
@override
String get genresLabel => '分类';
diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb
index 4c7f64a9..99bc0c37 100644
--- a/lib/l10n/app_zh.arb
+++ b/lib/l10n/app_zh.arb
@@ -91,6 +91,7 @@
"libraryTabLibrary": "媒体库",
"libraryTabSeries": "系列",
"libraryTabAuthors": "作者",
+ "libraryTabNarrators": "旁白",
"libraryNoBooks": "未找到书籍",
"libraryNoBooksInProgress": "暂无进行中的书籍",
"libraryNoFinishedBooks": "暂无已完成书籍",
@@ -102,6 +103,7 @@
"@libraryNoBooksInGenre": { "placeholders": { "genre": { "type": "String" } } },
"libraryClearFilter": "清除筛选",
"libraryNoAuthorsFound": "未找到作者",
+ "libraryNoNarratorsFound": "未找到旁白",
"libraryNoResults": "未找到结果",
"librarySearchBooks": "书籍",
"librarySearchShows": "播客",
@@ -112,6 +114,8 @@
"@librarySeriesCount": { "placeholders": { "count": { "type": "int" } } },
"libraryAuthorsCount": "{count} 位作者",
"@libraryAuthorsCount": { "placeholders": { "count": { "type": "int" } } },
+ "libraryNarratorsCount": "{count} 位旁白",
+ "@libraryNarratorsCount": { "placeholders": { "count": { "type": "int" } } },
"libraryBooksCount": "已加载 {loaded}/{total} 本书",
"@libraryBooksCount": { "placeholders": { "loaded": { "type": "int" }, "total": { "type": "int" } } },
@@ -232,10 +236,15 @@
"appShellAbsorbingTab": "正在收听",
"appShellStatsTab": "统计",
"appShellSettingsTab": "设置",
+ "appShellDiscoverTab": "发现",
+ "appShellShowsTab": "节目",
"appShellPressBackToExit": "再按一次返回键退出",
"settingsTitle": "设置",
"sectionAppearance": "外观",
+ "languageLabel": "语言",
+ "languageSystemDefault": "跟随系统",
+ "languageHelpTranslateInvite": "想帮 Absorb 翻译成你的语言吗?",
"themeLabel": "主题",
"themeDark": "深色",
"themeOled": "OLED",
diff --git a/lib/main.dart b/lib/main.dart
index f40ebaf4..1bdc8318 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -39,6 +39,9 @@ final ValueNotifier<bool> oledNotifier = ValueNotifier(false);
/// Whether to disable the fade animation when switching bottom nav tabs.
final ValueNotifier<bool> snappyTransitionsNotifier = ValueNotifier(false);
+/// User-selected language override. null means follow the system language.
+final ValueNotifier<Locale?> localeNotifier = ValueNotifier(null);
+
/// Cover-art-derived ColorScheme for the currently playing item.
/// null when nothing is playing or cover hasn't loaded yet.
@@ -117,6 +120,8 @@ void main() async {
try {
final savedTheme = await PlayerSettings.getThemeMode();
applyThemeMode(savedTheme);
+ final savedLang = await PlayerSettings.getLanguage();
+ if (savedLang.isNotEmpty) localeNotifier.value = Locale(savedLang);
snappyTransitionsNotifier.value = await PlayerSettings.getSnappyTransitions();
PlayerSettings.showExplicitBadge = await PlayerSettings.getShowExplicitBadge();
// Restore last cover seed color so the theme doesn't flash on startup
@@ -180,6 +185,9 @@ class AbsorbApp extends StatelessWidget {
return ValueListenableBuilder<bool>(
valueListenable: oledNotifier,
builder: (context, isOled, _) {
+ return ValueListenableBuilder<Locale?>(
+ valueListenable: localeNotifier,
+ builder: (context, overrideLocale, _) {
return ValueListenableBuilder<ColorScheme?>(
valueListenable: coverSchemeNotifier,
builder: (context, coverScheme, _) {
@@ -230,6 +238,7 @@ class AbsorbApp extends StatelessWidget {
navigatorKey: rootNavigatorKey,
title: 'Absorb',
debugShowCheckedModeBanner: false,
+ locale: overrideLocale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
localeResolutionCallback: (locale, supportedLocales) {
@@ -359,6 +368,8 @@ class AbsorbApp extends StatelessWidget {
);
},
);
+ },
+ );
},
);
}
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index 86fdf986..52fde066 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -904,10 +904,10 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: SegmentedButton<String>(
segments: [
- ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 16), label: Text(l.queueModeOff)),
- ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 16), label: Text(l.queueModeManual)),
+ ButtonSegment(value: 'off', icon: const Icon(Icons.stop_rounded, size: 16), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeOff, maxLines: 1))),
+ ButtonSegment(value: 'manual', icon: const Icon(Icons.queue_music_rounded, size: 16), label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.queueModeManual, maxLines: 1))),
ButtonSegment(value: 'auto_next', icon: const Icon(Icons.skip_next_rounded, size: 16),
- label: Text(widget.isMerged ? l.queueModeAuto : widget.isPodcast ? l.queueModeShowLabel : l.queueModeSeriesLabel)),
+ label: FittedBox(fit: BoxFit.scaleDown, child: Text(widget.isMerged ? l.queueModeAuto : widget.isPodcast ? l.queueModeShowLabel : l.queueModeSeriesLabel, maxLines: 1))),
],
selected: {_queueMode},
onSelectionChanged: (v) {
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index 1de211bd..a71d0b40 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -593,12 +593,12 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
NavigationDestination(
icon: Icon(isPodcast ? Icons.explore_outlined : Icons.home_outlined),
selectedIcon: Icon(isPodcast ? Icons.explore_rounded : Icons.home_rounded),
- label: isPodcast ? 'Discover' : l.appShellHomeTab,
+ label: isPodcast ? l.appShellDiscoverTab : l.appShellHomeTab,
),
NavigationDestination(
icon: Icon(isPodcast ? Icons.podcasts_outlined : Icons.library_books_outlined),
selectedIcon: Icon(isPodcast ? Icons.podcasts_rounded : Icons.library_books_rounded),
- label: isPodcast ? 'Shows' : l.appShellLibraryTab,
+ label: isPodcast ? l.appShellShowsTab : l.appShellLibraryTab,
),
NavigationDestination(
icon: const _AnimatedWaveIcon(size: 24, active: false),
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index e21dc8d4..44610e33 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -21,6 +21,7 @@ import '../widgets/collection_detail_sheet.dart';
import '../widgets/section_detail_sheet.dart';
import '../widgets/feature_hint.dart';
import '../widgets/offline_status_icon.dart';
+import '../widgets/section_labels.dart';
import 'app_shell.dart';
import '../l10n/app_localizations.dart';
@@ -297,19 +298,6 @@ class HomeScreenState extends State<HomeScreen> {
);
}
- String _sectionLabel(String id, AppLocalizations l) {
- switch (id) {
- case 'continue-listening': return l.continueListening;
- case 'continue-series': return l.continueSeries;
- case 'recently-added': return l.recentlyAdded;
- case 'listen-again': return l.listenAgain;
- case 'discover': return l.discover;
- case 'episodes-recently-added': return l.newEpisodes;
- case 'downloaded-books': return l.downloads;
- }
- return _titleCase(id);
- }
-
static const _sectionIcons = {
'continue-listening': Icons.play_circle_outline_rounded,
'continue-series': Icons.auto_stories_rounded,
@@ -320,14 +308,6 @@ class HomeScreenState extends State<HomeScreen> {
'downloaded-books': Icons.download_done_rounded,
};
- String _titleCase(String s) {
- return s
- .replaceAll('-', ' ')
- .split(' ')
- .map((w) => w.isEmpty ? w : '${w[0].toUpperCase()}${w.substring(1)}')
- .join(' ');
- }
-
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
@@ -616,7 +596,7 @@ class HomeScreenState extends State<HomeScreen> {
];
}
- final label = section['label'] ?? _sectionLabel(id, l);
+ final label = sectionLabel(id, section['label'] as String?, l);
final entities = _filterEbookOnly(
(section['entities'] as List<dynamic>?) ?? [],
sectionType: section['type'] as String?);
diff --git a/lib/screens/library_screen.dart b/lib/screens/library_screen.dart
index 918b6c95..f2d9e8a4 100644
--- a/lib/screens/library_screen.dart
+++ b/lib/screens/library_screen.dart
@@ -17,6 +17,7 @@ import '../widgets/library_sort_filter_sheet.dart';
import '../widgets/library_books_tab.dart';
import '../widgets/library_series_tab.dart';
import '../widgets/library_authors_tab.dart';
+import '../widgets/library_narrators_tab.dart';
import 'admin_podcasts_screen.dart';
import 'upcoming_releases_screen.dart';
import '../widgets/audible_series_sheet.dart' show showAudibleRegionPicker;
@@ -30,6 +31,14 @@ int responsiveGridCount(BuildContext context) {
return (width / 130).floor().clamp(3, 10);
}
+/// Bottom padding for the library tab grids/lists so the last row clears the
+/// floating tab bar (`Library/Series/Authors/Narrators`) plus the AppShell
+/// `NavigationBar` once both reappear at the end of a scroll. When the bars
+/// hide-on-scroll then snap back, the viewport shrinks but the scroll offset
+/// stays put, so the bottom items end up closer to the pill than steady-state
+/// math would suggest. This value keeps a comfortable gap even in that case.
+const double libraryGridBottomPadding = 180;
+
// ─── Sort modes ──────────────────────────────────────────────
enum LibrarySort { recentlyAdded, alphabetical, authorName, publishedYear, duration, random, totalDuration }
@@ -130,6 +139,14 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
bool _authorSortAsc = true;
final _authorsScrollController = ScrollController();
+ // ── Narrators tab state ──
+ List<String> _narrators = [];
+ bool _isLoadingNarrators = false;
+ bool _narratorsLoaded = false;
+ LibrarySort _narratorSort = LibrarySort.alphabetical;
+ bool _narratorSortAsc = true;
+ final _narratorsScrollController = ScrollController();
+
// ── Cover aspect ratio ──
bool _rectangleCovers = false;
double get _coverAspectRatio => _rectangleCovers ? 2 / 3 : 1.0;
@@ -199,6 +216,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_scrollController.addListener(_onScroll);
_seriesScrollController.addListener(_onSeriesScroll);
_authorsScrollController.addListener(_onAuthorsScroll);
+ _narratorsScrollController.addListener(_onNarratorsScroll);
// Load initial page once the library is ready
WidgetsBinding.instance.addPostFrameCallback((_) {
_initTabController();
@@ -209,7 +227,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
void _initTabController() {
final lib = context.read<LibraryProvider>();
if (!lib.isPodcastLibrary) {
- _tabController = TabController(length: 3, vsync: this);
+ _tabController = TabController(length: 4, vsync: this);
_tabController!.addListener(_onTabChanged);
}
}
@@ -228,6 +246,8 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_loadSeriesPage();
} else if (newTab == 2 && !_authorsLoaded && !_isLoadingAuthors) {
_loadAuthors();
+ } else if (newTab == 3 && !_narratorsLoaded && !_isLoadingNarrators) {
+ _loadNarrators();
}
}
@@ -245,7 +265,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_tabController?.removeListener(_onTabChanged);
_tabController?.dispose();
if (needsTabs) {
- _tabController = TabController(length: 3, vsync: this);
+ _tabController = TabController(length: 4, vsync: this);
_tabController!.addListener(_onTabChanged);
} else {
_tabController = null;
@@ -268,10 +288,14 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_authors.clear();
_authorsLoaded = false;
_isLoadingAuthors = false;
+ _narrators.clear();
+ _narratorsLoaded = false;
+ _isLoadingNarrators = false;
});
if (_scrollController.hasClients) _scrollController.jumpTo(0);
if (_seriesScrollController.hasClients) _seriesScrollController.jumpTo(0);
if (_authorsScrollController.hasClients) _authorsScrollController.jumpTo(0);
+ if (_narratorsScrollController.hasClients) _narratorsScrollController.jumpTo(0);
_lastScrollOffset = 0;
_showBars();
// Restore sort/filter for the new library type, then load
@@ -320,6 +344,8 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
PlayerSettings.getPodcastSort(),
PlayerSettings.getPodcastSortAsc(),
PlayerSettings.getLibraryTab(),
+ PlayerSettings.getNarratorSort(),
+ PlayerSettings.getNarratorSortAsc(),
]);
if (!mounted) return;
final sortName = results[0] as String;
@@ -333,6 +359,8 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
final podcastSortName = results[8] as String;
final podcastSortAsc = results[9] as bool;
final savedTab = results[10] as int;
+ final narratorSortName = results[11] as String;
+ final narratorSortAsc = results[12] as bool;
final isPodcast = context.read<LibraryProvider>().isPodcastLibrary;
setState(() {
// Book library sort/filter
@@ -357,6 +385,11 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
orElse: () => LibrarySort.alphabetical,
);
_authorSortAsc = authorSortAsc;
+ _narratorSort = LibrarySort.values.firstWhere(
+ (s) => s.name == narratorSortName,
+ orElse: () => LibrarySort.alphabetical,
+ );
+ _narratorSortAsc = narratorSortAsc;
// Podcast sort
_podcastSort = LibrarySort.values.firstWhere(
(s) => s.name == podcastSortName,
@@ -371,7 +404,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_genreFilter = null;
}
// Restore last active tab (only for book libraries with tabs)
- if (!isPodcast && savedTab > 0 && savedTab < 3) {
+ if (!isPodcast && savedTab > 0 && savedTab < 4) {
_currentTab = savedTab;
_tabController?.animateTo(savedTab);
}
@@ -381,6 +414,8 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_loadSeriesPage();
} else if (!isPodcast && savedTab == 2 && !_authorsLoaded && !_isLoadingAuthors) {
_loadAuthors();
+ } else if (!isPodcast && savedTab == 3 && !_narratorsLoaded && !_isLoadingNarrators) {
+ _loadNarrators();
}
}
@@ -446,6 +481,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_scrollController.dispose();
_seriesScrollController.dispose();
_authorsScrollController.dispose();
+ _narratorsScrollController.dispose();
_headerAnimController.dispose();
barsVisibleNotifier.dispose();
_tabController?.removeListener(_onTabChanged);
@@ -481,6 +517,10 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_onScrollDirection(_authorsScrollController);
}
+ void _onNarratorsScroll() {
+ _onScrollDirection(_narratorsScrollController);
+ }
+
// ══════════════════════════════════════════════════════════════
// LIBRARY TAB - Load a page of items
// ══════════════════════════════════════════════════════════════
@@ -826,10 +866,42 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
});
}
+ Future<void> _loadNarrators() async {
+ if (_isLoadingNarrators) return;
+ setState(() => _isLoadingNarrators = true);
+
+ final auth = context.read<AuthProvider>();
+ final lib = context.read<LibraryProvider>();
+ final api = auth.apiService;
+ if (api == null || lib.selectedLibraryId == null) {
+ setState(() { _isLoadingNarrators = false; _narratorsLoaded = true; });
+ return;
+ }
+
+ final narrators = await api.getLibraryNarrators(lib.selectedLibraryId!);
+ if (mounted) {
+ setState(() {
+ _narrators = narrators;
+ _sortNarrators();
+ _isLoadingNarrators = false;
+ _narratorsLoaded = true;
+ });
+ }
+ }
+
+ void _sortNarrators() {
+ _narrators.sort((a, b) {
+ final aLower = a.toLowerCase();
+ final bLower = b.toLowerCase();
+ return _narratorSortAsc ? aLower.compareTo(bLower) : bLower.compareTo(aLower);
+ });
+ }
+
// ── Change sort and reload ──
void _changeSort(LibrarySort newSort) {
if (_currentTab == 1) { _changeSeriesSort(newSort); return; }
if (_currentTab == 2) { _changeAuthorSort(newSort); return; }
+ if (_currentTab == 3) { _changeNarratorSort(newSort); return; }
final isPodcast = context.read<LibraryProvider>().isPodcastLibrary;
if (newSort == _sort) {
@@ -913,6 +985,21 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
if (_authorsScrollController.hasClients) _authorsScrollController.jumpTo(0);
}
+ void _changeNarratorSort(LibrarySort newSort) {
+ if (newSort == _narratorSort) {
+ setState(() { _narratorSortAsc = !_narratorSortAsc; });
+ } else {
+ setState(() {
+ _narratorSort = newSort;
+ _narratorSortAsc = true;
+ });
+ }
+ PlayerSettings.setNarratorSort(_narratorSort.name);
+ PlayerSettings.setNarratorSortAsc(_narratorSortAsc);
+ setState(() => _sortNarrators());
+ if (_narratorsScrollController.hasClients) _narratorsScrollController.jumpTo(0);
+ }
+
// ── Change filter and reload ──
void _changeFilter(LibraryFilter newFilter, {String? genre}) {
final effective = (newFilter == _filter && genre == _genreFilter) ? LibraryFilter.none : newFilter;
@@ -1127,6 +1214,11 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
currentSort = _authorSort;
currentSortAsc = _authorSortAsc;
break;
+ case 3:
+ tab = LibraryTab.narrators;
+ currentSort = _narratorSort;
+ currentSortAsc = _narratorSortAsc;
+ break;
default:
tab = LibraryTab.library;
currentSort = _sort;
@@ -1158,6 +1250,10 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
setState(() { _authorSortAsc = !_authorSortAsc; _sortAuthors(); });
PlayerSettings.setAuthorSortAsc(_authorSortAsc);
if (_authorsScrollController.hasClients) _authorsScrollController.jumpTo(0);
+ } else if (_currentTab == 3) {
+ setState(() { _narratorSortAsc = !_narratorSortAsc; _sortNarrators(); });
+ PlayerSettings.setNarratorSortAsc(_narratorSortAsc);
+ if (_narratorsScrollController.hasClients) _narratorsScrollController.jumpTo(0);
} else {
setState(() { _sortAsc = !_sortAsc; _items.clear(); _page = 0; _hasMore = true; _isLoadingPage = false; });
final isPodcast = context.read<LibraryProvider>().isPodcastLibrary;
@@ -1396,7 +1492,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
Widget _buildFloatingTabBar(ColorScheme cs) {
final l = AppLocalizations.of(context)!;
- final labels = [l.libraryTabLibrary, l.libraryTabSeries, l.libraryTabAuthors];
+ final labels = [l.libraryTabLibrary, l.libraryTabSeries, l.libraryTabAuthors, l.libraryTabNarrators];
return Center(child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
@@ -1410,7 +1506,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
),
child: Row(
mainAxisSize: MainAxisSize.min,
- children: List.generate(3, (i) {
+ children: List.generate(labels.length, (i) {
final active = _currentTab == i;
return GestureDetector(
onTap: () {
@@ -1423,7 +1519,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
- padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8),
+ padding: EdgeInsets.symmetric(horizontal: active ? 14 : 12, vertical: 8),
decoration: BoxDecoration(
color: active ? cs.primary.withValues(alpha: 0.15) : Colors.transparent,
borderRadius: BorderRadius.circular(20),
@@ -1540,6 +1636,9 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
case 2:
countText = l.libraryAuthorsCount(_authors.length);
break;
+ case 3:
+ countText = l.libraryNarratorsCount(_narrators.length);
+ break;
default:
countText = l.libraryBooksCount(_items.length, _totalItems);
break;
@@ -1588,6 +1687,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
_buildGrid(),
_buildSeriesGrid(),
_buildAuthorsGrid(),
+ _buildNarratorsGrid(),
],
);
}
@@ -1672,6 +1772,28 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi
);
}
+ // ═══════════════════════════════════════════════════════════════
+ // NARRATORS TAB - GRID
+ // ═══════════════════════════════════════════════════════════════
+ Future<void> _refreshNarrators() async {
+ setState(() {
+ _narrators.clear();
+ _narratorsLoaded = false;
+ _isLoadingNarrators = false;
+ });
+ await _loadNarrators();
+ }
+
+ Widget _buildNarratorsGrid() {
+ return LibraryNarratorsTab(
+ narrators: _narrators,
+ isLoading: _isLoadingNarrators,
+ loaded: _narratorsLoaded,
+ scrollController: _narratorsScrollController,
+ onRefresh: _refreshNarrators,
+ );
+ }
+
// ═══════════════════════════════════════════════════════════════
// SEARCH RESULTS
// ═══════════════════════════════════════════════════════════════
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 7bf09e36..6a400473 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -24,7 +24,7 @@ import '../screens/admin_screen.dart';
import '../screens/admin_rmab_screen.dart';
import '../screens/downloads_screen.dart';
import '../screens/bookmarks_screen.dart';
-import '../main.dart' show applyThemeMode, applyTrustAllCerts, oledNotifier, snappyTransitionsNotifier;
+import '../main.dart' show applyThemeMode, applyTrustAllCerts, localeNotifier, oledNotifier, snappyTransitionsNotifier;
import '../widgets/absorb_page_header.dart';
import '../widgets/absorb_slider.dart';
import '../widgets/collapsible_section.dart';
@@ -87,6 +87,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool _rectangleCovers = false;
bool _coverPlayButton = false;
String _themeMode = 'dark';
+ String _language = '';
int _startScreen = 2;
int _streamingCacheSizeMb = 0;
bool _localServerEnabled = false;
@@ -203,6 +204,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.getSleepChime(), // 46
PlayerSettings.getSleepChimeVolume(), // 47
PlayerSettings.getShakeSensitivity(), // 48
+ PlayerSettings.getLanguage(), // 49
]);
final s = results[0] as AutoRewindSettings;
final speed = results[1] as double;
@@ -250,6 +252,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
final chime = results[43] as bool;
final chimeVol = results[44] as double;
final shakeSens = results[45] as String;
+ final language = results[46] as String;
final rmabUrl = await ScopedPrefs.getString('rmab_url');
if (mounted) setState(() {
_rmabUrl = rmabUrl;
@@ -303,6 +306,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_sleepChime = chime;
_sleepChimeVolume = chimeVol;
_shakeSensitivity = shakeSens;
+ _language = language;
_canPickDownloadLocation = !_isPlayStoreBuild;
_loaded = true;
@@ -330,6 +334,84 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
}
+ /// Display name for a language code, in that language's own script.
+ /// Empty string => "System default" in the active locale.
+ String _languageDisplayName(String code, AppLocalizations l) {
+ switch (code) {
+ case 'en': return 'English';
+ case 'de': return 'Deutsch';
+ case 'zh': return '中文';
+ default: return l.languageSystemDefault;
+ }
+ }
+
+ Future<void> _pickLanguage() async {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ final l = AppLocalizations.of(context)!;
+ const codes = ['', 'en', 'de', 'zh'];
+
+ final picked = await showModalBottomSheet<String>(
+ context: context,
+ isScrollControlled: true,
+ useSafeArea: true,
+ backgroundColor: cs.surfaceContainerLow,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
+ ),
+ builder: (ctx) => SafeArea(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 8),
+ Container(
+ width: 40, height: 4,
+ decoration: BoxDecoration(
+ color: cs.onSurface.withValues(alpha: 0.24),
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ const SizedBox(height: 16),
+ Text(l.languageLabel,
+ style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600)),
+ const SizedBox(height: 8),
+ for (final code in codes)
+ RadioListTile<String>(
+ value: code,
+ groupValue: _language,
+ onChanged: (v) => Navigator.pop(ctx, v),
+ title: Text(_languageDisplayName(code, l)),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 8, 20, 16),
+ // TODO: when Crowdin is set up, swap this URL for the Crowdin project link.
+ child: InkWell(
+ onTap: () => launchUrl(
+ Uri.parse('https://github.com/pounat/absorb/issues/188'),
+ mode: LaunchMode.externalApplication,
+ ),
+ child: Text(
+ l.languageHelpTranslateInvite,
+ style: tt.bodySmall?.copyWith(
+ color: cs.primary,
+ decoration: TextDecoration.underline,
+ decorationColor: cs.primary.withValues(alpha: 0.6),
+ ),
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+
+ if (picked == null || picked == _language) return;
+ setState(() => _language = picked);
+ await PlayerSettings.setLanguage(picked);
+ localeNotifier.value = picked.isEmpty ? null : Locale(picked);
+ }
+
Widget _infoIcon(String title, String content) {
final cs = Theme.of(context).colorScheme;
final l = AppLocalizations.of(context)!;
@@ -532,6 +614,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
isExpanded: _expandedSection == 'Appearance',
onExpansionChanged: (v) => _onSectionExpanded('Appearance', v),
children: [
+ InkWell(
+ onTap: _loaded ? () => _pickLanguage() : null,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 14),
+ child: Row(
+ children: [
+ Expanded(child: Text(l.languageLabel, style: tt.titleSmall)),
+ Text(
+ _languageDisplayName(_language, l),
+ style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant),
+ ),
+ Icon(Icons.chevron_right_rounded,
+ color: cs.onSurfaceVariant.withValues(alpha: 0.5)),
+ ],
+ ),
+ ),
+ ),
+ const Divider(height: 1, indent: 16, endIndent: 16),
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
child: Column(
@@ -544,10 +644,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
child: SegmentedButton<String>(
showSelectedIcon: false,
segments: [
- ButtonSegment(value: 'dark', label: Text(l.themeDark)),
- ButtonSegment(value: 'oled', label: Text(l.themeOled)),
- ButtonSegment(value: 'light', label: Text(l.themeLight)),
- ButtonSegment(value: 'system', label: Text(l.themeAuto)),
+ ButtonSegment(value: 'dark', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.themeDark, maxLines: 1))),
+ ButtonSegment(value: 'oled', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.themeOled, maxLines: 1))),
+ ButtonSegment(value: 'light', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.themeLight, maxLines: 1))),
+ ButtonSegment(value: 'system', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.themeAuto, maxLines: 1))),
],
selected: {_themeMode},
onSelectionChanged: _loaded ? (selected) {
@@ -582,10 +682,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
child: SegmentedButton<int>(
showSelectedIcon: false,
segments: [
- ButtonSegment(value: 0, label: Text(l.startScreenHome)),
- ButtonSegment(value: 1, label: Text(l.startScreenLibrary)),
- ButtonSegment(value: 2, label: Text(l.startScreenAbsorb)),
- ButtonSegment(value: 3, label: Text(l.startScreenStats)),
+ ButtonSegment(value: 0, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.startScreenHome, maxLines: 1))),
+ ButtonSegment(value: 1, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.startScreenLibrary, maxLines: 1))),
+ ButtonSegment(value: 2, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.startScreenAbsorb, maxLines: 1))),
+ ButtonSegment(value: 3, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.startScreenStats, maxLines: 1))),
],
selected: {_startScreen},
onSelectionChanged: _loaded ? (selected) {
diff --git a/lib/services/api_service.dart b/lib/services/api_service.dart
index bda7e2f9..6f43c9b7 100644
--- a/lib/services/api_service.dart
+++ b/lib/services/api_service.dart
@@ -536,6 +536,48 @@ class ApiService {
return [];
}
+ /// Get all narrators for a library. ABS exposes narrators only via the
+ /// filterdata endpoint as a list of name strings (no IDs/images/bios).
+ Future<List<String>> getLibraryNarrators(String libraryId) async {
+ try {
+ final data = await getLibraryFilterData(libraryId);
+ if (data == null) return [];
+ final raw = data['narrators'] as List<dynamic>? ?? [];
+ return raw
+ .map((e) => e?.toString() ?? '')
+ .where((s) => s.isNotEmpty)
+ .toList();
+ } catch (e) {
+ debugPrint('[API] getLibraryNarrators error: $e');
+ }
+ return [];
+ }
+
+ /// Get books narrated by a specific person.
+ /// Filter format: narrators.<base64(name)>
+ Future<List<dynamic>> getBooksByNarrator(
+ String libraryId,
+ String narratorName, {
+ int limit = 50,
+ }) async {
+ try {
+ final filterValue = base64Encode(utf8.encode(narratorName));
+ final url = '$_cleanBaseUrl/api/libraries/$libraryId/items'
+ '?filter=narrators.$filterValue&sort=media.metadata.title&limit=$limit';
+ final response = await _authGet(
+ Uri.parse(url),
+ );
+
+ if (response.statusCode == 200) {
+ final data = jsonDecode(response.body) as Map<String, dynamic>;
+ return data['results'] as List<dynamic>? ?? [];
+ }
+ } catch (e) {
+ debugPrint('[API] getBooksByNarrator error: $e');
+ }
+ return [];
+ }
+
/// Get full author details including description/bio.
Future<Map<String, dynamic>?> getAuthorById(String authorId, {String? libraryId}) async {
try {
diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dart
index 9aea9b73..55c7fdd8 100644
--- a/lib/services/player_settings.dart
+++ b/lib/services/player_settings.dart
@@ -332,6 +332,12 @@ class PlayerSettings {
static Future<bool> getAuthorSortAsc() => _get('authorSortAsc', true);
static Future<void> setAuthorSortAsc(bool value) => _set('authorSortAsc', value);
+ static Future<String> getNarratorSort() => _get('narratorSort', 'alphabetical');
+ static Future<void> setNarratorSort(String value) => _set('narratorSort', value);
+
+ static Future<bool> getNarratorSortAsc() => _get('narratorSortAsc', true);
+ static Future<void> setNarratorSortAsc(bool value) => _set('narratorSortAsc', value);
+
static Future<bool> getShowGoodreadsButton() => _get('showGoodreadsButton', false);
static Future<void> setShowGoodreadsButton(bool value) => _set('showGoodreadsButton', value);
@@ -461,6 +467,19 @@ class PlayerSettings {
static Future<String> getThemeMode() => _get('themeMode', 'dark');
static Future<void> setThemeMode(String value) => _set('themeMode', value);
+ /// Language override. Empty string means follow the system language.
+ /// Otherwise an ISO 639-1 code matching a supported locale (e.g. 'en', 'de', 'zh').
+ /// Stored globally (not per-user) so it persists across cold start before any
+ /// account scope is active — and so all profiles on the device share one UI language.
+ static Future<String> getLanguage() async {
+ final prefs = await SharedPreferences.getInstance();
+ return prefs.getString('language') ?? '';
+ }
+ static Future<void> setLanguage(String value) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setString('language', value);
+ }
+
static Future<String> getColorSource() => _get('colorSource', 'default');
static Future<void> setColorSource(String value) => _set('colorSource', value);
diff --git a/lib/widgets/absorbing_shared.dart b/lib/widgets/absorbing_shared.dart
index 3ca2aaf3..76f0944e 100644
--- a/lib/widgets/absorbing_shared.dart
+++ b/lib/widgets/absorbing_shared.dart
@@ -99,20 +99,25 @@ class CoverPlaceholder extends StatelessWidget {
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.auto_stories_rounded, size: 28,
color: cs.onPrimaryContainer.withValues(alpha: 0.4)),
const SizedBox(height: 8),
- Text(title!, textAlign: TextAlign.center, maxLines: 4,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600,
- height: 1.2, color: cs.onPrimaryContainer)),
+ Flexible(
+ child: Text(title!, textAlign: TextAlign.center, maxLines: 3,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600,
+ height: 1.2, color: cs.onPrimaryContainer)),
+ ),
if (author != null && author!.isNotEmpty) ...[
const SizedBox(height: 4),
- Text(author!, textAlign: TextAlign.center, maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 11,
- color: cs.onPrimaryContainer.withValues(alpha: 0.7))),
+ Flexible(
+ child: Text(author!, textAlign: TextAlign.center, maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(fontSize: 11,
+ color: cs.onPrimaryContainer.withValues(alpha: 0.7))),
+ ),
],
],
),
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 4fc5228b..815f5cab 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -28,6 +28,7 @@ import '../services/metadata_override_service.dart';
import '../services/scoped_prefs.dart';
import '../screens/app_shell.dart';
import 'author_books_sheet.dart';
+import 'narrator_books_sheet.dart';
import 'series_books_sheet.dart';
import 'absorbing_shared.dart';
import 'html_description.dart';
@@ -70,6 +71,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
bool _showGoodreads = false;
bool _ebookSaved = false;
bool _authorsExpanded = false;
+ bool _narratorsExpanded = false;
bool _squareCovers = false;
ColorScheme? _coverScheme;
String? _coverSchemeUrl; // URL the current scheme was derived from
@@ -338,7 +340,6 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
final chapters = media['chapters'] as List<dynamic>? ?? [];
final title = metadata['title'] as String? ?? l.unknown;
final authorName = metadata['authorName'] as String? ?? '';
- final narrator = metadata['narratorName'] as String? ?? '';
final descRaw = metadata['description'] as String? ?? '';
final duration = (media['duration'] as num?)?.toDouble() ?? 0;
final seriesEntries = metadata['series'] as List<dynamic>? ?? [];
@@ -405,8 +406,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
Text(title, textAlign: TextAlign.center, style: tt.headlineSmall?.copyWith(fontWeight: FontWeight.w700, color: cs.onSurface)),
const SizedBox(height: 4),
_buildAuthorLinks(context, metadata, cs, tt, accent),
- if (narrator.isNotEmpty) ...[const SizedBox(height: 2),
- Text(l.narratedBy(narrator), textAlign: TextAlign.center, style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant))],
+ _buildNarratorLinks(context, metadata, cs, tt, accent),
// ─── AUDIBLE RATING (space always reserved) ─────────
const SizedBox(height: 8),
if (_rating != null && (_rating!['rating'] as num).toDouble() > 0)
@@ -956,6 +956,71 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
);
}
+ Widget _buildNarratorLinks(BuildContext context, Map<String, dynamic> metadata, ColorScheme cs, TextTheme tt, Color accent) {
+ final raw = metadata['narrators'] as List<dynamic>? ?? [];
+ final names = <String>[
+ for (final n in raw)
+ if (n is String && n.trim().isNotEmpty)
+ n.trim()
+ else if (n is Map<String, dynamic>)
+ (n['name'] as String? ?? '').trim()
+ ].where((s) => s.isNotEmpty).toList();
+
+ if (names.isEmpty) {
+ final fallback = (metadata['narratorName'] as String? ?? '').trim();
+ if (fallback.isEmpty) return const SizedBox.shrink();
+ names.addAll(fallback.split(',').map((s) => s.trim()).where((s) => s.isNotEmpty));
+ }
+ if (names.isEmpty) return const SizedBox.shrink();
+
+ final l = AppLocalizations.of(context)!;
+ // Split the localized "Narrated by {narrator}" template so we can prepend
+ // the prefix (and append any suffix, e.g. Chinese colon) around clickable
+ // narrator links.
+ final parts = l.narratedBy('||X||').split('||X||');
+ final prefix = parts.isNotEmpty ? parts[0] : '';
+ final suffix = parts.length > 1 ? parts[1] : '';
+
+ const int collapsedCount = 3;
+ final showAll = _narratorsExpanded || names.length <= collapsedCount;
+ final visible = showAll ? names : names.sublist(0, collapsedCount);
+ final remaining = names.length - collapsedCount;
+
+ final baseStyle = tt.bodySmall?.copyWith(color: cs.onSurfaceVariant);
+ final linkStyle = tt.bodySmall?.copyWith(
+ color: accent,
+ decoration: TextDecoration.underline,
+ decorationColor: accent.withValues(alpha: 0.4),
+ );
+ final commaStyle = tt.bodySmall?.copyWith(color: accent);
+
+ return Padding(
+ padding: const EdgeInsets.only(top: 2),
+ child: Wrap(
+ alignment: WrapAlignment.center,
+ children: [
+ if (prefix.isNotEmpty) Text(prefix, style: baseStyle),
+ for (int i = 0; i < visible.length; i++) ...[
+ GestureDetector(
+ onTap: () => showNarratorBooksSheet(context, narratorName: visible[i]),
+ child: Text(visible[i], style: linkStyle),
+ ),
+ if (i < visible.length - 1 || (!showAll && remaining > 0))
+ Text(', ', style: commaStyle),
+ ],
+ if (!showAll)
+ GestureDetector(
+ onTap: () => setState(() => _narratorsExpanded = true),
+ child: Text(l.andCountMore(remaining), style: tt.bodySmall?.copyWith(
+ color: accent.withValues(alpha: 0.7),
+ )),
+ ),
+ if (suffix.isNotEmpty) Text(suffix, style: baseStyle),
+ ],
+ ),
+ );
+ }
+
Future<void> _openSeries(BuildContext context, String? seriesId, String seriesName) async {
if (seriesId == null) return;
final auth = context.read<AuthProvider>();
diff --git a/lib/widgets/episode_row.dart b/lib/widgets/episode_row.dart
index 39f62a5a..1d67a805 100644
--- a/lib/widgets/episode_row.dart
+++ b/lib/widgets/episode_row.dart
@@ -142,8 +142,11 @@ class _EpisodeRowState extends State<EpisodeRow> {
Row(
children: [
if (dateLabel.isNotEmpty)
- Text(dateLabel,
- style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
+ Flexible(
+ child: Text(dateLabel,
+ maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
+ ),
),
if (dateLabel.isNotEmpty && durationLabel.isNotEmpty)
Padding(
@@ -153,8 +156,11 @@ class _EpisodeRowState extends State<EpisodeRow> {
),
),
if (durationLabel.isNotEmpty)
- Text(durationLabel,
- style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
+ Flexible(
+ child: Text(durationLabel,
+ maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
+ ),
),
ListenableBuilder(
listenable: DownloadService(),
diff --git a/lib/widgets/home_customize_sheet.dart b/lib/widgets/home_customize_sheet.dart
index 7d018732..2cce0578 100644
--- a/lib/widgets/home_customize_sheet.dart
+++ b/lib/widgets/home_customize_sheet.dart
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
+import 'section_labels.dart';
class HomeCustomizeSheet extends StatefulWidget {
final ScrollController? scrollController;
@@ -284,7 +285,7 @@ class _HomeCustomizeSheetState extends State<HomeCustomizeSheet> {
itemBuilder: (context, index) {
final section = _sections[index];
final id = section['id']!;
- final label = section['label']!;
+ final label = sectionLabel(id, section['label'], l);
final isHidden = _hiddenIds.contains(id);
final isPlaylist = id.startsWith('playlist:');
final isCollection = id.startsWith('collection:');
diff --git a/lib/widgets/library_authors_tab.dart b/lib/widgets/library_authors_tab.dart
index 93c4517c..d216dbde 100644
--- a/lib/widgets/library_authors_tab.dart
+++ b/lib/widgets/library_authors_tab.dart
@@ -58,7 +58,7 @@ class LibraryAuthorsTab extends StatelessWidget {
child: GridView.builder(
controller: scrollController,
physics: const AlwaysScrollableScrollPhysics(),
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 100),
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: responsiveGridCount(context),
childAspectRatio: 0.68,
diff --git a/lib/widgets/library_books_tab.dart b/lib/widgets/library_books_tab.dart
index 7f921a31..4113b0bd 100644
--- a/lib/widgets/library_books_tab.dart
+++ b/lib/widgets/library_books_tab.dart
@@ -86,7 +86,7 @@ class LibraryBooksTab extends StatelessWidget {
child: GridView.builder(
controller: scrollController,
physics: const AlwaysScrollableScrollPhysics(),
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 100),
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: responsiveGridCount(context),
childAspectRatio: rectangleCovers ? 0.48 : 0.68,
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index e0482b46..6bd603c4 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -765,3 +765,4 @@ class GridAuthorTile extends StatelessWidget {
);
}
}
+
diff --git a/lib/widgets/library_narrators_tab.dart b/lib/widgets/library_narrators_tab.dart
new file mode 100644
index 00000000..b4b94225
--- /dev/null
+++ b/lib/widgets/library_narrators_tab.dart
@@ -0,0 +1,99 @@
+import 'package:flutter/material.dart';
+import '../l10n/app_localizations.dart';
+import '../screens/library_screen.dart';
+import 'narrator_books_sheet.dart';
+
+class LibraryNarratorsTab extends StatelessWidget {
+ final List<String> narrators;
+ final bool isLoading;
+ final bool loaded;
+ final ScrollController scrollController;
+ final Future<void> Function() onRefresh;
+
+ const LibraryNarratorsTab({
+ super.key,
+ required this.narrators,
+ required this.isLoading,
+ required this.loaded,
+ required this.scrollController,
+ required this.onRefresh,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ final l = AppLocalizations.of(context)!;
+
+ if (isLoading) {
+ return const Center(child: CircularProgressIndicator());
+ }
+ if (narrators.isEmpty && loaded) {
+ return RefreshIndicator(
+ onRefresh: onRefresh,
+ child: CustomScrollView(
+ physics: const AlwaysScrollableScrollPhysics(),
+ slivers: [
+ SliverFillRemaining(
+ child: Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(Icons.mic_none_rounded,
+ size: 56, color: cs.onSurfaceVariant.withValues(alpha: 0.3)),
+ const SizedBox(height: 12),
+ Text(l.libraryNoNarratorsFound,
+ style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant)),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ return RefreshIndicator(
+ onRefresh: onRefresh,
+ child: ListView.separated(
+ controller: scrollController,
+ physics: const AlwaysScrollableScrollPhysics(),
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding),
+ itemCount: narrators.length,
+ separatorBuilder: (_, __) => Divider(
+ height: 1,
+ thickness: 0.5,
+ color: cs.outlineVariant.withValues(alpha: 0.4),
+ ),
+ itemBuilder: (context, index) {
+ final name = narrators[index];
+ return InkWell(
+ borderRadius: BorderRadius.circular(8),
+ onTap: () => showNarratorBooksSheet(context, narratorName: name),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 14),
+ child: Row(
+ children: [
+ Icon(Icons.mic_rounded, size: 18, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
+ const SizedBox(width: 14),
+ Expanded(
+ child: Text(
+ name,
+ style: tt.bodyLarge?.copyWith(
+ color: cs.onSurface,
+ fontWeight: FontWeight.w500,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ Icon(Icons.chevron_right_rounded, size: 18, color: cs.onSurfaceVariant.withValues(alpha: 0.4)),
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/library_series_tab.dart b/lib/widgets/library_series_tab.dart
index 56e5da15..0277c1ca 100644
--- a/lib/widgets/library_series_tab.dart
+++ b/lib/widgets/library_series_tab.dart
@@ -62,7 +62,7 @@ class LibrarySeriesTab extends StatelessWidget {
child: GridView.builder(
controller: scrollController,
physics: const AlwaysScrollableScrollPhysics(),
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 100),
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: responsiveGridCount(context),
childAspectRatio: rectangleCovers ? 0.48 : 0.68,
diff --git a/lib/widgets/library_sort_filter_sheet.dart b/lib/widgets/library_sort_filter_sheet.dart
index d2c9ffbc..a5c9bb2a 100644
--- a/lib/widgets/library_sort_filter_sheet.dart
+++ b/lib/widgets/library_sort_filter_sheet.dart
@@ -4,7 +4,7 @@ import '../l10n/app_localizations.dart';
import '../screens/library_screen.dart';
/// Which library tab the sort/filter sheet is being shown for.
-enum LibraryTab { library, series, authors }
+enum LibraryTab { library, series, authors, narrators }
// ═══════════════════════════════════════════════════════════════
// Sort & Filter bottom sheet with tabs
@@ -120,6 +120,7 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProv
double _calcHeight() {
if (widget.libraryTab == LibraryTab.series) return widget.onUpcomingReleases != null ? 330 : 230;
if (widget.libraryTab == LibraryTab.authors) return 180;
+ if (widget.libraryTab == LibraryTab.narrators) return 130;
return _genreExpanded ? 420 : (widget.isPodcastLibrary ? 200 : 400);
}
@@ -230,6 +231,10 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProv
(LibrarySort.alphabetical, l.name, Icons.sort_by_alpha_rounded),
(LibrarySort.totalDuration, l.numberOfBooks, Icons.auto_stories_rounded),
];
+ case LibraryTab.narrators:
+ return [
+ (LibrarySort.alphabetical, l.name, Icons.sort_by_alpha_rounded),
+ ];
case LibraryTab.library:
if (widget.isPodcastLibrary) {
return [
diff --git a/lib/widgets/narrator_books_sheet.dart b/lib/widgets/narrator_books_sheet.dart
new file mode 100644
index 00000000..53f1724d
--- /dev/null
+++ b/lib/widgets/narrator_books_sheet.dart
@@ -0,0 +1,255 @@
+import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+import '../l10n/app_localizations.dart';
+import '../providers/auth_provider.dart';
+import '../providers/library_provider.dart';
+import '../services/audio_player_service.dart';
+import 'library_grid_tiles.dart';
+import 'library_search_results.dart';
+import 'stackable_sheet.dart';
+
+enum _NarratorLayout { list, grid }
+
+/// Show a stackable sheet listing books narrated by [narratorName].
+void showNarratorBooksSheet(BuildContext context, {
+ required String narratorName,
+}) {
+ final auth = context.read<AuthProvider>();
+ final lib = context.read<LibraryProvider>();
+ showStackableSheet(
+ context: context,
+ showHandle: true,
+ builder: (ctx, scrollController) => NarratorBooksSheet(
+ libraryId: lib.selectedLibraryId ?? '',
+ narratorName: narratorName,
+ serverUrl: auth.serverUrl,
+ token: auth.token,
+ scrollController: scrollController,
+ ),
+ );
+}
+
+class NarratorBooksSheet extends StatefulWidget {
+ final String libraryId;
+ final String narratorName;
+ final String? serverUrl;
+ final String? token;
+ final ScrollController scrollController;
+
+ const NarratorBooksSheet({
+ super.key,
+ required this.libraryId,
+ required this.narratorName,
+ required this.serverUrl,
+ required this.token,
+ required this.scrollController,
+ });
+
+ @override
+ State<NarratorBooksSheet> createState() => _NarratorBooksSheetState();
+}
+
+class _NarratorBooksSheetState extends State<NarratorBooksSheet> {
+ List<Map<String, dynamic>> _books = [];
+ bool _isLoading = true;
+ _NarratorLayout _layout = _NarratorLayout.list;
+
+ @override
+ void initState() {
+ super.initState();
+ _loadViewSettings();
+ _loadBooks();
+ }
+
+ Future<void> _loadViewSettings() async {
+ final grid = await PlayerSettings.getSheetGridView();
+ if (mounted) setState(() {
+ _layout = grid ? _NarratorLayout.grid : _NarratorLayout.list;
+ });
+ }
+
+ Future<void> _loadBooks() async {
+ final auth = context.read<AuthProvider>();
+ final api = auth.apiService;
+ if (api == null || widget.libraryId.isEmpty) {
+ if (mounted) setState(() => _isLoading = false);
+ return;
+ }
+
+ final raw = await api.getBooksByNarrator(widget.libraryId, widget.narratorName, limit: 200);
+ if (!mounted) return;
+
+ final lib = context.read<LibraryProvider>();
+ final books = raw.whereType<Map<String, dynamic>>().toList();
+ for (final book in books) {
+ final id = book['id'] as String?;
+ final bts = book['updatedAt'] as num?;
+ if (id != null && bts != null) lib.registerUpdatedAt(id, bts.toInt());
+ if (id != null) {
+ final coverPath = (book['media'] as Map<String, dynamic>?)?['coverPath'] as String?;
+ lib.registerHasCover(id, coverPath != null && coverPath.isNotEmpty);
+ }
+ }
+
+ // Sort alphabetically by title
+ books.sort((a, b) {
+ final tA = ((a['media'] as Map<String, dynamic>?)?['metadata'] as Map<String, dynamic>?)?['title'] as String? ?? '';
+ final tB = ((b['media'] as Map<String, dynamic>?)?['metadata'] as Map<String, dynamic>?)?['title'] as String? ?? '';
+ return tA.toLowerCase().compareTo(tB.toLowerCase());
+ });
+
+ setState(() {
+ _books = books;
+ _isLoading = false;
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ final l = AppLocalizations.of(context)!;
+ final bottomPad = 24 + MediaQuery.of(context).viewPadding.bottom;
+
+ if (_isLoading) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _buildHeader(cs, tt, l),
+ const Expanded(child: Center(child: CircularProgressIndicator())),
+ ],
+ );
+ }
+
+ final headerWidgets = <Widget>[
+ _buildHeader(cs, tt, l),
+ if (_books.isNotEmpty) _buildViewModeBar(cs, l),
+ ];
+
+ if (_books.isEmpty) {
+ return ListView(
+ controller: widget.scrollController,
+ padding: EdgeInsets.fromLTRB(0, 0, 0, bottomPad),
+ children: [
+ ...headerWidgets,
+ Center(
+ child: Padding(
+ padding: const EdgeInsets.only(top: 48),
+ child: Text(l.noBooksFound,
+ style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant)),
+ ),
+ ),
+ ],
+ );
+ }
+
+ if (_layout == _NarratorLayout.list) {
+ return ListView.builder(
+ controller: widget.scrollController,
+ padding: EdgeInsets.fromLTRB(0, 0, 0, bottomPad),
+ itemCount: _books.length + headerWidgets.length,
+ itemBuilder: (context, index) {
+ if (index < headerWidgets.length) return headerWidgets[index];
+ final book = _books[index - headerWidgets.length];
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: BookResultTile(
+ item: book,
+ serverUrl: widget.serverUrl,
+ token: widget.token,
+ ),
+ );
+ },
+ );
+ }
+
+ return CustomScrollView(
+ controller: widget.scrollController,
+ slivers: [
+ SliverList(delegate: SliverChildListDelegate(headerWidgets)),
+ SliverPadding(
+ padding: EdgeInsets.fromLTRB(16, 0, 16, bottomPad),
+ sliver: SliverGrid(
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: (MediaQuery.of(context).size.width / 130).floor().clamp(3, 10),
+ mainAxisSpacing: 8,
+ crossAxisSpacing: 8,
+ childAspectRatio: 0.55,
+ ),
+ delegate: SliverChildBuilderDelegate(
+ (_, i) => GridBookTile(item: _books[i]),
+ childCount: _books.length,
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildViewModeBar(ColorScheme cs, AppLocalizations l) {
+ Widget layoutBtn(IconData icon, _NarratorLayout mode, String tooltip) {
+ final active = _layout == mode;
+ return IconButton(
+ icon: Icon(icon, size: 20, color: active ? cs.primary : cs.onSurfaceVariant),
+ tooltip: tooltip,
+ visualDensity: VisualDensity.compact,
+ onPressed: () {
+ setState(() => _layout = mode);
+ PlayerSettings.setSheetGridView(mode == _NarratorLayout.grid);
+ },
+ );
+ }
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 4),
+ child: Row(
+ children: [
+ const Spacer(),
+ layoutBtn(Icons.view_list_rounded, _NarratorLayout.list, l.authorBooksList),
+ layoutBtn(Icons.apps_rounded, _NarratorLayout.grid, l.authorBooksGrid),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildHeader(ColorScheme cs, TextTheme tt, AppLocalizations l) {
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(24, 0, 24, 12),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ width: 72,
+ height: 72,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: cs.tertiaryContainer,
+ ),
+ child: Center(
+ child: Icon(Icons.mic_rounded,
+ size: 36, color: cs.onTertiaryContainer.withValues(alpha: 0.7)),
+ ),
+ ),
+ const SizedBox(width: 16),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 4),
+ Text(widget.narratorName,
+ style: tt.titleLarge?.copyWith(fontWeight: FontWeight.w600)),
+ if (_books.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.only(top: 4),
+ child: Text(
+ l.authorBooksBookCount(_books.length),
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/section_labels.dart b/lib/widgets/section_labels.dart
new file mode 100644
index 00000000..5988a9db
--- /dev/null
+++ b/lib/widgets/section_labels.dart
@@ -0,0 +1,30 @@
+import '../l10n/app_localizations.dart';
+
+/// Returns the localized display label for a known ABS personalized shelf
+/// section ID. Falls back to [fallback] (typically the server-provided label,
+/// which is English) when the ID isn't one we recognize. As a last resort it
+/// title-cases the ID.
+String sectionLabel(String id, String? fallback, AppLocalizations l) {
+ switch (id) {
+ case 'continue-listening':
+ return l.continueListening;
+ case 'continue-series':
+ return l.continueSeries;
+ case 'recently-added':
+ return l.recentlyAdded;
+ case 'listen-again':
+ return l.listenAgain;
+ case 'discover':
+ return l.discover;
+ case 'episodes-recently-added':
+ return l.newEpisodes;
+ case 'downloaded-books':
+ return l.downloads;
+ }
+ if (fallback != null && fallback.isNotEmpty) return fallback;
+ return id
+ .replaceAll('-', ' ')
+ .split(' ')
+ .map((w) => w.isEmpty ? w : '${w[0].toUpperCase()}${w.substring(1)}')
+ .join(' ');
+}
diff --git a/lib/widgets/sleep_timer_sheet.dart b/lib/widgets/sleep_timer_sheet.dart
index 5c0d8c21..54ee81e4 100644
--- a/lib/widgets/sleep_timer_sheet.dart
+++ b/lib/widgets/sleep_timer_sheet.dart
@@ -363,8 +363,8 @@ class _SleepTimerSheetState extends State<SleepTimerSheet> {
child: SegmentedButton<bool>(
showSelectedIcon: false,
segments: [
- ButtonSegment(value: false, label: Text(l.sleepTimerSheetSpecificStart)),
- ButtonSegment(value: true, label: Text(l.sleepTimerSheetSpecificEnd)),
+ ButtonSegment(value: false, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.sleepTimerSheetSpecificStart, maxLines: 1))),
+ ButtonSegment(value: true, label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.sleepTimerSheetSpecificEnd, maxLines: 1))),
],
selected: {_useChapterEnd},
style: const ButtonStyle(
@@ -725,9 +725,9 @@ class _SleepTimerSheetState extends State<SleepTimerSheet> {
child: SegmentedButton<String>(
showSelectedIcon: false,
segments: [
- ButtonSegment(value: 'off', label: Text(l.off)),
- ButtonSegment(value: 'addTime', label: Text(l.shakeAddTime)),
- ButtonSegment(value: 'resetTimer', label: Text(l.shakeReset)),
+ ButtonSegment(value: 'off', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.off, maxLines: 1))),
+ ButtonSegment(value: 'addTime', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.shakeAddTime, maxLines: 1))),
+ ButtonSegment(value: 'resetTimer', label: FittedBox(fit: BoxFit.scaleDown, child: Text(l.shakeReset, maxLines: 1))),
],
selected: {_shakeMode},
style: ButtonStyle(
diff --git a/pubspec.lock b/pubspec.lock
index 40ec7cbc..131aecef 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -551,10 +551,10 @@ packages:
dependency: transitive
description:
name: matcher
- sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
+ sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
url: "https://pub.dev"
source: hosted
- version: "0.12.19"
+ version: "0.12.18"
material_color_utilities:
dependency: transitive
description:
@@ -1036,10 +1036,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
+ sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
url: "https://pub.dev"
source: hosted
- version: "0.7.10"
+ version: "0.7.9"
timezone:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index e5c675d6..a10224c4 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: absorb
description: An Audiobookshelf Client
publish_to: 'none'
-version: 1.8.82+121
+version: 1.8.83+122
environment:
sdk: '>=3.1.0 <4.0.0'