2024-08-20 08:36:39 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-04-19 19:17:31 +05:30
|
|
|
import 'package:vaani/api/library_provider.dart' show currentLibraryProvider;
|
2025-10-25 10:38:56 +08:00
|
|
|
import 'package:vaani/features/you/view/widgets/library_switch_chip.dart'
|
|
|
|
|
show showLibrarySwitcher;
|
2025-10-24 11:47:50 +08:00
|
|
|
import 'package:vaani/generated/l10n.dart';
|
2025-04-19 19:17:31 +05:30
|
|
|
import 'package:vaani/router/router.dart' show Routes;
|
|
|
|
|
import 'package:vaani/shared/icons/abs_icons.dart' show AbsIcons;
|
2025-10-25 10:38:56 +08:00
|
|
|
import 'package:vaani/shared/widgets/not_implemented.dart'
|
|
|
|
|
show showNotImplementedToast;
|
2024-08-20 08:36:39 -04:00
|
|
|
|
|
|
|
|
class LibraryBrowserPage extends HookConsumerWidget {
|
|
|
|
|
const LibraryBrowserPage({super.key});
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2025-04-19 19:17:31 +05:30
|
|
|
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
|
2025-10-24 11:47:50 +08:00
|
|
|
final String appBarTitle = currentLibrary?.name ?? S.of(context).library;
|
2025-04-19 19:17:31 +05:30
|
|
|
|
2024-08-20 08:36:39 -04:00
|
|
|
return Scaffold(
|
2025-04-19 19:17:31 +05:30
|
|
|
// Use CustomScrollView to enable slivers
|
|
|
|
|
body: CustomScrollView(
|
|
|
|
|
slivers: <Widget>[
|
|
|
|
|
SliverAppBar(
|
|
|
|
|
pinned: true,
|
|
|
|
|
// floating: true, // Optional: uncomment if you want floating behavior
|
|
|
|
|
// snap:
|
|
|
|
|
// true, // Optional: uncomment if you want snapping behavior (usually with floating: true)
|
|
|
|
|
leading: IconButton(
|
|
|
|
|
icon: Icon(libraryIconData),
|
2025-10-25 10:38:56 +08:00
|
|
|
tooltip: S
|
|
|
|
|
.of(context)
|
|
|
|
|
.librarySwitchTooltip, // Helpful tooltip for users
|
2025-04-19 19:17:31 +05:30
|
|
|
onPressed: () {
|
|
|
|
|
showLibrarySwitcher(context, ref);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
title: Text(appBarTitle),
|
2024-08-20 08:36:39 -04:00
|
|
|
),
|
2025-04-19 19:17:31 +05:30
|
|
|
SliverList(
|
|
|
|
|
delegate: SliverChildListDelegate(
|
|
|
|
|
[
|
|
|
|
|
ListTile(
|
2025-10-24 11:47:50 +08:00
|
|
|
title: Text(S.of(context).bookAuthors),
|
2025-04-19 19:17:31 +05:30
|
|
|
leading: const Icon(Icons.person),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
showNotImplementedToast(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-10-24 11:47:50 +08:00
|
|
|
title: Text(S.of(context).bookGenres),
|
2025-04-19 19:17:31 +05:30
|
|
|
leading: const Icon(Icons.category),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
showNotImplementedToast(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-10-24 11:47:50 +08:00
|
|
|
title: Text(S.of(context).bookSeries),
|
2025-04-19 19:17:31 +05:30
|
|
|
leading: const Icon(Icons.list),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
showNotImplementedToast(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// Downloads
|
|
|
|
|
ListTile(
|
2025-10-24 11:47:50 +08:00
|
|
|
title: Text(S.of(context).bookDownloads),
|
2025-04-19 19:17:31 +05:30
|
|
|
leading: const Icon(Icons.download),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
GoRouter.of(context).pushNamed(Routes.downloads.name);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2024-08-20 08:36:39 -04:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|