fix: Fix BottomBar showing incorrect animation when navigating from sibling routes

pull/203/head
Inex Code 2023-02-24 15:13:17 +03:00 committed by Gitea
parent 9d6721d58b
commit 9a8965f569
2 changed files with 14 additions and 12 deletions

View File

@ -36,18 +36,19 @@ class RootScaffoldWithNavigation extends StatelessWidget {
body: Row(
children: [
if (Breakpoints.medium.isActive(context))
MainScreenNavigationRail(
_MainScreenNavigationRail(
destinations: destinations,
showFab: showFab,
),
if (Breakpoints.large.isActive(context))
MainScreenNavigationDrawer(
_MainScreenNavigationDrawer(
destinations: destinations,
showFab: showFab,
),
Expanded(child: child),
],
),
bottomNavigationBar: BottomBar(
bottomNavigationBar: _BottomBar(
destinations: destinations,
hidden: !(Breakpoints.small.isActive(context) && showBottomBar),
key: const Key('bottomBar'),
@ -104,11 +105,10 @@ class _RootAppBar extends StatelessWidget {
);
}
class MainScreenNavigationRail extends StatelessWidget {
const MainScreenNavigationRail({
class _MainScreenNavigationRail extends StatelessWidget {
const _MainScreenNavigationRail({
required this.destinations,
this.showFab = true,
super.key,
});
final List<RouteDestination> destinations;
@ -173,8 +173,8 @@ class MainScreenNavigationRail extends StatelessWidget {
}
}
class BottomBar extends StatelessWidget {
const BottomBar({
class _BottomBar extends StatelessWidget {
const _BottomBar({
required this.destinations,
required this.hidden,
super.key,
@ -219,11 +219,10 @@ class BottomBar extends StatelessWidget {
}
}
class MainScreenNavigationDrawer extends StatelessWidget {
const MainScreenNavigationDrawer({
class _MainScreenNavigationDrawer extends StatelessWidget {
const _MainScreenNavigationDrawer({
required this.destinations,
this.showFab = true,
super.key,
});
final List<RouteDestination> destinations;

View File

@ -38,11 +38,14 @@ class _RootPageState extends State<RootPage> with TickerProviderStateMixin {
(final destination) =>
context.router.isRouteActive(destination.route.routeName),
);
final isOtherRouterActive =
context.router.root.current.name != RootRoute.name;
final routeName = getRouteTitle(context.router.current.name).tr();
return RootScaffoldWithNavigation(
title: routeName,
destinations: destinations,
showBottomBar: !(currentDestinationIndex == -1),
showBottomBar:
!(currentDestinationIndex == -1 && !isOtherRouterActive),
showFab: isReady,
child: child,
);