mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
chore: pushed pages not closing
This commit is contained in:
parent
5ff36a8643
commit
1119c0e47d
@ -41,29 +41,33 @@ class PanelController extends ChangeNotifier {
|
|||||||
bool get isAttached => _panelState != null;
|
bool get isAttached => _panelState != null;
|
||||||
|
|
||||||
/// Closes the sliding panel to its collapsed state (i.e. to the minHeight)
|
/// Closes the sliding panel to its collapsed state (i.e. to the minHeight)
|
||||||
Future<void> close() {
|
Future<void> close() async {
|
||||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||||
return _panelState!._close();
|
await _panelState!._close();
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens the sliding panel fully
|
/// Opens the sliding panel fully
|
||||||
/// (i.e. to the maxHeight)
|
/// (i.e. to the maxHeight)
|
||||||
Future<void> open() {
|
Future<void> open() async {
|
||||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||||
return _panelState!._open();
|
await _panelState!._open();
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hides the sliding panel (i.e. is invisible)
|
/// Hides the sliding panel (i.e. is invisible)
|
||||||
Future<void> hide() {
|
Future<void> hide() async {
|
||||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||||
return _panelState!._hide();
|
await _panelState!._hide();
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows the sliding panel in its collapsed state
|
/// Shows the sliding panel in its collapsed state
|
||||||
/// (i.e. "un-hide" the sliding panel)
|
/// (i.e. "un-hide" the sliding panel)
|
||||||
Future<void> show() {
|
Future<void> show() async {
|
||||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||||
return _panelState!._show();
|
await _panelState!._show();
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Animates the panel position to the value.
|
/// Animates the panel position to the value.
|
||||||
|
@ -104,7 +104,6 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
return AppPopScope(
|
return AppPopScope(
|
||||||
canPop: context.canPop(),
|
canPop: context.canPop(),
|
||||||
onPopInvoked: (didPop) async {
|
onPopInvoked: (didPop) async {
|
||||||
if (didPop) return;
|
|
||||||
await panelController.close();
|
await panelController.close();
|
||||||
},
|
},
|
||||||
child: IconTheme(
|
child: IconTheme(
|
||||||
|
@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.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:spotube/collections/side_bar_tiles.dart';
|
||||||
import 'package:spotube/collections/spotube_icons.dart';
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
import 'package:spotube/components/framework/app_pop_scope.dart';
|
import 'package:spotube/components/framework/app_pop_scope.dart';
|
||||||
import 'package:spotube/modules/player/player_queue.dart';
|
import 'package:spotube/modules/player/player_queue.dart';
|
||||||
@ -32,7 +33,6 @@ class RootApp extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final routerState = GoRouterState.of(context);
|
|
||||||
|
|
||||||
final showingDialogCompleter = useRef(Completer()..complete());
|
final showingDialogCompleter = useRef(Completer()..complete());
|
||||||
final downloader = ref.watch(downloadManagerProvider);
|
final downloader = ref.watch(downloadManagerProvider);
|
||||||
@ -167,57 +167,69 @@ class RootApp extends HookConsumerWidget {
|
|||||||
return null;
|
return null;
|
||||||
}, [backgroundColor]);
|
}, [backgroundColor]);
|
||||||
|
|
||||||
|
final navTileNames = useMemoized(() {
|
||||||
|
return getSidebarTileList(context.l10n).map((s) => s.name).toList();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
final scaffold = Scaffold(
|
||||||
|
body: Sidebar(child: child),
|
||||||
|
extendBody: true,
|
||||||
|
drawerScrimColor: Colors.transparent,
|
||||||
|
endDrawer: kIsDesktop
|
||||||
|
? Container(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 800),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
boxShadow: theme.brightness == Brightness.light
|
||||||
|
? null
|
||||||
|
: kElevationToShadow[8],
|
||||||
|
),
|
||||||
|
margin: const EdgeInsets.only(
|
||||||
|
top: 40,
|
||||||
|
bottom: 100,
|
||||||
|
),
|
||||||
|
child: Consumer(
|
||||||
|
builder: (context, ref, _) {
|
||||||
|
final playlist = ref.watch(audioPlayerProvider);
|
||||||
|
final playlistNotifier =
|
||||||
|
ref.read(audioPlayerProvider.notifier);
|
||||||
|
|
||||||
|
return PlayerQueue.fromAudioPlayerNotifier(
|
||||||
|
floating: true,
|
||||||
|
playlist: playlist,
|
||||||
|
notifier: playlistNotifier,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
bottomNavigationBar: const Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
BottomPlayer(),
|
||||||
|
SpotubeNavigationBar(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!kIsAndroid) {
|
||||||
|
return scaffold;
|
||||||
|
}
|
||||||
|
|
||||||
|
final topRoute = GoRouterState.of(context).topRoute;
|
||||||
|
final canPop = topRoute != null && !navTileNames.contains(topRoute.name);
|
||||||
|
|
||||||
return AppPopScope(
|
return AppPopScope(
|
||||||
// Only allow to pop when in root screen
|
canPop: canPop,
|
||||||
canPop: routerState.namedLocation(HomePage.name) ==
|
onPopInvoked: (didPop) {
|
||||||
routerState.matchedLocation,
|
|
||||||
onPopInvoked: (didPop) async {
|
|
||||||
if (didPop) return;
|
if (didPop) return;
|
||||||
|
|
||||||
final routerState = GoRouterState.of(context);
|
if (topRoute?.name == HomePage.name) {
|
||||||
if (routerState.matchedLocation != "/") {
|
SystemNavigator.pop();
|
||||||
|
} else {
|
||||||
context.goNamed(HomePage.name);
|
context.goNamed(HomePage.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: scaffold,
|
||||||
body: Sidebar(child: child),
|
|
||||||
extendBody: true,
|
|
||||||
drawerScrimColor: Colors.transparent,
|
|
||||||
endDrawer: kIsDesktop
|
|
||||||
? Container(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 800),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
boxShadow: theme.brightness == Brightness.light
|
|
||||||
? null
|
|
||||||
: kElevationToShadow[8],
|
|
||||||
),
|
|
||||||
margin: const EdgeInsets.only(
|
|
||||||
top: 40,
|
|
||||||
bottom: 100,
|
|
||||||
),
|
|
||||||
child: Consumer(
|
|
||||||
builder: (context, ref, _) {
|
|
||||||
final playlist = ref.watch(audioPlayerProvider);
|
|
||||||
final playlistNotifier =
|
|
||||||
ref.read(audioPlayerProvider.notifier);
|
|
||||||
|
|
||||||
return PlayerQueue.fromAudioPlayerNotifier(
|
|
||||||
floating: true,
|
|
||||||
playlist: playlist,
|
|
||||||
notifier: playlistNotifier,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
bottomNavigationBar: const Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
BottomPlayer(),
|
|
||||||
SpotubeNavigationBar(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user