44 lines
1.2 KiB
Dart
44 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'beranda_page.dart';
|
|
import 'kontrol_page.dart';
|
|
import 'akun_page.dart';
|
|
|
|
class MainNavigation extends StatefulWidget {
|
|
const MainNavigation({super.key});
|
|
|
|
@override
|
|
State<MainNavigation> createState() => _MainNavigationState();
|
|
}
|
|
|
|
class _MainNavigationState extends State<MainNavigation> {
|
|
int _currentIndex = 0;
|
|
|
|
final List<Widget> _pages = const [BerandaPage(), KontrolPage(), AkunPage()];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _currentIndex,
|
|
children: _pages,
|
|
), // ⬅ tampilkan halaman aktif
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
backgroundColor: const Color(0xFF6FCF97),
|
|
selectedItemColor: Colors.white,
|
|
unselectedItemColor: Colors.white70,
|
|
currentIndex: _currentIndex,
|
|
onTap: (index) {
|
|
setState(() {
|
|
_currentIndex = index;
|
|
});
|
|
},
|
|
items: const [
|
|
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Beranda"),
|
|
BottomNavigationBarItem(icon: Icon(Icons.settings), label: "Kontrol"),
|
|
BottomNavigationBarItem(icon: Icon(Icons.person), label: "Akun"),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|