📱 Add a drawer menu button to fix cannot open drawer on android

This commit is contained in:
LittleSheep 2024-12-05 00:02:32 +08:00
parent 5fc03e48a1
commit cae4756747
5 changed files with 32 additions and 0 deletions

View File

@ -4,10 +4,12 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class AccountScreen extends StatelessWidget {
const AccountScreen({super.key});
@ -18,6 +20,11 @@ class AccountScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
title: Text("screenAccount").tr(),
actions: [
IconButton(

View File

@ -3,12 +3,14 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:surface/providers/channel.dart';
import 'package:surface/providers/user_directory.dart';
import 'package:surface/types/chat.dart';
import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class ChatScreen extends StatefulWidget {
const ChatScreen({super.key});
@ -65,6 +67,11 @@ class _ChatScreenState extends State<ChatScreen> {
return Scaffold(
appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
title: Text('screenChat').tr(),
),
floatingActionButton: FloatingActionButton(

View File

@ -5,8 +5,10 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:surface/providers/post.dart';
import 'package:surface/types/post.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
import 'package:surface/widgets/post/post_item.dart';
import 'package:very_good_infinite_list/very_good_infinite_list.dart';
@ -137,6 +139,12 @@ class _ExploreScreenState extends State<ExploreScreen> {
child: CustomScrollView(
slivers: [
SliverAppBar(
leading:
ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
title: Text('screenExplore').tr(),
floating: true,
snap: true,

View File

@ -6,12 +6,14 @@ import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:flutter/material.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/check_in.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class HomeScreenDashEntry {
final String name;
@ -45,6 +47,11 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
title: Text("screenHome").tr(),
),
body: LayoutBuilder(

View File

@ -10,6 +10,8 @@ import 'package:surface/widgets/navigation/app_bottom_navigation.dart';
import 'package:surface/widgets/navigation/app_drawer_navigation.dart';
import 'package:surface/widgets/navigation/app_rail_navigation.dart';
final globalRootScaffoldKey = GlobalKey<ScaffoldState>();
class AppPageScaffold extends StatelessWidget {
final String? title;
final Widget? body;
@ -93,6 +95,7 @@ class AppRootScaffold extends StatelessWidget {
return AppBackground(
isRoot: true,
child: Scaffold(
key: globalRootScaffoldKey,
body: Column(
children: [
ConnectionIndicator(),