58 lines
1.5 KiB
Dart
58 lines
1.5 KiB
Dart
/// Host scaffold that owns the bottom navigation bar and its tabs.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'balance_screen.dart';
|
|
import 'settings_screen.dart';
|
|
import 'transactions_screen.dart';
|
|
|
|
/// Switches between Balance, Transactions, and Settings without stacking routes.
|
|
class MainShell extends StatefulWidget {
|
|
const MainShell({super.key});
|
|
|
|
@override
|
|
State<MainShell> createState() => _MainShellState();
|
|
}
|
|
|
|
class _MainShellState extends State<MainShell> {
|
|
int _index = 0;
|
|
|
|
static const _pages = [
|
|
BalanceScreen(),
|
|
TransactionsScreen(),
|
|
SettingsScreen(),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _index,
|
|
children: _pages,
|
|
),
|
|
bottomNavigationBar: NavigationBar(
|
|
selectedIndex: _index,
|
|
onDestinationSelected: (index) => setState(() => _index = index),
|
|
destinations: const [
|
|
NavigationDestination(
|
|
icon: Icon(Icons.account_balance_wallet_outlined),
|
|
selectedIcon: Icon(Icons.account_balance_wallet),
|
|
label: 'Balance',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.receipt_long_outlined),
|
|
selectedIcon: Icon(Icons.receipt_long),
|
|
label: 'Transactions',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.settings_outlined),
|
|
selectedIcon: Icon(Icons.settings),
|
|
label: 'Settings',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|