mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 02:59:28 +00:00
downloads and offline playback
This commit is contained in:
parent
1c95d1e4bb
commit
c24541f1cd
38 changed files with 1590 additions and 109 deletions
|
|
@ -43,6 +43,19 @@ class Routes {
|
|||
pathName: 'explore',
|
||||
name: 'explore',
|
||||
);
|
||||
|
||||
// downloads
|
||||
static const downloads = _SimpleRoute(
|
||||
pathName: 'downloads',
|
||||
name: 'downloads',
|
||||
);
|
||||
|
||||
// library browser to browse the library using author, genre, etc.
|
||||
static const libraryBrowser = _SimpleRoute(
|
||||
pathName: 'browser',
|
||||
name: 'libraryBrowser',
|
||||
// parentRoute: library,
|
||||
);
|
||||
}
|
||||
|
||||
// a class to store path
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:whispering_pages/features/downloads/view/downloads_page.dart';
|
||||
import 'package:whispering_pages/features/explore/view/explore_page.dart';
|
||||
import 'package:whispering_pages/features/explore/view/search_result_page.dart';
|
||||
import 'package:whispering_pages/features/item_viewer/view/library_item_page.dart';
|
||||
import 'package:whispering_pages/features/library_browser/view/library_browser_page.dart';
|
||||
import 'package:whispering_pages/features/onboarding/view/onboarding_single_page.dart';
|
||||
import 'package:whispering_pages/pages/home_page.dart';
|
||||
import 'package:whispering_pages/settings/view/app_settings_page.dart';
|
||||
|
|
@ -13,9 +15,9 @@ import 'transitions/slide.dart';
|
|||
|
||||
part 'constants.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> _rootNavigatorKey =
|
||||
final GlobalKey<NavigatorState> rootNavigatorKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'root');
|
||||
final GlobalKey<NavigatorState> _sectionHomeNavigatorKey =
|
||||
final GlobalKey<NavigatorState> sectionHomeNavigatorKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'HomeNavigator');
|
||||
|
||||
// GoRouter configuration
|
||||
|
|
@ -47,7 +49,7 @@ class MyAppRouter {
|
|||
branches: <StatefulShellBranch>[
|
||||
// The route branch for the first tab of the bottom navigation bar.
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _sectionHomeNavigatorKey,
|
||||
navigatorKey: sectionHomeNavigatorKey,
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: Routes.home.path,
|
||||
|
|
@ -76,6 +78,23 @@ class MyAppRouter {
|
|||
);
|
||||
},
|
||||
),
|
||||
// downloads page
|
||||
GoRoute(
|
||||
path: Routes.downloads.path,
|
||||
name: Routes.downloads.name,
|
||||
pageBuilder: defaultPageBuilder(const DownloadsPage()),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Library page
|
||||
StatefulShellBranch(
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: Routes.libraryBrowser.path,
|
||||
name: Routes.libraryBrowser.name,
|
||||
pageBuilder: defaultPageBuilder(const LibraryBrowserPage()),
|
||||
),
|
||||
],
|
||||
),
|
||||
// search/explore page
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:miniplayer/miniplayer.dart';
|
|||
import 'package:whispering_pages/features/explore/providers/search_controller.dart';
|
||||
import 'package:whispering_pages/features/player/providers/player_form.dart';
|
||||
import 'package:whispering_pages/features/player/view/audiobook_player.dart';
|
||||
import 'package:whispering_pages/features/player/view/player_when_expanded.dart';
|
||||
|
||||
// stack to track changes in navigationShell.currentIndex
|
||||
// home is always at index 0 and at the start and should be the last before popping
|
||||
|
|
@ -39,10 +40,11 @@ class ScaffoldWithNavBar extends HookConsumerWidget {
|
|||
final isPlayerExpanded = playerProgress != playerMinHeight;
|
||||
|
||||
debugPrint(
|
||||
'BackButtonListener: Back button pressed, isPlayerExpanded: $isPlayerExpanded, stack: $navigationShellStack',
|
||||
'BackButtonListener: Back button pressed, isPlayerExpanded: $isPlayerExpanded, stack: $navigationShellStack, pendingPlayerModals: $pendingPlayerModals',
|
||||
);
|
||||
|
||||
// close miniplayer if it is open
|
||||
if (isPlayerExpanded) {
|
||||
if (isPlayerExpanded && pendingPlayerModals == 0) {
|
||||
debugPrint(
|
||||
'BackButtonListener: closing the player',
|
||||
);
|
||||
|
|
@ -83,6 +85,7 @@ class ScaffoldWithNavBar extends HookConsumerWidget {
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement a better way to handle back button presses to minimize player
|
||||
return BackButtonListener(
|
||||
onBackButtonPressed: onBackButtonPressed,
|
||||
child: Scaffold(
|
||||
|
|
@ -161,7 +164,7 @@ class ScaffoldWithNavBar extends HookConsumerWidget {
|
|||
// If it is, debugPrint a message to the console.
|
||||
if (index == navigationShell.currentIndex) {
|
||||
// if current branch is explore, open the search view
|
||||
if (index == 1) {
|
||||
if (index == 2) {
|
||||
final searchController = ref.read(globalSearchControllerProvider);
|
||||
// open the search view if not already open
|
||||
if (!searchController.isOpen) {
|
||||
|
|
@ -183,6 +186,12 @@ const _navigationItems = [
|
|||
icon: Icons.home_outlined,
|
||||
activeIcon: Icons.home,
|
||||
),
|
||||
// Library
|
||||
_NavigationItem(
|
||||
name: 'Library',
|
||||
icon: Icons.book_outlined,
|
||||
activeIcon: Icons.book,
|
||||
),
|
||||
_NavigationItem(
|
||||
name: 'Explore',
|
||||
icon: Icons.search_outlined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue