import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/supplement_provider.dart'; import 'add_supplement_screen.dart'; import 'history_screen.dart'; import 'settings_screen.dart'; import 'supplements_list_screen.dart'; import 'today_schedule_screen.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State createState() => _HomeScreenState(); } class _HomeScreenState extends State { int _currentIndex = 0; final List _screens = [ const TodayScheduleScreen(), const SupplementsListScreen(), const HistoryScreen(), const SettingsScreen(), ]; @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { context.read().initialize(); }); } // Persistent reminder checks removed @override Widget build(BuildContext context) { return Scaffold( body: _screens[_currentIndex], bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, onTap: (index) { setState(() { _currentIndex = index; }); }, type: BottomNavigationBarType.fixed, selectedItemColor: Theme.of(context).colorScheme.primary, unselectedItemColor: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.4), backgroundColor: Theme.of(context).colorScheme.surface, items: const [ BottomNavigationBarItem( icon: Icon(Icons.medication_liquid_sharp), label: 'Supplements', ), BottomNavigationBarItem( icon: Icon(Icons.edit_calendar_rounded), label: 'Edit', ), BottomNavigationBarItem( icon: Icon(Icons.history), label: 'History', ), BottomNavigationBarItem( icon: Icon(Icons.settings), label: 'Settings', ), ], ), floatingActionButton: _currentIndex == 1 ? FloatingActionButton( onPressed: () async { await Navigator.of(context).push( MaterialPageRoute( builder: (context) => const AddSupplementScreen(), ), ); // Refresh the list when returning from add screen if (context.mounted) { context.read().loadSupplements(); } }, child: const Icon(Icons.add), ) : null, ); } }