fixed back button navigation
This commit is contained in:
@@ -8,12 +8,15 @@ import 'package:go_router/go_router.dart';
|
||||
part 'routes.g.dart';
|
||||
|
||||
@TypedGoRoute<KagiRoute>(
|
||||
name: 'KagiRoute',
|
||||
path: '/',
|
||||
routes: [
|
||||
TypedGoRoute<AboutRoute>(
|
||||
name: 'AboutRoute',
|
||||
path: 'about',
|
||||
),
|
||||
TypedGoRoute<SettingsRoute>(
|
||||
name: 'SettingsRoute',
|
||||
path: 'settings',
|
||||
),
|
||||
],
|
||||
|
||||
@@ -12,14 +12,17 @@ List<RouteBase> get $appRoutes => [
|
||||
|
||||
RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
path: '/',
|
||||
name: 'KagiRoute',
|
||||
factory: $KagiRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'about',
|
||||
name: 'AboutRoute',
|
||||
factory: $AboutRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'settings',
|
||||
name: 'SettingsRoute',
|
||||
factory: $SettingsRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -249,6 +249,16 @@ class KagiScreen extends HookConsumerWidget {
|
||||
|
||||
return BackButtonListener(
|
||||
onBackButtonPressed: () async {
|
||||
//Don't do anything if a child route is active
|
||||
if (GoRouterState.of(context).topRoute?.name != 'KagiRoute') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (displayedSheet != null) {
|
||||
ref.read(bottomSheetProvider.notifier).dismiss();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (activeWebView?.page.value.pageHistory.canGoBack == true) {
|
||||
lastBackButtonPress.value = null;
|
||||
|
||||
@@ -257,7 +267,7 @@ class KagiScreen extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
if (lastBackButtonPress.value != null &&
|
||||
lastBackButtonPress.value!.difference(DateTime.now()) <
|
||||
DateTime.now().difference(lastBackButtonPress.value!) <
|
||||
const Duration(seconds: 2)) {
|
||||
lastBackButtonPress.value = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user