47 lines
1.0 KiB
Dart
47 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'home.dart';
|
|
import 'history.dart';
|
|
|
|
class BottomBar extends StatefulWidget {
|
|
const BottomBar({super.key});
|
|
|
|
@override
|
|
State<BottomBar> createState() => _BottomBarState();
|
|
}
|
|
|
|
class _BottomBarState extends State<BottomBar> {
|
|
int _selectedIndex = 0;
|
|
|
|
static final List<Widget> _pages = [
|
|
const HomePage(),
|
|
const HistoryPage(),
|
|
];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: _pages[_selectedIndex],
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
items: const <BottomNavigationBarItem>[
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.home),
|
|
label: 'Beranda',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.history),
|
|
label: 'Riwayat',
|
|
),
|
|
],
|
|
currentIndex: _selectedIndex,
|
|
selectedItemColor: Colors.blue,
|
|
onTap: _onItemTapped,
|
|
),
|
|
);
|
|
}
|
|
} |