🐛 Fix bottom navigation everywhere

This commit is contained in:
LittleSheep 2024-06-27 15:50:13 +08:00
parent b913c6a432
commit f239fbbed6
3 changed files with 18 additions and 9 deletions

View File

@ -53,7 +53,6 @@ abstract class AppRouter {
path: '/posts/view/:alias', path: '/posts/view/:alias',
name: 'postDetail', name: 'postDetail',
builder: (context, state) => TitleShell( builder: (context, state) => TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: PostDetailScreen( child: PostDetailScreen(
alias: state.pathParameters['alias']!, alias: state.pathParameters['alias']!,
@ -119,7 +118,6 @@ abstract class AppRouter {
builder: (context, state) { builder: (context, state) {
final arguments = state.extra as ChannelDetailArguments; final arguments = state.extra as ChannelDetailArguments;
return TitleShell( return TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: ChannelDetailScreen( child: ChannelDetailScreen(
channel: arguments.channel, channel: arguments.channel,
@ -152,7 +150,6 @@ abstract class AppRouter {
path: '/realms/:alias/detail', path: '/realms/:alias/detail',
name: 'realmDetail', name: 'realmDetail',
builder: (context, state) => TitleShell( builder: (context, state) => TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: RealmDetailScreen( child: RealmDetailScreen(
realm: state.extra as Realm, realm: state.extra as Realm,
@ -202,7 +199,6 @@ abstract class AppRouter {
path: '/account/friend', path: '/account/friend',
name: 'accountFriend', name: 'accountFriend',
builder: (context, state) => TitleShell( builder: (context, state) => TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: const FriendScreen(), child: const FriendScreen(),
), ),
@ -211,7 +207,6 @@ abstract class AppRouter {
path: '/account/personalize', path: '/account/personalize',
name: 'accountPersonalize', name: 'accountPersonalize',
builder: (context, state) => TitleShell( builder: (context, state) => TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: const PersonalizeScreen(), child: const PersonalizeScreen(),
), ),
@ -220,7 +215,6 @@ abstract class AppRouter {
path: '/about', path: '/about',
name: 'about', name: 'about',
builder: (context, state) => TitleShell( builder: (context, state) => TitleShell(
showAppBar: SolianTheme.isExtraLargeScreen(context),
state: state, state: state,
child: const AboutScreen(), child: const AboutScreen(),
), ),

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:solian/router.dart'; import 'package:solian/router.dart';
import 'package:solian/theme.dart'; import 'package:solian/theme.dart';
import 'package:solian/widgets/navigation/app_navigation.dart';
import 'package:solian/widgets/prev_page.dart'; import 'package:solian/widgets/prev_page.dart';
import 'package:solian/widgets/navigation/app_navigation_bottom_bar.dart'; import 'package:solian/widgets/navigation/app_navigation_bottom_bar.dart';
import 'package:solian/widgets/navigation/app_navigation_rail.dart'; import 'package:solian/widgets/navigation/app_navigation_rail.dart';
@ -11,6 +12,8 @@ import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
class NavShell extends StatelessWidget { class NavShell extends StatelessWidget {
final bool showAppBar; final bool showAppBar;
final bool showSidebar; final bool showSidebar;
final bool showNavigation;
final bool? showBottomNavigation;
final GoRouterState state; final GoRouterState state;
final Widget child; final Widget child;
@ -23,6 +26,8 @@ class NavShell extends StatelessWidget {
required this.state, required this.state,
this.showAppBar = true, this.showAppBar = true,
this.showSidebar = true, this.showSidebar = true,
this.showNavigation = true,
this.showBottomNavigation,
this.sidebarFirst = false, this.sidebarFirst = false,
this.sidebar, this.sidebar,
}); });
@ -47,6 +52,11 @@ class NavShell extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final canPop = AppRouter.instance.canPop(); final canPop = AppRouter.instance.canPop();
final routeName =
AppRouter.instance.routerDelegate.currentConfiguration.last.route.name;
final showBottom = showBottomNavigation ??
AppNavigation.destinationPages.contains(routeName);
return Scaffold( return Scaffold(
appBar: showAppBar appBar: showAppBar
? AppBar( ? AppBar(
@ -58,14 +68,16 @@ class NavShell extends StatelessWidget {
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
) )
: null, : null,
bottomNavigationBar: SolianTheme.isLargeScreen(context) bottomNavigationBar: (SolianTheme.isLargeScreen(context) ||
!(showNavigation && showBottom))
? null ? null
: const AppNavigationBottomBar(), : const AppNavigationBottomBar(),
body: SolianTheme.isLargeScreen(context) body: SolianTheme.isLargeScreen(context)
? Row( ? Row(
children: [ children: [
const AppNavigationRail(), if (showNavigation) const AppNavigationRail(),
const VerticalDivider(thickness: 0.3, width: 1), if (showNavigation)
const VerticalDivider(thickness: 0.3, width: 1),
if (showSidebar && sidebarFirst) if (showSidebar && sidebarFirst)
...buildContent(context).reversed ...buildContent(context).reversed
else if (showSidebar) else if (showSidebar)

View File

@ -24,6 +24,9 @@ abstract class AppNavigation {
page: 'account', page: 'account',
), ),
]; ];
static List<String> get destinationPages =>
AppNavigation.destinations.map((x) => x.page).toList();
} }
class AppNavigationDestination { class AppNavigationDestination {