♻️ New auto impl leading

This commit is contained in:
LittleSheep 2024-12-05 22:22:38 +08:00
parent 5dd2e83389
commit d0a4eeb2b2
11 changed files with 37 additions and 30 deletions

View File

@ -4,12 +4,11 @@ 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/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class AccountScreen extends StatelessWidget {
const AccountScreen({super.key});
@ -20,11 +19,7 @@ class AccountScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
leading: AutoAppBarLeading(),
title: Text("screenAccount").tr(),
actions: [
IconButton(

View File

@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/attachment.dart';
import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/attachment/attachment_detail.dart';
import 'package:surface/widgets/attachment/attachment_item.dart';
import 'package:surface/widgets/dialog.dart';
@ -82,6 +83,7 @@ class _AlbumScreenState extends State<AlbumScreen> {
controller: _scrollController,
slivers: [
SliverAppBar(
leading: AutoAppBarLeading(),
title: Text('screenAlbum').tr(),
),
SliverMasonryGrid.extent(

View File

@ -3,14 +3,13 @@ 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/app_bar_leading.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});
@ -67,11 +66,7 @@ class _ChatScreenState extends State<ChatScreen> {
return Scaffold(
appBar: AppBar(
leading: ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: null,
leading: AutoAppBarLeading(),
title: Text('screenChat').tr(),
),
floatingActionButton: FloatingActionButton(

View File

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

View File

@ -8,6 +8,7 @@ import 'package:surface/providers/relationship.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/account.dart';
import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
@ -166,6 +167,7 @@ class _FriendScreenState extends State<FriendScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: AutoAppBarLeading(),
title: Text('screenFriend').tr(),
),
floatingActionButton: FloatingActionButton(

View File

@ -6,14 +6,13 @@ 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/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class HomeScreenDashEntry {
final String name;
@ -47,11 +46,7 @@ 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,
leading: AutoAppBarLeading(),
title: Text("screenHome").tr(),
),
body: LayoutBuilder(

View File

@ -10,6 +10,7 @@ import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/notification.dart';
import 'package:surface/types/post.dart';
import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
import 'package:surface/widgets/markdown_content.dart';
@ -132,6 +133,7 @@ class _NotificationScreenState extends State<NotificationScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: AutoAppBarLeading(),
title: Text('screenNotification').tr(),
actions: [
IconButton(

View File

@ -8,6 +8,7 @@ import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/realm.dart';
import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
import 'package:surface/widgets/universal_image.dart';
@ -77,6 +78,7 @@ class _RealmScreenState extends State<RealmScreen> {
return Scaffold(
appBar: AppBar(
leading: AutoAppBarLeading(),
title: Text('screenRealm').tr(),
actions: [
IconButton(

View File

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class AutoAppBarLeading extends StatelessWidget {
const AutoAppBarLeading({super.key});
@override
Widget build(BuildContext context) {
return ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
? DrawerButton(onPressed: () {
globalRootScaffoldKey.currentState?.openDrawer();
})
: Navigator.canPop(context)
? BackButton()
: const SizedBox();
}
}

View File

@ -56,7 +56,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
],
).padding(
horizontal: 32,
top: MediaQuery.of(context).padding.top > 16 ? 8 : 16,
top: MediaQuery.of(context).padding.top > 16 ? 8 : 24,
bottom: 8,
),
...destinations.where((ele) => ele.isPinned).map((ele) {

View File

@ -26,6 +26,8 @@
<string>$(PRODUCT_COPYRIGHT)</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.social-networking</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>