80 lines
2.0 KiB
Dart
80 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'history_screen.dart';
|
|
import 'profile_screen.dart';
|
|
import 'dashboard.dart'; // pastikan Dashboard ada di file ini
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
int index = 0;
|
|
|
|
List<Widget> pages = [
|
|
Dashboard(),
|
|
HistoryScreen(),
|
|
ProfileScreen(),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.grey[200],
|
|
body: Stack(
|
|
children: [
|
|
/// PAGE CONTENT
|
|
pages[index],
|
|
|
|
/// FLOATING NAVBAR
|
|
Positioned(
|
|
bottom: 25,
|
|
left: 60,
|
|
right: 60,
|
|
child: Container(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[300],
|
|
borderRadius: BorderRadius.circular(40),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Colors.black26,
|
|
blurRadius: 6,
|
|
offset: Offset(0, 4),
|
|
)
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
_navItem(Icons.grid_view, 0),
|
|
_navItem(Icons.history, 1),
|
|
_navItem(Icons.person, 2),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _navItem(IconData icon, int i) {
|
|
final isActive = index == i;
|
|
|
|
return GestureDetector(
|
|
onTap: () => setState(() => index = i),
|
|
child: Container(
|
|
width: 45,
|
|
height: 45,
|
|
decoration: BoxDecoration(
|
|
color: isActive ? Colors.black : Colors.grey[400],
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(icon, color: Colors.white),
|
|
),
|
|
);
|
|
}
|
|
} |