mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
- Changed color scheme from ShadBlueColorScheme to ShadZincColorScheme in main.dart - Added getMostRecentIntake method in SupplementProvider to retrieve the latest intake for a supplement - Integrated TodayScheduleScreen into HomeScreen with a new BottomNavigationBar item - Updated SupplementsListScreen title and adjusted layout for better UX - Enhanced SupplementCard to support undoing last taken action and improved popover menu options - Added popover package for better UI interactions
91 lines
2.6 KiB
Dart
91 lines
2.6 KiB
Dart
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<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
int _currentIndex = 0;
|
|
|
|
final List<Widget> _screens = [
|
|
const TodayScheduleScreen(),
|
|
const SupplementsListScreen(),
|
|
const HistoryScreen(),
|
|
const SettingsScreen(),
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
context.read<SupplementProvider>().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<SupplementProvider>().loadSupplements();
|
|
}
|
|
},
|
|
child: const Icon(Icons.add),
|
|
)
|
|
: null,
|
|
);
|
|
}
|
|
}
|