import 'package:flutter/material.dart'; import 'dashboard/dashboard_screen.dart'; import 'control/control_screen.dart'; import 'setting/setting_screen.dart'; class MainScreen extends StatefulWidget { const MainScreen({super.key}); @override State createState() => _MainScreenState(); } class _MainScreenState extends State { int _selectedIndex = 0; final List _screens = const [ DashboardScreen(), ControlScreen(), SettingScreen(), ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } Widget buildIconButton(IconData icon, String label, int index) { final isSelected = _selectedIndex == index; final color = isSelected ? Colors.green[700] : Colors.grey; return Flexible( fit: FlexFit.tight, child: InkWell( onTap: () => _onItemTapped(index), child: Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ Icon(icon, color: color, size: 26), const SizedBox(height: 2), FittedBox( child: Text( label, style: TextStyle( color: color, fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontSize: 11, ), ), ), ], ), ), ), ); } @override Widget build(BuildContext context) { return Scaffold( extendBody: true, resizeToAvoidBottomInset: true, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: SizedBox( width: 66, height: 66, child: FloatingActionButton( onPressed: () => _onItemTapped(0), // Dashboard / Monitoring di tengah backgroundColor: _selectedIndex == 0 ? const Color.fromRGBO(56, 142, 60, 1) : Colors.green[400], elevation: _selectedIndex == 0 ? 8 : 4, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(35), ), child: const Icon( Icons.analytics_outlined, // ikon monitoring yang keren size: 35, color: Colors.white, ), ), ), bottomNavigationBar: SafeArea( child: BottomAppBar( shape: const CircularNotchedRectangle(), notchMargin: 8, elevation: 8, color: const Color.fromARGB(255, 255, 255, 255), child: SizedBox( height: 60, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ buildIconButton(Icons.settings_remote_outlined, 'Control', 1), const SizedBox(width: 56), // space untuk FAB buildIconButton(Icons.settings, 'Setting', 2), ], ), ), ), ), body: _screens[_selectedIndex], ); } }