151 lines
3.7 KiB
Dart
151 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'home_screen.dart';
|
|
import 'history_screen.dart';
|
|
import 'scan_qr_screen.dart'; // <-- TAMBAH INI
|
|
|
|
class DashboardScreen extends StatefulWidget {
|
|
const DashboardScreen({super.key});
|
|
|
|
@override
|
|
State<DashboardScreen> createState() =>
|
|
_DashboardScreenState();
|
|
}
|
|
|
|
class _DashboardScreenState
|
|
extends State<DashboardScreen> {
|
|
int _selectedIndex = 0;
|
|
|
|
final List<Widget> _screens = const [
|
|
HomeScreen(),
|
|
HistoryScreen()
|
|
];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
Widget _buildNavItem({
|
|
required IconData icon,
|
|
required String label,
|
|
required int index,
|
|
}) {
|
|
final bool isActive =
|
|
_selectedIndex == index;
|
|
|
|
return InkWell(
|
|
onTap: () => _onItemTapped(index),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: 22,
|
|
color: isActive
|
|
? const Color(0xFF0F2D13)
|
|
: Colors.black54,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: isActive
|
|
? FontWeight.w600
|
|
: FontWeight.w400,
|
|
color: isActive
|
|
? const Color(0xFF0F2D13)
|
|
: Colors.black54,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
extendBody: true,
|
|
body: _screens[_selectedIndex],
|
|
|
|
// ================= QRIS BUTTON =================
|
|
floatingActionButton: SizedBox(
|
|
width: 75,
|
|
height: 75,
|
|
child: FloatingActionButton(
|
|
backgroundColor:
|
|
const Color.fromARGB(255, 20, 40, 0),
|
|
shape: const CircleBorder(),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) =>
|
|
const ScanQrScreen(),
|
|
),
|
|
);
|
|
},
|
|
child: const Icon(
|
|
Icons.qr_code_scanner,
|
|
size: 32,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
|
|
floatingActionButtonLocation:
|
|
FloatingActionButtonLocation
|
|
.centerDocked,
|
|
|
|
// ================= BOTTOM NAV =================
|
|
bottomNavigationBar: Container(
|
|
decoration: const BoxDecoration(
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black26,
|
|
blurRadius: 10,
|
|
offset: Offset(0, -3),
|
|
),
|
|
],
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
const BorderRadius.only(
|
|
topLeft: Radius.circular(30),
|
|
topRight: Radius.circular(30),
|
|
),
|
|
child: BottomAppBar(
|
|
shape:
|
|
const CircularNotchedRectangle(),
|
|
notchMargin: 8,
|
|
color:
|
|
const Color.fromARGB(255, 223, 242, 112),
|
|
child: SizedBox(
|
|
height: 70,
|
|
child: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.spaceAround,
|
|
children: [
|
|
_buildNavItem(
|
|
icon: Icons.home_outlined,
|
|
label: "Home",
|
|
index: 0,
|
|
),
|
|
const SizedBox(width: 40),
|
|
_buildNavItem(
|
|
icon: Icons.history,
|
|
label: "History",
|
|
index: 1,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |