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 authored and torkelrogstad committed Oct 30, 2023
1 parent c916839 commit eb58d21
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 23 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.
4 changes: 2 additions & 2 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter_test/flutter_test.dart';
import 'package:sidesail/pages/tabs/home_page.dart';
import 'package:sidesail/pages/tabs/dashboard_tab_page.dart';

import 'test_utils.dart';

void main() {
testWidgets('RPC submit smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpSailPage(
const HomePage(),
const DashboardTabPage(),
);

// Verify that there's a submit button.
Expand Down

0 comments on commit eb58d21

Please sign in to comment.