diff --git a/lib/screens/articles/article_editor.dart b/lib/screens/articles/article_editor.dart index 2ca8ac8..dd655a3 100644 --- a/lib/screens/articles/article_editor.dart +++ b/lib/screens/articles/article_editor.dart @@ -130,7 +130,7 @@ class _ArticlePublishScreenState extends State { 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), diff --git a/lib/screens/channel/call/call.dart b/lib/screens/channel/call/call.dart index af6dec6..bc037d0 100644 --- a/lib/screens/channel/call/call.dart +++ b/lib/screens/channel/call/call.dart @@ -56,7 +56,7 @@ class _CallScreenState extends State { 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( diff --git a/lib/screens/channel/channel_chat.dart b/lib/screens/channel/channel_chat.dart index a26b45e..e6c6d29 100644 --- a/lib/screens/channel/channel_chat.dart +++ b/lib/screens/channel/channel_chat.dart @@ -193,7 +193,7 @@ class _ChannelChatScreenState extends State { return Scaffold( appBar: AppBar( - leading: const AppBarLeadingButton(), + leading: AppBarLeadingButton.adaptive(context), title: AppBarTitle(title), centerTitle: false, titleSpacing: SolianTheme.titleSpacing(context), diff --git a/lib/screens/chat.dart b/lib/screens/chat.dart index 827ffea..497a68f 100644 --- a/lib/screens/chat.dart +++ b/lib/screens/chat.dart @@ -44,7 +44,7 @@ class _ChatScreenState extends State { 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), diff --git a/lib/screens/feed/draft_box.dart b/lib/screens/feed/draft_box.dart index d1bc378..c2d4067 100644 --- a/lib/screens/feed/draft_box.dart +++ b/lib/screens/feed/draft_box.dart @@ -63,7 +63,7 @@ class _DraftBoxScreenState extends State { 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), diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 543a906..058830a 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -64,7 +64,7 @@ class _HomeScreenState extends State { centerTitle: false, floating: true, toolbarHeight: SolianTheme.toolbarHeight(context), - leading: const AppBarLeadingButton(), + leading: AppBarLeadingButton.adaptive(context), actions: [ const BackgroundStateWidget(), const NotificationButton(), diff --git a/lib/screens/posts/post_editor.dart b/lib/screens/posts/post_editor.dart index 0c3bc3b..ceb323a 100644 --- a/lib/screens/posts/post_editor.dart +++ b/lib/screens/posts/post_editor.dart @@ -134,7 +134,7 @@ class _PostPublishScreenState extends State { 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), diff --git a/lib/screens/realms.dart b/lib/screens/realms.dart index e50bee6..df04241 100644 --- a/lib/screens/realms.dart +++ b/lib/screens/realms.dart @@ -59,7 +59,7 @@ class _RealmListScreenState extends State { 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), diff --git a/lib/screens/realms/realm_organize.dart b/lib/screens/realms/realm_organize.dart index 6d3a227..21832a1 100644 --- a/lib/screens/realms/realm_organize.dart +++ b/lib/screens/realms/realm_organize.dart @@ -99,7 +99,7 @@ class _RealmOrganizeScreenState extends State { 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), diff --git a/lib/screens/realms/realm_view.dart b/lib/screens/realms/realm_view.dart index e2029c7..177cce1 100644 --- a/lib/screens/realms/realm_view.dart +++ b/lib/screens/realms/realm_view.dart @@ -91,7 +91,7 @@ class _RealmViewScreenState extends State { handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), sliver: SliverAppBar( - leading: const AppBarLeadingButton(), + leading: AppBarLeadingButton.adaptive(context), title: Text(_realm?.name ?? 'loading'.tr), centerTitle: false, actions: [ diff --git a/lib/shells/centered_shell.dart b/lib/shells/centered_shell.dart index d5ac332..fbfa20e 100644 --- a/lib/shells/centered_shell.dart +++ b/lib/shells/centered_shell.dart @@ -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), diff --git a/lib/shells/sidebar_shell.dart b/lib/shells/sidebar_shell.dart index 0eeabe9..866aeb0 100644 --- a/lib/shells/sidebar_shell.dart +++ b/lib/shells/sidebar_shell.dart @@ -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), diff --git a/lib/shells/title_shell.dart b/lib/shells/title_shell.dart index b3ca757..c45c866 100644 --- a/lib/shells/title_shell.dart +++ b/lib/shells/title_shell.dart @@ -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), diff --git a/lib/widgets/app_bar_leading.dart b/lib/widgets/app_bar_leading.dart index 7cb0532..8abc1e1 100644 --- a/lib/widgets/app_bar_leading.dart +++ b/lib/widgets/app_bar_leading.dart @@ -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)) {