fix: bug of back button in rtl flutter 3.24

This commit is contained in:
Hiddify
2024-08-20 01:52:44 -04:00
parent 1c65c35172
commit 4726c8ad8b

View File

@@ -1,13 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:hiddify/bootstrap.dart';
import 'package:hiddify/core/router/router.dart'; import 'package:hiddify/core/router/router.dart';
import 'package:hiddify/features/common/adaptive_root_scaffold.dart'; import 'package:hiddify/features/common/adaptive_root_scaffold.dart';
import 'package:hiddify/utils/utils.dart';
bool showDrawerButton(BuildContext context) { bool showDrawerButton(BuildContext context) {
if (!useMobileRouter) return true; if (!useMobileRouter) return true;
final String location = GoRouterState.of(context).uri.path; final String location = GoRouterState.of(context).uri.path;
if (location == const HomeRoute().location || if (location == const HomeRoute().location || location == const ProfilesOverviewRoute().location) return true;
location == const ProfilesOverviewRoute().location) return true;
if (location.startsWith(const ProxiesRoute().location)) return true; if (location.startsWith(const ProxiesRoute().location)) return true;
return false; return false;
} }
@@ -33,14 +34,19 @@ class NestedAppBar extends StatelessWidget {
RootScaffold.canShowDrawer(context); RootScaffold.canShowDrawer(context);
return SliverAppBar( return SliverAppBar(
leading: (RootScaffold.stateKey.currentState?.hasDrawer ?? false) && leading: (RootScaffold.stateKey.currentState?.hasDrawer ?? false) && showDrawerButton(context)
showDrawerButton(context)
? DrawerButton( ? DrawerButton(
onPressed: () { onPressed: () {
RootScaffold.stateKey.currentState?.openDrawer(); RootScaffold.stateKey.currentState?.openDrawer();
}, },
) )
: null, : IconButton(
icon: Icon(context.isRtl ? Icons.arrow_forward : Icons.arrow_back),
padding: EdgeInsets.only(right: context.isRtl ? 50 : 0),
onPressed: () {
Navigator.of(context).pop(); // Pops the current route off the navigator stack
},
),
title: title, title: title,
actions: actions, actions: actions,
pinned: pinned, pinned: pinned,