MIF_E31231033/lib/screens/dashboard/admin/dashboard_admin.dart

150 lines
5.0 KiB
Dart

import 'package:flutter/material.dart';
import 'admin_home.dart';
import 'laporan_admin_screen.dart';
import 'profile_admin_screen.dart';
import 'kelola_jadwal_screen.dart';
import 'laporan_kejadian_admin_screen.dart';
class DashboardAdmin extends StatefulWidget {
const DashboardAdmin({super.key});
@override
State<DashboardAdmin> createState() => _DashboardAdminState();
}
class _DashboardAdminState extends State<DashboardAdmin> {
int _currentIndex = 0;
late PageController _pageController;
@override
void initState() {
super.initState();
_pageController = PageController();
}
@override
void dispose() {
_pageController.dispose();
super.dispose();
}
final List<Widget> _pages = [
const AdminHome(),
const KelolaJadwalScreen(),
const LaporanKejadianAdminScreen(
namaAdmin: 'Admin',
lokasiKejadian: 'Politeknik Negeri Jember',
),
const LaporanAdminScreen(),
const ProfileAdminScreen(),
];
// label1 = baris atas, label2 = baris bawah (boleh kosong)
final List<({IconData icon, String label1, String label2})> _navItems = const [
(icon: Icons.dashboard_rounded, label1: 'Dashboard', label2: ''),
(icon: Icons.edit_calendar_rounded, label1: 'Kelola', label2: 'Jadwal'),
(icon: Icons.report_problem_rounded, label1: 'Laporan', label2: 'Kejadian'),
(icon: Icons.fact_check_rounded, label1: 'Laporan', label2: 'Patroli'),
(icon: Icons.person_rounded, label1: 'Profile', label2: ''),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (index) => setState(() => _currentIndex = index),
children: _pages,
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 20),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(32),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.10),
blurRadius: 24,
offset: const Offset(0, 4),
),
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 4,
offset: const Offset(0, 1),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(_navItems.length, (index) {
final isActive = _currentIndex == index;
final item = _navItems[index];
return GestureDetector(
onTap: () {
setState(() => _currentIndex = index);
_pageController.animateToPage(
index,
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOut,
width: 44,
height: 44,
decoration: BoxDecoration(
color: isActive
? const Color(0xFF2F5BEA)
: Colors.transparent,
shape: BoxShape.circle,
),
child: Icon(
item.icon,
size: 20,
color: isActive ? Colors.white : Colors.grey,
),
),
const SizedBox(height: 2),
Text(
item.label1,
style: TextStyle(
fontSize: 10,
fontWeight: isActive
? FontWeight.w600
: FontWeight.w400,
color: isActive
? const Color(0xFF2F5BEA)
: Colors.grey,
height: 1.2,
),
),
if (item.label2.isNotEmpty)
Text(
item.label2,
style: TextStyle(
fontSize: 10,
fontWeight: isActive
? FontWeight.w600
: FontWeight.w400,
color: isActive
? const Color(0xFF2F5BEA)
: Colors.grey,
height: 1.2,
),
),
],
),
);
}),
),
),
),
);
}
}