A cross platform Audiobookshelf client for Android and iOS
Dart
Add tag support: filter by tag, tappable chips on detail
Barnabasc6d8439a97d7
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex 4705190c..d20ff56d 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -101,6 +101,8 @@"libraryNoBooksWithEbooks": "No books with eBooks","libraryNoBooksInGenre": "No books in \"{genre}\"","@libraryNoBooksInGenre": { "placeholders": { "genre": { "type": "String" } } },+ "libraryNoBooksWithTag": "No books tagged \"{tag}\"",+ "@libraryNoBooksWithTag": { "placeholders": { "tag": { "type": "String" } } },"libraryClearFilter": "Clear filter","libraryNoAuthorsFound": "No authors found","libraryNoNarratorsFound": "No narrators found",@@ -137,8 +139,10 @@"downloaded": "Downloaded","hasEbook": "Has eBook","genre": "Genre",+ "tag": "Tag","clearFilter": "Clear Filter","noGenresFound": "No genres found",+ "noTagsFound": "No tags found","asc": "ASC","desc": "DESC",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex a1d26ee8..c1593c2b 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -652,6 +652,12 @@ abstract class AppLocalizations {/// **'No books in \"{genre}\"'**String libraryNoBooksInGenre(String genre);+ /// No description provided for @libraryNoBooksWithTag.+ ///+ /// In en, this message translates to:+ /// **'No books tagged \"{tag}\"'**+ String libraryNoBooksWithTag(String tag);+/// No description provided for @libraryClearFilter.////// In en, this message translates to:@@ -838,6 +844,12 @@ abstract class AppLocalizations {/// **'Genre'**String get genre;+ /// No description provided for @tag.+ ///+ /// In en, this message translates to:+ /// **'Tag'**+ String get tag;+/// No description provided for @clearFilter.////// In en, this message translates to:@@ -850,6 +862,12 @@ abstract class AppLocalizations {/// **'No genres found'**String get noGenresFound;+ /// No description provided for @noTagsFound.+ ///+ /// In en, this message translates to:+ /// **'No tags found'**+ String get noTagsFound;+/// No description provided for @asc.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 014d45fa..6cc1481e 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -303,6 +303,11 @@ class AppLocalizationsDe extends AppLocalizations {return 'Keine Bücher in \"$genre\"';}+ @override+ String libraryNoBooksWithTag(String tag) {+ return 'No books tagged \"$tag\"';+ }+@overrideString get libraryClearFilter => 'Filter zurücksetzen';@@ -404,12 +409,18 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get genre => 'Genre';+ @override+ String get tag => 'Tag';+@overrideString get clearFilter => 'Filter zurücksetzen';@overrideString get noGenresFound => 'Keine Genres gefunden';+ @override+ String get noTagsFound => 'No tags found';+@overrideString get asc => 'AUF';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex c0684960..4eea52cf 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -300,6 +300,11 @@ class AppLocalizationsEn extends AppLocalizations {return 'No books in \"$genre\"';}+ @override+ String libraryNoBooksWithTag(String tag) {+ return 'No books tagged \"$tag\"';+ }+@overrideString get libraryClearFilter => 'Clear filter';@@ -401,12 +406,18 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get genre => 'Genre';+ @override+ String get tag => 'Tag';+@overrideString get clearFilter => 'Clear Filter';@overrideString get noGenresFound => 'No genres found';+ @override+ String get noTagsFound => 'No tags found';+@overrideString get asc => 'ASC';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 2af581e1..98072cb7 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -294,6 +294,11 @@ class AppLocalizationsZh extends AppLocalizations {return '\"$genre\" 中没有找到书籍';}+ @override+ String libraryNoBooksWithTag(String tag) {+ return 'No books tagged \"$tag\"';+ }+@overrideString get libraryClearFilter => '清除筛选';@@ -395,12 +400,18 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get genre => '分类';+ @override+ String get tag => 'Tag';+@overrideString get clearFilter => '清除筛选';@overrideString get noGenresFound => '未找到分类';+ @override+ String get noTagsFound => 'No tags found';+@overrideString get asc => '升序';diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex 9952107a..d6377be1 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -56,6 +56,39 @@ class AppShell extends StatefulWidget {return true;}+ /// Switch to the Library tab and apply a tag filter. Used by the book+ /// detail sheet's tag chip so tapping a tag jumps the user to the library+ /// view filtered by that tag. Returns false when the shell or library+ /// state isn't mounted yet.+ static bool openLibraryWithTagFilterGlobal(String tag) =>+ _applyLibraryFilterGlobal((s) => s.applyTagFilter(tag));++ /// Switch to the Library tab and apply a genre filter. Mirrors the tag+ /// version above; used by the genre chip in book detail.+ static bool openLibraryWithGenreFilterGlobal(String genre) =>+ _applyLibraryFilterGlobal((s) => s.applyGenreFilter(genre));++ static bool _applyLibraryFilterGlobal(+ void Function(LibraryScreenState) apply) {+ final inst = _AppShellState._instance;+ if (inst == null) return false;+ inst._navigateTo(1);+ var attempts = 0;+ void tryApply() {+ if (!inst.mounted) return;+ final state = inst._libraryKey.currentState;+ if (state != null) {+ apply(state);+ return;+ }+ if (++attempts < 10) {+ WidgetsBinding.instance.addPostFrameCallback((_) => tryApply());+ }+ }+ WidgetsBinding.instance.addPostFrameCallback((_) => tryApply());+ return true;+ }+/// Called by Home (callingTab=0) and Library (callingTab=1) after their/// first frame. Lets the AppShell re-sync the bottom-nav listener to the/// right notifier — handles both "screen state didn't exist on initialdiff --git a/lib/screens/library_screen.dart b/lib/screens/library_screen.dartindex 1d9df825..4d3aa60e 100644--- a/lib/screens/library_screen.dart+++ b/lib/screens/library_screen.dart@@ -11,6 +11,7 @@ import '../providers/library_provider.dart';import '../services/api_service.dart';import '../services/download_service.dart';import '../services/audio_player_service.dart';+import '../utils/library_filter_query.dart';import '../widgets/absorb_page_header.dart';import '../widgets/library_search_results.dart';import '../main.dart' show oledNotifier;@@ -46,7 +47,7 @@ const double libraryGridBottomPadding = 180;enum LibrarySort { recentlyAdded, alphabetical, authorName, publishedYear, duration, random, totalDuration }// ─── Filter modes ────────────────────────────────────────────-enum LibraryFilter { none, inProgress, finished, notStarted, downloaded, inASeries, hasEbook, genre }+enum LibraryFilter { none, inProgress, finished, notStarted, downloaded, inASeries, hasEbook, genre, tag }class LibraryScreen extends StatefulWidget {const LibraryScreen({super.key});@@ -110,7 +111,9 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMibool _sortAsc = false; // false = desc (newest/longest first), true = ascLibraryFilter _filter = LibraryFilter.none;String? _genreFilter;+ String? _tagFilter;List<String> _availableGenres = [];+ List<String> _availableTags = [];bool _hideEbookOnly = false;final List<Map<String, dynamic>> _items = [];bool _isLoadingPage = false;@@ -244,6 +247,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi_hasMore = true;_isLoadingPage = false;_availableGenres = [];+ _availableTags = [];// Clear series and author data_seriesItems.clear();_seriesPage = 0;@@ -265,7 +269,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi_restoreSortFilter().then((_) {if (mounted) _loadPage();});- _loadGenres();+ _loadFilterData();}}@@ -286,7 +290,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMilib.addListener(_onLibraryProviderChanged);if (lib.selectedLibraryId != null) {_loadPage();- _loadGenres();+ _loadFilterData();} else {lib.addListener(_onLibraryChanged);}@@ -309,6 +313,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiPlayerSettings.getLibraryTab(),PlayerSettings.getNarratorSort(),PlayerSettings.getNarratorSortAsc(),+ PlayerSettings.getLibraryTagFilter(),]);if (!mounted) return;final sortName = results[0] as String;@@ -324,6 +329,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMifinal savedTab = results[10] as int;final narratorSortName = results[11] as String;final narratorSortAsc = results[12] as bool;+ final tagFilter = results[13] as String;final isPodcast = context.read<LibraryProvider>().isPodcastLibrary;setState(() {// Book library sort/filter@@ -338,6 +344,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiorElse: () => LibraryFilter.none,);_genreFilter = genreFilter.isNotEmpty ? genreFilter : null;+ _tagFilter = tagFilter.isNotEmpty ? tagFilter : null;_seriesSort = LibrarySort.values.firstWhere((s) => s.name == seriesSortName,orElse: () => LibrarySort.alphabetical,@@ -365,6 +372,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi_sortAsc = _podcastSortAsc;_filter = LibraryFilter.none;_genreFilter = null;+ _tagFilter = null;}// Restore last active tab (only for book libraries with tabs)if (!isPodcast && savedTab > 0 && savedTab < 4) {@@ -418,11 +426,11 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiif (lib.selectedLibraryId != null && _items.isEmpty && !_isLoadingPage) {lib.removeListener(_onLibraryChanged);_loadPage();- _loadGenres();+ _loadFilterData();}}- Future<void> _loadGenres() async {+ Future<void> _loadFilterData() async {final auth = context.read<AuthProvider>();final lib = context.read<LibraryProvider>();final api = auth.apiService;@@ -430,8 +438,20 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMifinal filterData = await api.getLibraryFilterData(lib.selectedLibraryId!);if (filterData != null && mounted) {final genres = filterData['genres'] as List<dynamic>? ?? [];+ final tags = filterData['tags'] as List<dynamic>? ?? [];+ String unwrap(dynamic v) =>+ v is Map ? (v['name'] as String? ?? '') : v.toString();setState(() {- _availableGenres = genres.map((g) => g is Map ? (g['name'] as String? ?? '') : g.toString()).where((g) => g.isNotEmpty).toList()..sort();+ _availableGenres = genres+ .map(unwrap)+ .where((g) => g.isNotEmpty)+ .toList()+ ..sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));+ _availableTags = tags+ .map(unwrap)+ .where((t) => t.isNotEmpty)+ .toList()+ ..sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));});}}@@ -503,15 +523,18 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiString? filter;if (_filter == LibraryFilter.inProgress) {- filter = 'progress.${base64Encode(utf8.encode('in-progress'))}';+ filter = LibraryFilterQuery.grouped(LibraryFilterGroup.progress, 'in-progress').queryValue;} else if (_filter == LibraryFilter.finished) {- filter = 'progress.${base64Encode(utf8.encode('finished'))}';+ filter = LibraryFilterQuery.grouped(LibraryFilterGroup.progress, 'finished').queryValue;} else if (_filter == LibraryFilter.notStarted) {- filter = 'progress.${base64Encode(utf8.encode('not-started'))}';+ filter = LibraryFilterQuery.grouped(LibraryFilterGroup.progress, 'not-started').queryValue;} else if (_filter == LibraryFilter.hasEbook) {- filter = 'ebooks.${base64Encode(utf8.encode('ebook'))}';+ // ABS uses an `ebooks` group not in our generic enum; build manually.+ filter = 'ebooks.${encodeFilterValue('ebook')}';} else if (_filter == LibraryFilter.genre && _genreFilter != null) {- filter = 'genres.${base64Encode(utf8.encode(_genreFilter!))}';+ filter = LibraryFilterQuery.grouped(LibraryFilterGroup.genres, _genreFilter!).queryValue;+ } else if (_filter == LibraryFilter.tag && _tagFilter != null) {+ filter = LibraryFilterQuery.grouped(LibraryFilterGroup.tags, _tagFilter!).queryValue;}// Downloaded filter is client-side — handled after loading@@ -940,15 +963,38 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiif (_narratorsScrollController.hasClients) _narratorsScrollController.jumpTo(0);}+ /// Switch to the Books sub-tab (if needed) and apply a tag filter. Used by+ /// AppShell.openLibraryWithTagFilterGlobal so a tag chip tapped from the+ /// book detail sheet drops the user into the matching library view.+ void applyTagFilter(String tag) {+ if (_currentTab != 0 && _tabController != null) {+ _tabController!.animateTo(0);+ }+ _changeFilter(LibraryFilter.tag, tag: tag);+ }++ /// Switch to the Books sub-tab (if needed) and apply a genre filter.+ /// Mirrors [applyTagFilter] for genre chips tapped from book detail.+ void applyGenreFilter(String genre) {+ if (_currentTab != 0 && _tabController != null) {+ _tabController!.animateTo(0);+ }+ _changeFilter(LibraryFilter.genre, genre: genre);+ }+// ── Change filter and reload ──- void _changeFilter(LibraryFilter newFilter, {String? genre}) {- final effective = (newFilter == _filter && genre == _genreFilter) ? LibraryFilter.none : newFilter;- if (effective == _filter && genre == _genreFilter) return;+ void _changeFilter(LibraryFilter newFilter, {String? genre, String? tag}) {+ final sameAsCurrent = newFilter == _filter &&+ genre == _genreFilter &&+ tag == _tagFilter;+ final effective = sameAsCurrent ? LibraryFilter.none : newFilter;+ if (effective == _filter && genre == _genreFilter && tag == _tagFilter) return;final isPodcast = context.read<LibraryProvider>().isPodcastLibrary;_loadGeneration++;setState(() {_filter = effective;_genreFilter = effective == LibraryFilter.genre ? genre : null;+ _tagFilter = effective == LibraryFilter.tag ? tag : null;_items.clear();_page = 0;_hasMore = true;@@ -957,6 +1003,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiif (!isPodcast) {PlayerSettings.setLibraryFilter(_filter.name);PlayerSettings.setLibraryGenreFilter(_genreFilter);+ PlayerSettings.setLibraryTagFilter(_tagFilter);}if (_scrollController.hasClients) _scrollController.jumpTo(0);_loadPage();@@ -1157,6 +1204,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiLibraryFilter.inASeries => l.libraryTabSeries,LibraryFilter.hasEbook => l.hasEbook,LibraryFilter.genre => _genreFilter ?? l.genre,+ LibraryFilter.tag => _tagFilter ?? l.tag,LibraryFilter.none => '',};@@ -1196,7 +1244,9 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMisortAsc: currentSortAsc,currentFilter: _filter,genreFilter: _genreFilter,+ tagFilter: _tagFilter,availableGenres: _availableGenres,+ availableTags: _availableTags,initialTab: initialTab,cs: cs, tt: tt,libraryTab: tab,@@ -1229,7 +1279,10 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi}Navigator.pop(ctx);},- onFilterChanged: (filter, {String? genre}) { Navigator.pop(ctx); _changeFilter(filter, genre: genre); },+ onFilterChanged: (filter, {String? genre, String? tag}) {+ Navigator.pop(ctx);+ _changeFilter(filter, genre: genre, tag: tag);+ },onClearFilter: () { Navigator.pop(ctx); _changeFilter(LibraryFilter.none); },collapseSeries: _collapseSeries,onCollapseSeriesChanged: (value) {@@ -1261,10 +1314,10 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMifinal l = AppLocalizations.of(context)!;final scaffoldBg = Theme.of(context).scaffoldBackgroundColor;final lowerFade = Color.lerp(cs.surface, scaffoldBg, 0.55) ?? scaffoldBg;- final lib = context.watch<LibraryProvider>();- final allLibraries = lib.libraries;- final hasMultipleLibraries = allLibraries.length > 1;- final libraryName = lib.selectedLibrary?['name'] as String? ?? l.libraryFallback;+ // Watch LibraryProvider so this screen rebuilds when the active library+ // or its data changes; the actual lib object is consumed inside+ // _buildHeaderSliver via context.watch.+ context.watch<LibraryProvider>();final hasTabs = _tabController != null && !_isInSearchMode;return Scaffold(@@ -1315,49 +1368,134 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi},child: Builder(builder: (ctx) {- // Paint the same screen-height gradient inside the- // SliverAppBar so the header (a) visually matches the- // body's gradient when sitting at the top, and (b) is- // opaque enough to occlude books when it floats back in- // mid-scroll. The gradient is shifted up by the SafeArea- // top inset so its color at any screen-Y matches the- // body gradient at the same screen-Y (no visible seam at- // the bottom of the header).- final topInset = MediaQuery.of(context).padding.top;- final screenH = MediaQuery.of(context).size.height;- final headerBackground = oledNotifier.value- ? const ColoredBox(color: Colors.black)- : ClipRect(- child: OverflowBox(- maxHeight: screenH,- minHeight: 0,- alignment: Alignment.topCenter,- child: Transform.translate(- offset: Offset(0, -topInset),- child: SizedBox(- height: screenH,- width: double.infinity,- child: DecoratedBox(- decoration: BoxDecoration(- color: scaffoldBg,- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- stops: const [0.0, 0.22, 0.72, 1.0],- colors: [- cs.primary.withValues(alpha: 0.06),- cs.surface,- lowerFade,- scaffoldBg,- ],- ),- ),- ),- ),- ),- ),- );- final headerSliver = SliverAppBar(+ return _isInSearchMode+ ? _buildSearchResults(cs, tt, l,+ _buildHeaderSliver(context, useSharedFocus: true))+ : hasTabs+ ? _buildTabbedContent(cs, tt)+ : _buildGrid(_buildHeaderSliver(context,+ useSharedFocus: true));+ },+ ),+ ),+ if (hasTabs && !_isInSearchMode)+ Positioned(+ left: 0,+ right: 0,+ bottom: 12,+ child: ValueListenableBuilder<double>(+ valueListenable: _revealDriver.notifier,+ // Translate only; skip the Opacity saveLayer that was+ // forcing a per-frame re-raster of the BackdropFilter+ // pill. Skip painting entirely once basically hidden.+ builder: (_, reveal, child) {+ if (reveal < 0.02) return const SizedBox.shrink();+ return IgnorePointer(+ ignoring: reveal < 0.5,+ child: Transform.translate(+ offset: Offset(0, (1 - reveal) * 80),+ child: child,+ ),+ );+ },+ child: RepaintBoundary(child: _buildFloatingTabBar(cs)),+ ),+ ),+ if (!hasTabs && !_isInSearchMode)+ Positioned(+ left: 0,+ right: 0,+ bottom: 12,+ child: ValueListenableBuilder<double>(+ valueListenable: _revealDriver.notifier,+ builder: (_, reveal, child) {+ if (reveal < 0.02) return const SizedBox.shrink();+ return IgnorePointer(+ ignoring: reveal < 0.5,+ child: Transform.translate(+ offset: Offset(0, (1 - reveal) * 80),+ child: child,+ ),+ );+ },+ child: RepaintBoundary(+ child: Center(+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ _buildFloatingSortButton(cs, tt),+ if (context.read<AuthProvider>().isRoot) ...[+ const SizedBox(width: 8),+ _buildFloatingManageButton(cs),+ ],+ ],+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ ),+ ],+ ),+ );+ }++ /// Build the floating SliverAppBar header that goes at the top of each+ /// tab's CustomScrollView. Each tab in the IndexedStack gets its own+ /// instance — when [useSharedFocus] is true, the SearchBar inside binds to+ /// the screen-level [_focusNode] (so the active tab is the one that+ /// receives focus from taps and the Search app shortcut). Inactive tabs+ /// get a fresh internal FocusNode per SearchBar so they don't fight over+ /// the shared one.+ Widget _buildHeaderSliver(BuildContext context,+ {required bool useSharedFocus}) {+ final cs = Theme.of(context).colorScheme;+ final tt = Theme.of(context).textTheme;+ final l = AppLocalizations.of(context)!;+ final scaffoldBg = Theme.of(context).scaffoldBackgroundColor;+ final lowerFade = Color.lerp(cs.surface, scaffoldBg, 0.55) ?? scaffoldBg;+ final lib = context.watch<LibraryProvider>();+ final allLibraries = lib.libraries;+ final hasMultipleLibraries = allLibraries.length > 1;+ final libraryName =+ lib.selectedLibrary?['name'] as String? ?? l.libraryFallback;+ final topInset = MediaQuery.of(context).padding.top;+ final screenH = MediaQuery.of(context).size.height;+ final headerBackground = oledNotifier.value+ ? const ColoredBox(color: Colors.black)+ : ClipRect(+ child: OverflowBox(+ maxHeight: screenH,+ minHeight: 0,+ alignment: Alignment.topCenter,+ child: Transform.translate(+ offset: Offset(0, -topInset),+ child: SizedBox(+ height: screenH,+ width: double.infinity,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: scaffoldBg,+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ stops: const [0.0, 0.22, 0.72, 1.0],+ colors: [+ cs.primary.withValues(alpha: 0.06),+ cs.surface,+ lowerFade,+ scaffoldBg,+ ],+ ),+ ),+ ),+ ),+ ),+ ),+ );+ return SliverAppBar(floating: true,snap: true,// primary: false disables Material's automatic status@@ -1365,7 +1503,9 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi// (we already wrap the whole NestedScrollView in// SafeArea above).primary: false,- toolbarHeight: _isInSearchMode ? 156 : 184,+ toolbarHeight: _isInSearchMode+ ? 156+ : (_filter != LibraryFilter.none ? 196 : 184),backgroundColor: scaffoldBg,surfaceTintColor: Colors.transparent,elevation: 0,@@ -1428,7 +1568,13 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMipadding: const EdgeInsets.fromLTRB(16, 8, 16, 0),child: SearchBar(controller: _searchController,- focusNode: _focusNode,+ // Only the active tab's SearchBar binds to the screen-+ // level focus node. Inactive tabs' SearchBars use their+ // own internal focus so multiple instances in the+ // IndexedStack don't fight over the same FocusNode (the+ // bug that left tap-to-focus dead until you switched+ // libraries to force a state reset).+ focusNode: useSharedFocus ? _focusNode : null,hintText: lib.isPodcastLibrary? l.librarySearchShowsHint: l.librarySearchBooksHint,@@ -1458,79 +1604,9 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMiif (!_isInSearchMode)_buildInfoRow(cs, tt, l),]),- ],- ),- ),- );- return _isInSearchMode- ? _buildSearchResults(cs, tt, l, headerSliver)- : hasTabs- ? _buildTabbedContent(cs, tt, headerSliver)- : _buildGrid(headerSliver);- },- ),- ),- if (hasTabs && !_isInSearchMode)- Positioned(- left: 0,- right: 0,- bottom: 12,- child: ValueListenableBuilder<double>(- valueListenable: _revealDriver.notifier,- // Translate only; skip the Opacity saveLayer that was- // forcing a per-frame re-raster of the BackdropFilter- // pill. Skip painting entirely once basically hidden.- builder: (_, reveal, child) {- if (reveal < 0.02) return const SizedBox.shrink();- return IgnorePointer(- ignoring: reveal < 0.5,- child: Transform.translate(- offset: Offset(0, (1 - reveal) * 80),- child: child,- ),- );- },- child: RepaintBoundary(child: _buildFloatingTabBar(cs)),- ),- ),- if (!hasTabs && !_isInSearchMode)- Positioned(- left: 0,- right: 0,- bottom: 12,- child: ValueListenableBuilder<double>(- valueListenable: _revealDriver.notifier,- builder: (_, reveal, child) {- if (reveal < 0.02) return const SizedBox.shrink();- return IgnorePointer(- ignoring: reveal < 0.5,- child: Transform.translate(- offset: Offset(0, (1 - reveal) * 80),- child: child,- ),- );- },- child: RepaintBoundary(- child: Center(- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- _buildFloatingSortButton(cs, tt),- if (context.read<AuthProvider>().isRoot) ...[- const SizedBox(width: 8),- _buildFloatingManageButton(cs),- ],- ],- ),- ),- ),- ),- ),- ],- ),+ ],),- ],- ),+ ),);}@@ -1723,18 +1799,22 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMi);}- Widget _buildTabbedContent(ColorScheme cs, TextTheme tt, Widget headerSliver) {+ Widget _buildTabbedContent(ColorScheme cs, TextTheme tt) {// IndexedStack preserves each tab's scroll position when switching tabs.- // Each tab is its own CustomScrollView with its own SliverAppBar instance,- // so floating-header behavior is per-tab and there's no NestedScrollView- // coordinator overhead in the scroll path.+ // Each tab gets its own SliverAppBar instance built fresh by+ // _buildHeaderSliver — only the active tab passes useSharedFocus: true so+ // the SearchBar inside binds to the screen-level _focusNode. Inactive+ // tabs' SearchBars use their own internal focus, avoiding the multi-bind+ // bug that left the search bar unresponsive on first tap.+ Widget headerFor(int i) =>+ _buildHeaderSliver(context, useSharedFocus: i == _currentTab);return IndexedStack(index: _currentTab,children: [- _buildGrid(headerSliver),- _buildSeriesGrid(headerSliver),- _buildAuthorsGrid(headerSliver),- _buildNarratorsGrid(headerSliver),+ _buildGrid(headerFor(0)),+ _buildSeriesGrid(headerFor(1)),+ _buildAuthorsGrid(headerFor(2)),+ _buildNarratorsGrid(headerFor(3)),],);}@@ -1783,6 +1863,7 @@ class LibraryScreenState extends State<LibraryScreen> with TickerProviderStateMihasMore: _hasMore,filter: _filter,genreFilter: _genreFilter,+ tagFilter: _tagFilter,rectangleCovers: _rectangleCovers,coverAspectRatio: _coverAspectRatio,onRefresh: _refreshAll,diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 55c7fdd8..96aa1712 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -309,6 +309,9 @@ class PlayerSettings {static Future<String> getLibraryGenreFilter() => _get('libraryGenreFilter', '');static Future<void> setLibraryGenreFilter(String? value) => _set('libraryGenreFilter', value ?? '');+ static Future<String> getLibraryTagFilter() => _get('libraryTagFilter', '');+ static Future<void> setLibraryTagFilter(String? value) => _set('libraryTagFilter', value ?? '');+static Future<int> getLibraryTab() => _get('libraryTab', 0);static Future<void> setLibraryTab(int value) => _set('libraryTab', value);diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dartindex 815f5cab..892eeaec 100644--- a/lib/widgets/book_detail_sheet.dart+++ b/lib/widgets/book_detail_sheet.dart@@ -344,6 +344,13 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {final duration = (media['duration'] as num?)?.toDouble() ?? 0;final seriesEntries = metadata['series'] as List<dynamic>? ?? [];final genres = (metadata['genres'] as List<dynamic>?)?.cast<String>() ?? [];+ // ABS puts tags on the media object (LibraryItem.media.tags), not in+ // metadata. Some endpoints may stash them in metadata too — fall back to+ // that if media doesn't have them.+ final tagsRaw = (media['tags'] as List<dynamic>?)+ ?? (metadata['tags'] as List<dynamic>?)+ ?? const [];+ final tags = tagsRaw.cast<String>();final publisher = metadata['publisher'] as String? ?? '';final year = metadata['publishedYear'] as String? ?? '';final serverPath = _item!['path'] as String? ?? _item!['relPath'] as String? ?? '';@@ -563,7 +570,22 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {if (chapters.isNotEmpty) _chip(Icons.list_rounded, l.chaptersChip(chapters.length)),..._audioInfoChips(media),if (publisher.isNotEmpty) _chip(Icons.business_rounded, publisher),- ...genres.take(3).map((g) => _chip(Icons.tag_rounded, g)),+ ...genres.take(3).map((g) => _chip(+ Icons.tag_rounded,+ g,+ onTap: () {+ Navigator.of(context).pop();+ AppShell.openLibraryWithGenreFilterGlobal(g);+ },+ )),+ ...tags.take(5).map((t) => _chip(+ Icons.local_offer_outlined,+ t,+ onTap: () {+ Navigator.of(context).pop();+ AppShell.openLibraryWithTagFilterGlobal(t);+ },+ )),if (progressData?['startedAt'] is num)_chip(Icons.play_circle_outline_rounded, l.startedDate(_fmtDate((progressData!['startedAt'] as num).toInt()))),if (progressData?['finishedAt'] is num)@@ -779,17 +801,41 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {return '${(bytes / 1073741824).toStringAsFixed(2)} GB';}- Widget _chip(IconData icon, String text) {+ Widget _chip(IconData icon, String text, {VoidCallback? onTap}) {final cs = Theme.of(context).colorScheme;- return Container(+ final pill = Container(constraints: const BoxConstraints(maxWidth: 200),padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),- decoration: BoxDecoration(color: cs.onSurface.withValues(alpha: 0.06), borderRadius: BorderRadius.circular(20),- border: Border.all(color: cs.onSurface.withValues(alpha: 0.08))),+ decoration: BoxDecoration(+ color: onTap != null+ ? cs.tertiary.withValues(alpha: 0.10)+ : cs.onSurface.withValues(alpha: 0.06),+ borderRadius: BorderRadius.circular(20),+ border: Border.all(+ color: onTap != null+ ? cs.tertiary.withValues(alpha: 0.30)+ : cs.onSurface.withValues(alpha: 0.08),+ ),+ ),child: Row(mainAxisSize: MainAxisSize.min, children: [- Icon(icon, size: 12, color: cs.onSurface.withValues(alpha: 0.3)), const SizedBox(width: 4),- Flexible(child: Text(text, overflow: TextOverflow.ellipsis, maxLines: 1,- style: TextStyle(color: cs.onSurfaceVariant, fontSize: 11)))]));+ Icon(icon,+ size: 12,+ color: onTap != null+ ? cs.tertiary+ : cs.onSurface.withValues(alpha: 0.3)),+ const SizedBox(width: 4),+ Flexible(+ child: Text(text,+ overflow: TextOverflow.ellipsis,+ maxLines: 1,+ style: TextStyle(+ color: onTap != null ? cs.tertiary : cs.onSurfaceVariant,+ fontSize: 11)),+ ),+ ]),+ );+ if (onTap == null) return pill;+ return GestureDetector(onTap: onTap, child: pill);}String _fmtDate(int ms) {diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dartindex 8163ade0..98bd776f 100644--- a/lib/widgets/episode_list_sheet.dart+++ b/lib/widgets/episode_list_sheet.dart@@ -80,6 +80,12 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {String get _description => _metadata['description'] as String? ?? '';List<String> get _genres =>(_metadata['genres'] as List<dynamic>?)?.cast<String>() ?? [];+ // ABS keeps tags on the media object, not in metadata. Fall back to+ // metadata in case some endpoint nests them differently.+ List<String> get _tags => ((_media['tags'] as List<dynamic>?)+ ?? (_metadata['tags'] as List<dynamic>?)+ ?? const [])+ .cast<String>();String get _language => _metadata['language'] as String? ?? '';bool get _explicit => PlayerSettings.showExplicitBadge && _metadata['explicit'] == true;String get _type => _metadata['type'] as String? ?? '';@@ -630,6 +636,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {if (_autoDownloadEnabled) _chip(Icons.downloading_rounded, l.episodeListAutoDownloadChip),if (_subscribed) _chip(Icons.notifications_active_rounded, l.episodeListSubscribedChip, highlight: true),..._genres.take(3).map((g) => _chip(Icons.tag_rounded, g)),+ ..._tags.take(5).map((t) => _chip(Icons.local_offer_outlined, t)),if (_language.isNotEmpty) _chip(Icons.language_rounded, _language.toUpperCase()),if (_explicit) _chip(Icons.explicit_rounded, l.episodeListExplicitChip),if (_type.isNotEmpty && _type != 'episodic') _chip(Icons.list_rounded, _type[0].toUpperCase() + _type.substring(1)),diff --git a/lib/widgets/library_books_tab.dart b/lib/widgets/library_books_tab.dartindex df9d9fd4..8fe28dff 100644--- a/lib/widgets/library_books_tab.dart+++ b/lib/widgets/library_books_tab.dart@@ -9,6 +9,7 @@ class LibraryBooksTab extends StatelessWidget {final bool hasMore;final LibraryFilter filter;final String? genreFilter;+ final String? tagFilter;final bool rectangleCovers;final double coverAspectRatio;final Future<void> Function() onRefresh;@@ -36,6 +37,7 @@ class LibraryBooksTab extends StatelessWidget {required this.hasMore,required this.filter,this.genreFilter,+ this.tagFilter,required this.rectangleCovers,required this.coverAspectRatio,required this.onRefresh,@@ -75,6 +77,7 @@ class LibraryBooksTab extends StatelessWidget {LibraryFilter.inASeries => l.libraryNoSeriesFound,LibraryFilter.hasEbook => l.libraryNoBooksWithEbooks,LibraryFilter.genre => l.libraryNoBooksInGenre(genreFilter ?? l.genre.toLowerCase()),+ LibraryFilter.tag => l.libraryNoBooksWithTag(tagFilter ?? l.tag.toLowerCase()),LibraryFilter.none => l.libraryNoBooks,};body = CustomScrollView(diff --git a/lib/widgets/library_sort_filter_sheet.dart b/lib/widgets/library_sort_filter_sheet.dartindex a5c9bb2a..04a9a54a 100644--- a/lib/widgets/library_sort_filter_sheet.dart+++ b/lib/widgets/library_sort_filter_sheet.dart@@ -14,13 +14,15 @@ class SortFilterSheet extends StatefulWidget {final bool sortAsc;final LibraryFilter currentFilter;final String? genreFilter;+ final String? tagFilter;final List<String> availableGenres;+ final List<String> availableTags;final int initialTab;final ColorScheme cs;final TextTheme tt;final void Function(LibrarySort) onSortChanged;final VoidCallback onSortDirectionToggled;- final void Function(LibraryFilter, {String? genre}) onFilterChanged;+ final void Function(LibraryFilter, {String? genre, String? tag}) onFilterChanged;final VoidCallback onClearFilter;final bool collapseSeries;final ValueChanged<bool> onCollapseSeriesChanged;@@ -31,8 +33,9 @@ class SortFilterSheet extends StatefulWidget {const SortFilterSheet({super.key,required this.currentSort, required this.sortAsc,- required this.currentFilter, this.genreFilter,- required this.availableGenres, required this.initialTab,+ required this.currentFilter, this.genreFilter, this.tagFilter,+ required this.availableGenres, this.availableTags = const [],+ required this.initialTab,required this.cs, required this.tt,required this.onSortChanged, required this.onSortDirectionToggled,required this.onFilterChanged, required this.onClearFilter,@@ -49,6 +52,7 @@ class SortFilterSheet extends StatefulWidget {class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProviderStateMixin {late TabController _tabCtrl;bool _genreExpanded = false;+ bool _tagExpanded = false;late bool _collapseSeries;bool get _showFilterTab => widget.libraryTab == LibraryTab.library && !widget.isPodcastLibrary;@@ -63,6 +67,7 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProvinitialIndex: _showFilterTab ? widget.initialTab.clamp(0, 1) : 0,);if (widget.currentFilter == LibraryFilter.genre) _genreExpanded = true;+ if (widget.currentFilter == LibraryFilter.tag) _tagExpanded = true;}@override@@ -121,7 +126,8 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProvif (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);+ if (_genreExpanded || _tagExpanded) return 420;+ return widget.isPodcastLibrary ? 200 : 440;}Widget _buildSortTab(ColorScheme cs, AppLocalizations l) {@@ -313,6 +319,30 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProv);}).toList()),),+ SheetOption(+ icon: Icons.local_offer_rounded,+ label: l.tag,+ selected: widget.currentFilter == LibraryFilter.tag,+ selectedColor: cs.tertiary,+ trailing: Icon(_tagExpanded ? Icons.expand_less_rounded : Icons.expand_more_rounded, size: 20, color: cs.onSurfaceVariant),+ onTap: () => setState(() => _tagExpanded = !_tagExpanded),+ ),+ if (_tagExpanded)+ Padding(+ padding: const EdgeInsets.only(left: 16),+ child: widget.availableTags.isEmpty+ ? Padding(padding: const EdgeInsets.all(12),+ child: Text(l.noTagsFound, style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant)))+ : Column(children: widget.availableTags.map((tag) {+ final selected = widget.currentFilter == LibraryFilter.tag && widget.tagFilter == tag;+ return SheetOption(+ icon: Icons.local_offer_outlined, label: tag,+ selected: selected, selectedColor: cs.tertiary,+ compact: true, marquee: true,+ onTap: () => widget.onFilterChanged(LibraryFilter.tag, tag: tag),+ );+ }).toList()),+ ),],);}