♻️ Refactored nav completely
This commit is contained in:
@ -37,17 +37,15 @@ class _AppBottomNavigationBarState extends State<AppBottomNavigationBar> {
|
||||
...nav.destinations.where((ele) => ele.isPinned),
|
||||
];
|
||||
|
||||
return BottomNavigationBar(
|
||||
currentIndex: nav.getIndexInRange(0, nav.pinnedDestinationCount),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
showUnselectedLabels: false,
|
||||
items: destinations.map((ele) {
|
||||
return BottomNavigationBarItem(
|
||||
return NavigationBar(
|
||||
selectedIndex: nav.getIndexInRange(0, nav.pinnedDestinationCount),
|
||||
destinations: destinations.map((ele) {
|
||||
return NavigationDestination(
|
||||
icon: ele.icon,
|
||||
label: ele.label.tr(),
|
||||
);
|
||||
}).toList(),
|
||||
onTap: (idx) {
|
||||
onDestinationSelected: (idx) {
|
||||
nav.setIndex(idx);
|
||||
GoRouter.of(context).goNamed(destinations[idx].screen);
|
||||
},
|
||||
|
@ -78,27 +78,29 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
Expanded(
|
||||
child: _DrawerContentList(),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: nav.destinations.where((ele) => ele.isPinned).map(
|
||||
(ele) {
|
||||
return Expanded(
|
||||
child: Tooltip(
|
||||
message: ele.label.tr(),
|
||||
child: IconButton.filledTonal(
|
||||
icon: ele.icon,
|
||||
color:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
onPressed: () {
|
||||
GoRouter.of(context).goNamed(ele.screen);
|
||||
Scaffold.of(context).closeDrawer();
|
||||
},
|
||||
if (cfg.hideBottomNav)
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: nav.destinations.where((ele) => ele.isPinned).map(
|
||||
(ele) {
|
||||
return Expanded(
|
||||
child: Tooltip(
|
||||
message: ele.label.tr(),
|
||||
child: IconButton.filledTonal(
|
||||
icon: ele.icon,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimaryContainer,
|
||||
onPressed: () {
|
||||
GoRouter.of(context).goNamed(ele.screen);
|
||||
Scaffold.of(context).closeDrawer();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
).padding(horizontal: 16),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
).padding(horizontal: 16),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: ListTile(
|
||||
|
@ -12,6 +12,7 @@ import 'package:surface/providers/config.dart';
|
||||
import 'package:surface/providers/navigation.dart';
|
||||
import 'package:surface/widgets/connection_indicator.dart';
|
||||
import 'package:surface/widgets/navigation/app_background.dart';
|
||||
import 'package:surface/widgets/navigation/app_bottom_navigation.dart';
|
||||
import 'package:surface/widgets/navigation/app_drawer_navigation.dart';
|
||||
import 'package:surface/widgets/navigation/app_rail_navigation.dart';
|
||||
import 'package:surface/widgets/notify_indicator.dart';
|
||||
@ -106,6 +107,7 @@ class AppRootScaffold extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cfg = context.watch<ConfigProvider>();
|
||||
final nav = context.watch<NavigationProvider>();
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
|
||||
final isCollapseDrawer = cfg.drawerIsCollapsed;
|
||||
@ -117,6 +119,11 @@ class AppRootScaffold extends StatelessWidget {
|
||||
.last
|
||||
.route
|
||||
.name;
|
||||
final isShowBottomNavigation = cfg.hideBottomNav
|
||||
? false
|
||||
: nav.showBottomNavScreen.contains(routeName)
|
||||
? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
|
||||
: false;
|
||||
final isPopable = !NavigationProvider.kAllDestination
|
||||
.map((ele) => ele.screen)
|
||||
.contains(routeName);
|
||||
@ -227,6 +234,8 @@ class AppRootScaffold extends StatelessWidget {
|
||||
),
|
||||
drawer: !isExpandedDrawer ? AppNavigationDrawer() : null,
|
||||
drawerEdgeDragWidth: isPopable ? 0 : null,
|
||||
bottomNavigationBar:
|
||||
isShowBottomNavigation ? AppBottomNavigationBar() : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user