Layout and Push Fix

This commit is contained in:
2026-03-28 23:44:56 +01:00
parent 74722b5e81
commit cf3d7557aa
13 changed files with 429 additions and 282 deletions
+43 -6
View File
@@ -85,17 +85,20 @@ public partial class WeekViewModel : ObservableObject
var date = WeekStart.AddDays(i);
var dayEntries = entries.Where(x => x.EntryDate.Date == date.Date).ToList();
var morningAverage = _aggregationService.CalculateAverage(_aggregationService.FilterForDayPart(dayEntries, DayPart.Morning));
var afternoonAverage = _aggregationService.CalculateAverage(_aggregationService.FilterForDayPart(dayEntries, DayPart.Afternoon));
var morningEntries = _aggregationService.FilterForDayPart(dayEntries, DayPart.Morning).ToList();
var afternoonEntries = _aggregationService.FilterForDayPart(dayEntries, DayPart.Afternoon).ToList();
var morningWorstState = CalculateWorstState(morningEntries);
var afternoonWorstState = CalculateWorstState(afternoonEntries);
Days.Add(new WeekDaySummaryViewModel
{
Date = date,
DateText = DateHelper.ToGermanShortDay(date),
MorningText = _aggregationService.ToDisplayText(morningAverage, _appearanceService),
AfternoonText = _aggregationService.ToDisplayText(afternoonAverage, _appearanceService),
MorningColor = _appearanceService.GetColor(morningAverage.State.ToAppearanceColorKey(), "#1F242B"),
AfternoonColor = _appearanceService.GetColor(afternoonAverage.State.ToAppearanceColorKey(), "#1F242B"),
MorningText = GetStateText(morningWorstState),
AfternoonText = GetStateText(afternoonWorstState),
MorningColor = GetStateColor(morningWorstState),
AfternoonColor = GetStateColor(afternoonWorstState),
ActivitiesText = _aggregationService.BuildDistinctActivityText(dayEntries, activityMap),
SymptomsText = _aggregationService.BuildDistinctSymptomText(dayEntries, symptomsMap)
});
@@ -137,6 +140,7 @@ public partial class WeekViewModel : ObservableObject
_calendarStateService.SelectedDate = SelectedDate;
await RefreshAsync();
}
private async Task TodayAsync()
{
var today = DateTime.Today;
@@ -153,4 +157,37 @@ public partial class WeekViewModel : ObservableObject
await RefreshAsync();
});
}
private string GetStateText(HealthState? state) => state switch
{
HealthState.Green => _appearanceService.GetText(AppearanceKeys.StatusGreenText, "Grün"),
HealthState.Yellow => _appearanceService.GetText(AppearanceKeys.StatusYellowText, "Gelb"),
HealthState.Red => _appearanceService.GetText(AppearanceKeys.StatusRedText, "Rot"),
HealthState.Gray => _appearanceService.GetText(AppearanceKeys.StatusGrayText, "Schwarz"),
_ => "-"
};
private Color GetStateColor(HealthState? state)
{
return state.HasValue
? _appearanceService.GetColor(state.Value.ToAppearanceColorKey(), "#1F242B")
: Colors.Transparent;
}
private static HealthState? CalculateWorstState(IReadOnlyCollection<HealthEntry> entries)
{
if (entries.Count == 0)
return null;
if (entries.Any(x => x.State == HealthState.Gray))
return HealthState.Gray;
if (entries.Any(x => x.State == HealthState.Red))
return HealthState.Red;
if (entries.Any(x => x.State == HealthState.Yellow))
return HealthState.Yellow;
return HealthState.Green;
}
}