mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-11 05:29:29 +00:00
feat: refactor LibraryBrowserPage to use CustomScrollView and enhance app bar with dynamic library icon and title
This commit is contained in:
parent
98e8ffb021
commit
f82bcab2e0
1 changed files with 70 additions and 34 deletions
|
|
@ -1,47 +1,83 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:vaani/router/router.dart';
|
import 'package:vaani/api/library_provider.dart' show currentLibraryProvider;
|
||||||
|
import 'package:vaani/features/you/view/widgets/library_switch_chip.dart'
|
||||||
|
show showLibrarySwitcher;
|
||||||
|
import 'package:vaani/router/router.dart' show Routes;
|
||||||
|
import 'package:vaani/shared/icons/abs_icons.dart' show AbsIcons;
|
||||||
|
import 'package:vaani/shared/widgets/not_implemented.dart'
|
||||||
|
show showNotImplementedToast;
|
||||||
|
|
||||||
class LibraryBrowserPage extends HookConsumerWidget {
|
class LibraryBrowserPage extends HookConsumerWidget {
|
||||||
const LibraryBrowserPage({super.key});
|
const LibraryBrowserPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final currentLibrary = ref.watch(currentLibraryProvider).valueOrNull;
|
||||||
|
|
||||||
|
// Determine the icon to use, with a fallback
|
||||||
|
final IconData libraryIconData =
|
||||||
|
AbsIcons.getIconByName(currentLibrary?.icon) ?? Icons.library_books;
|
||||||
|
|
||||||
|
// Determine the title text
|
||||||
|
final String appBarTitle = '${currentLibrary?.name ?? 'Your'} Library';
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
// Use CustomScrollView to enable slivers
|
||||||
title: const Text('Library'),
|
body: CustomScrollView(
|
||||||
backgroundColor: Colors.transparent,
|
slivers: <Widget>[
|
||||||
),
|
SliverAppBar(
|
||||||
// a list redirecting to authors, genres, and series pages
|
pinned: true,
|
||||||
body: ListView(
|
// floating: true, // Optional: uncomment if you want floating behavior
|
||||||
children: [
|
// snap:
|
||||||
ListTile(
|
// true, // Optional: uncomment if you want snapping behavior (usually with floating: true)
|
||||||
title: const Text('Authors'),
|
leading: IconButton(
|
||||||
leading: const Icon(Icons.person),
|
icon: Icon(libraryIconData),
|
||||||
trailing: const Icon(Icons.chevron_right),
|
tooltip: 'Switch Library', // Helpful tooltip for users
|
||||||
onTap: () {},
|
onPressed: () {
|
||||||
|
showLibrarySwitcher(context, ref);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Text(appBarTitle),
|
||||||
),
|
),
|
||||||
ListTile(
|
SliverList(
|
||||||
title: const Text('Genres'),
|
delegate: SliverChildListDelegate(
|
||||||
leading: const Icon(Icons.category),
|
[
|
||||||
trailing: const Icon(Icons.chevron_right),
|
ListTile(
|
||||||
onTap: () {},
|
title: const Text('Authors'),
|
||||||
),
|
leading: const Icon(Icons.person),
|
||||||
ListTile(
|
trailing: const Icon(Icons.chevron_right),
|
||||||
title: const Text('Series'),
|
onTap: () {
|
||||||
leading: const Icon(Icons.list),
|
showNotImplementedToast(context);
|
||||||
trailing: const Icon(Icons.chevron_right),
|
},
|
||||||
onTap: () {},
|
),
|
||||||
),
|
ListTile(
|
||||||
// Downloads
|
title: const Text('Genres'),
|
||||||
ListTile(
|
leading: const Icon(Icons.category),
|
||||||
title: const Text('Downloads'),
|
trailing: const Icon(Icons.chevron_right),
|
||||||
leading: const Icon(Icons.download),
|
onTap: () {
|
||||||
trailing: const Icon(Icons.chevron_right),
|
showNotImplementedToast(context);
|
||||||
onTap: () {
|
},
|
||||||
GoRouter.of(context).pushNamed(Routes.downloads.name);
|
),
|
||||||
},
|
ListTile(
|
||||||
|
title: const Text('Series'),
|
||||||
|
leading: const Icon(Icons.list),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () {
|
||||||
|
showNotImplementedToast(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// Downloads
|
||||||
|
ListTile(
|
||||||
|
title: const Text('Downloads'),
|
||||||
|
leading: const Icon(Icons.download),
|
||||||
|
trailing: const Icon(Icons.chevron_right),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(Routes.downloads.name);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue