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