mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55: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,19 +167,11 @@ class RootApp extends HookConsumerWidget {
|
|||||||
return null;
|
return null;
|
||||||
}, [backgroundColor]);
|
}, [backgroundColor]);
|
||||||
|
|
||||||
return AppPopScope(
|
final navTileNames = useMemoized(() {
|
||||||
// Only allow to pop when in root screen
|
return getSidebarTileList(context.l10n).map((s) => s.name).toList();
|
||||||
canPop: routerState.namedLocation(HomePage.name) ==
|
}, []);
|
||||||
routerState.matchedLocation,
|
|
||||||
onPopInvoked: (didPop) async {
|
|
||||||
if (didPop) return;
|
|
||||||
|
|
||||||
final routerState = GoRouterState.of(context);
|
final scaffold = Scaffold(
|
||||||
if (routerState.matchedLocation != "/") {
|
|
||||||
context.goNamed(HomePage.name);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Scaffold(
|
|
||||||
body: Sidebar(child: child),
|
body: Sidebar(child: child),
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
drawerScrimColor: Colors.transparent,
|
drawerScrimColor: Colors.transparent,
|
||||||
@ -217,7 +209,27 @@ class RootApp extends HookConsumerWidget {
|
|||||||
SpotubeNavigationBar(),
|
SpotubeNavigationBar(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
|
||||||
|
if (!kIsAndroid) {
|
||||||
|
return scaffold;
|
||||||
|
}
|
||||||
|
|
||||||
|
final topRoute = GoRouterState.of(context).topRoute;
|
||||||
|
final canPop = topRoute != null && !navTileNames.contains(topRoute.name);
|
||||||
|
|
||||||
|
return AppPopScope(
|
||||||
|
canPop: canPop,
|
||||||
|
onPopInvoked: (didPop) {
|
||||||
|
if (didPop) return;
|
||||||
|
|
||||||
|
if (topRoute?.name == HomePage.name) {
|
||||||
|
SystemNavigator.pop();
|
||||||
|
} else {
|
||||||
|
context.goNamed(HomePage.name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: scaffold,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user