mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-05-04 20:19:38 +00:00
feat: implement library view with Authors, Genres, and Series browsing
This commit implements a comprehensive library browsing feature: - Add LibraryBrowserProvider with providers for authors, genres, and series data - Create LibraryAuthorsPage with grid view of authors including images and book counts - Create LibraryGenresPage with list view of all genres - Create LibrarySeriesPage with list view of series and book counts - Update LibraryBrowserPage navigation to route to the new views - Add routes for /browser/authors, /browser/genres, and /browser/series - Replace "Not Implemented" toasts with functional navigation The implementation uses the Audiobookshelf API via shelfsdk to fetch: - Authors list with metadata (getAuthors) - Genres from library filter data (getFilterData) - Series with pagination support (getSeries) All views follow Material Design 3 patterns and include proper loading/error states.
This commit is contained in:
parent
07aea41c6e
commit
53027bf74c
7 changed files with 485 additions and 5 deletions
105
lib/features/library_browser/view/library_series_page.dart
Normal file
105
lib/features/library_browser/view/library_series_page.dart
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shelfsdk/audiobookshelf_api.dart';
|
||||
import 'package:vaani/api/library_browser_provider.dart';
|
||||
|
||||
class LibrarySeriesPage extends HookConsumerWidget {
|
||||
const LibrarySeriesPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final seriesAsync = ref.watch(librarySeriesProvider());
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Series'),
|
||||
),
|
||||
body: seriesAsync.when(
|
||||
data: (seriesResponse) {
|
||||
if (seriesResponse == null || seriesResponse.results.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No series found'),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: seriesResponse.results.length,
|
||||
itemBuilder: (context, index) {
|
||||
final series = seriesResponse.results[index];
|
||||
return SeriesListTile(series: series);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stack) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text('Error loading series: $error'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SeriesListTile extends StatelessWidget {
|
||||
const SeriesListTile({
|
||||
super.key,
|
||||
required this.series,
|
||||
});
|
||||
|
||||
final Series series;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Extract series data based on variant
|
||||
final String seriesName = series.name;
|
||||
final int? numBooks = series.maybeMap(
|
||||
numBooks: (s) => s.numBooks,
|
||||
books: (s) => s.books.length,
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.list,
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
seriesName,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
subtitle: numBooks != null
|
||||
? Text('$numBooks ${numBooks == 1 ? 'book' : 'books'}')
|
||||
: null,
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () {
|
||||
// TODO: Navigate to series detail page
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Tapped on $seriesName'),
|
||||
duration: const Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue