mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-05-05 20:49:37 +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
96
lib/features/library_browser/view/library_genres_page.dart
Normal file
96
lib/features/library_browser/view/library_genres_page.dart
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:vaani/api/library_browser_provider.dart';
|
||||
|
||||
class LibraryGenresPage extends HookConsumerWidget {
|
||||
const LibraryGenresPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final genresAsync = ref.watch(libraryGenresProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Genres'),
|
||||
),
|
||||
body: genresAsync.when(
|
||||
data: (genres) {
|
||||
if (genres.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No genres found'),
|
||||
);
|
||||
}
|
||||
|
||||
// Sort genres alphabetically
|
||||
final sortedGenres = List<String>.from(genres)..sort();
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: sortedGenres.length,
|
||||
itemBuilder: (context, index) {
|
||||
final genre = sortedGenres[index];
|
||||
return GenreListTile(genre: genre);
|
||||
},
|
||||
);
|
||||
},
|
||||
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 genres: $error'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GenreListTile extends StatelessWidget {
|
||||
const GenreListTile({
|
||||
super.key,
|
||||
required this.genre,
|
||||
});
|
||||
|
||||
final String genre;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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.primaryContainer,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.category,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
genre,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () {
|
||||
// TODO: Navigate to books in this genre
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Tapped on $genre'),
|
||||
duration: const Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue