import 'package:flutter/material.dart'; import 'user_home.dart'; import 'jadwal_user_screen.dart'; import 'riwayat_laporan_user_screen.dart'; import 'profile_user_screen.dart'; import 'laporan_tab_screen.dart'; class DashboardUser extends StatefulWidget { const DashboardUser({super.key}); @override State createState() => _DashboardUserState(); } class _DashboardUserState extends State { int _currentIndex = 0; late PageController _pageController; @override void initState() { super.initState(); _pageController = PageController(initialPage: _currentIndex); } @override void dispose() { _pageController.dispose(); super.dispose(); } final List _pages = [ const UserHome(), const JadwalUserScreen(), const LaporanTabScreen(), const RiwayatLaporanUserScreen(), const ProfileUserScreen(), ]; final List<({IconData icon, String label})> _navItems = const [ (icon: Icons.dashboard_rounded, label: 'Dashboard'), (icon: Icons.calendar_today_rounded, label: 'Jadwal'), (icon: Icons.assignment_rounded, label: 'Laporan'), (icon: Icons.history_rounded, label: 'Riwayat'), (icon: Icons.person_rounded, label: 'Profile'), ]; @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.withValues(alpha: 0.10), blurRadius: 24, offset: const Offset(0, 4), ), BoxShadow( color: Colors.black.withValues(alpha: 0.06), blurRadius: 4, offset: const Offset(0, 1), ), ], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: List.generate(_navItems.length, (index) { final isActive = _currentIndex == 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( _navItems[index].icon, size: 20, color: isActive ? Colors.white : Colors.grey, ), ), const SizedBox(height: 4), Text( _navItems[index].label, style: TextStyle( fontSize: 11, fontWeight: isActive ? FontWeight.w600 : FontWeight.w400, color: isActive ? const Color(0xFF2F5BEA) : Colors.grey, ), ), ], ), ); }), ), ), ), ); } }