Adaptive app bar leading

This commit is contained in:
LittleSheep 2024-07-12 22:37:58 +08:00
parent a2db9a7ae4
commit 156e6f1075
14 changed files with 19 additions and 13 deletions

View File

@ -130,7 +130,7 @@ class _ArticlePublishScreenState extends State<ArticlePublishScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('articlePublish'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -56,7 +56,7 @@ class _CallScreenState extends State<CallScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
centerTitle: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
title: RichText(

View File

@ -193,7 +193,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
return Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(title),
centerTitle: false,
titleSpacing: SolianTheme.titleSpacing(context),

View File

@ -44,7 +44,7 @@ class _ChatScreenState extends State<ChatScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('chat'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -63,7 +63,7 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('draftBox'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -64,7 +64,7 @@ class _HomeScreenState extends State<HomeScreen> {
centerTitle: false,
floating: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
actions: [
const BackgroundStateWidget(),
const NotificationButton(),

View File

@ -134,7 +134,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('postPublish'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -59,7 +59,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('realm'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -99,7 +99,7 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('realmOrganizing'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -91,7 +91,7 @@ class _RealmViewScreenState extends State<RealmViewScreen> {
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: Text(_realm?.name ?? 'loading'.tr),
centerTitle: false,
actions: [

View File

@ -22,7 +22,7 @@ class CenteredShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -44,7 +44,7 @@ class SidebarShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -22,7 +22,7 @@ class TitleShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -4,6 +4,12 @@ import 'package:solian/shells/root_shell.dart';
class AppBarLeadingButton extends StatelessWidget {
const AppBarLeadingButton({super.key});
static Widget? adaptive(BuildContext context) {
final hasContent =
Navigator.canPop(context) || rootScaffoldKey.currentState!.hasDrawer;
return hasContent ? const AppBarLeadingButton() : null;
}
@override
Widget build(BuildContext context) {
if (Navigator.canPop(context)) {