Skip to content

Commit

Permalink
lib/routing+tabs: add bottom navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
octobocto committed Oct 30, 2023
1 parent 9f8afb2 commit 94fc952
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 21 deletions.
58 changes: 58 additions & 0 deletions lib/pages/tabs/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:sail_ui/sail_ui.dart';
import 'package:sail_ui/theme/theme.dart';
import 'package:sidesail/routing/router.dart';

@RoutePage()
class HomePage extends StatelessWidget {
const HomePage({super.key});

@override
Widget build(BuildContext context) {
final theme = SailTheme.of(context);

return AutoTabsRouter.pageView(
homeIndex: 1,
routes: const [
DashboardTabRoute(),
WithdrawalBundleTabRoute(),
WithdrawalTabRoute(),
],
builder: (context, child, _) {
final tabsRouter = AutoTabsRouter.of(context);
return Scaffold(
body: child,
bottomNavigationBar: BottomNavigationBar(
selectedItemColor: theme.colors.orange,
currentIndex: tabsRouter.activeIndex,
onTap: tabsRouter.setActiveIndex,
items: [
BottomNavigationBarItem(
label: 'Dashboard',
icon: SailSVG.icon(
SailSVGAsset.iconDashboardTab,
isHighlighted: tabsRouter.activeIndex == 0,
),
),
BottomNavigationBarItem(
label: 'Withdrawal Bundles',
icon: SailSVG.icon(
SailSVGAsset.iconDashboardTab,
isHighlighted: tabsRouter.activeIndex == 1,
),
),
BottomNavigationBarItem(
label: 'Withdrawals',
icon: SailSVG.icon(
SailSVGAsset.iconDashboardTab,
isHighlighted: tabsRouter.activeIndex == 2,
),
),
],
),
);
},
);
}
}
21 changes: 14 additions & 7 deletions lib/routing/router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/widgets.dart';
import 'package:sidesail/pages/tabs/dashboard_tab_page.dart';
import 'package:sidesail/pages/tabs/home_page.dart';
import 'package:sidesail/pages/tabs/withdrawal_bundle_tab_page.dart';
import 'package:sidesail/pages/tabs/withdrawal_tab_page.dart';
import 'package:sidesail/pages/test_page.dart';
Expand All @@ -26,14 +27,20 @@ class AppRouter extends _$AppRouter {
@override
List<AutoRoute> get routes => [
AutoRoute(
page: DashboardTabRoute.page,
page: HomeRoute.page,
initial: true,
),
AutoRoute(
page: WithdrawalBundleTabRoute.page,
),
AutoRoute(
page: WithdrawalTabRoute.page,
children: [
AutoRoute(
page: DashboardTabRoute.page,
initial: true,
),
AutoRoute(
page: WithdrawalBundleTabRoute.page,
),
AutoRoute(
page: WithdrawalTabRoute.page,
),
],
),

/// This route is used in tests so that we can pump a widget into a route
Expand Down
48 changes: 34 additions & 14 deletions lib/routing/router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/sail_ui/assets/svgs/icon_dashboard_tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 94fc952

Please sign in to comment.