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

View File

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

View File

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

View File

@ -6,12 +6,14 @@ import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart'; import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/check_in.dart'; import 'package:surface/types/check_in.dart';
import 'package:surface/widgets/dialog.dart'; import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class HomeScreenDashEntry { class HomeScreenDashEntry {
final String name; final String name;
@ -45,6 +47,11 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
title: Text("screenHome").tr(), title: Text("screenHome").tr(),
), ),
body: LayoutBuilder( 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_drawer_navigation.dart';
import 'package:surface/widgets/navigation/app_rail_navigation.dart'; import 'package:surface/widgets/navigation/app_rail_navigation.dart';
final globalRootScaffoldKey = GlobalKey<ScaffoldState>();
class AppPageScaffold extends StatelessWidget { class AppPageScaffold extends StatelessWidget {
final String? title; final String? title;
final Widget? body; final Widget? body;
@ -93,6 +95,7 @@ class AppRootScaffold extends StatelessWidget {
return AppBackground( return AppBackground(
isRoot: true, isRoot: true,
child: Scaffold( child: Scaffold(
key: globalRootScaffoldKey,
body: Column( body: Column(
children: [ children: [
ConnectionIndicator(), ConnectionIndicator(),