mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
feat: Update theme colors and add Today Schedule screen
- 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
This commit is contained in:
@@ -367,6 +367,24 @@ class SupplementProvider with ChangeNotifier, WidgetsBindingObserver {
|
||||
return _todayIntakes.where((intake) => intake['supplement_id'] == supplementId).length;
|
||||
}
|
||||
|
||||
/// Get the most recent intake for a supplement today
|
||||
Map<String, dynamic>? getMostRecentIntake(int supplementId) {
|
||||
final supplementIntakes = _todayIntakes
|
||||
.where((intake) => intake['supplement_id'] == supplementId)
|
||||
.toList();
|
||||
|
||||
if (supplementIntakes.isEmpty) return null;
|
||||
|
||||
// Sort by takenAt time (most recent first)
|
||||
supplementIntakes.sort((a, b) {
|
||||
final aTime = DateTime.parse(a['takenAt']);
|
||||
final bTime = DateTime.parse(b['takenAt']);
|
||||
return bTime.compareTo(aTime); // Descending order
|
||||
});
|
||||
|
||||
return supplementIntakes.first;
|
||||
}
|
||||
|
||||
Map<String, double> get dailyIngredientIntake {
|
||||
final Map<String, double> ingredientIntake = {};
|
||||
|
||||
|
Reference in New Issue
Block a user