Details ausgearbeitet
Linked colors to options menu Options extension Aussehen aufgebohrt: - erlaubt text von status zu ändern, - bessere beschriftung von Farben desing änderung und bedienung - heute status felder anklickbar, - Farbpalette verdunkelt und kontrast reduziert - Kalender Tage anklickbar gemacht - Optionen überarbeitet
This commit is contained in:
+31
-40
@@ -1,13 +1,12 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using cfs_tracker.Data;
|
||||
using cfs_tracker.Models;
|
||||
using cfs_tracker.Services;
|
||||
using cfs_tracker.ViewModels;
|
||||
using cfs_tracker.Views;
|
||||
using Microsoft.Maui.Graphics;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using cfs_tracker.Data;
|
||||
using cfs_tracker.Helpers;
|
||||
using cfs_tracker.Models;
|
||||
using cfs_tracker.Services;
|
||||
using Microsoft.Maui.Graphics;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
@@ -15,12 +14,13 @@ public partial class WeekViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly AggregationService _aggregationService;
|
||||
private readonly CalendarStateService _calendarState;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime anchorDate = DateTime.Today;
|
||||
|
||||
[ObservableProperty]
|
||||
private string weekText = "";
|
||||
private string weekText = string.Empty;
|
||||
|
||||
public ObservableCollection<WeekCellViewModel> Days { get; } = new();
|
||||
|
||||
@@ -31,10 +31,12 @@ public partial class WeekViewModel : ObservableObject
|
||||
|
||||
public WeekViewModel(
|
||||
HealthEntryRepository repository,
|
||||
AggregationService aggregationService)
|
||||
AggregationService aggregationService,
|
||||
CalendarStateService calendarState)
|
||||
{
|
||||
_repository = repository;
|
||||
_aggregationService = aggregationService;
|
||||
_calendarState = calendarState;
|
||||
|
||||
PreviousWeekCommand = new AsyncRelayCommand(PreviousWeekAsync);
|
||||
NextWeekCommand = new AsyncRelayCommand(NextWeekAsync);
|
||||
@@ -68,14 +70,14 @@ public partial class WeekViewModel : ObservableObject
|
||||
Date = summary.Date,
|
||||
DayText = summary.Date.ToString("ddd", new CultureInfo("de-DE")),
|
||||
DateText = summary.Date.ToString("dd.MM"),
|
||||
MorningText = summary.MorningAverage.HasValue ? StateLabel(morningState) : "—",
|
||||
AfternoonText = summary.AfternoonAverage.HasValue ? StateLabel(afternoonState) : "—",
|
||||
MorningCountText = summary.MorningCount > 0 ? $"{summary.MorningCount}x" : "",
|
||||
AfternoonCountText = summary.AfternoonCount > 0 ? $"{summary.AfternoonCount}x" : "",
|
||||
MorningText = StateLabel(morningState),
|
||||
AfternoonText = StateLabel(afternoonState),
|
||||
MorningCountText = summary.MorningCount > 0 ? $"{summary.MorningCount}x" : string.Empty,
|
||||
AfternoonCountText = summary.AfternoonCount > 0 ? $"{summary.AfternoonCount}x" : string.Empty,
|
||||
MorningBackgroundColor = StateColor(morningState),
|
||||
AfternoonBackgroundColor = StateColor(afternoonState),
|
||||
MorningTextColor = StateTextColor(morningState),
|
||||
AfternoonTextColor = StateTextColor(afternoonState),
|
||||
MorningTextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2"),
|
||||
AfternoonTextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2"),
|
||||
IsToday = summary.Date.Date == DateTime.Today.Date
|
||||
};
|
||||
}
|
||||
@@ -94,8 +96,7 @@ public partial class WeekViewModel : ObservableObject
|
||||
|
||||
private async Task SetTodayAsync()
|
||||
{
|
||||
AnchorDate = DateTime.Today;
|
||||
await RefreshAsync();
|
||||
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||
}
|
||||
|
||||
private async Task OpenDayAsync(WeekCellViewModel? cell)
|
||||
@@ -103,8 +104,7 @@ public partial class WeekViewModel : ObservableObject
|
||||
if (cell is null)
|
||||
return;
|
||||
|
||||
string date = cell.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
||||
await Shell.Current.GoToAsync($"{nameof(QuickEntryPage)}?date={date}");
|
||||
await _calendarState.ShowDayTabAsync(cell.Date);
|
||||
}
|
||||
|
||||
private static DateTime StartOfWeek(DateTime date)
|
||||
@@ -113,28 +113,19 @@ public partial class WeekViewModel : ObservableObject
|
||||
return date.Date.AddDays(-diff);
|
||||
}
|
||||
|
||||
private static string StateLabel(HealthState? state) => state switch
|
||||
private static string StateLabel(HealthState? state)
|
||||
{
|
||||
HealthState.Green => "Gut",
|
||||
HealthState.Yellow => "So lala",
|
||||
HealthState.Red => "Schlecht",
|
||||
HealthState.Gray => "Ausfall",
|
||||
_ => "—"
|
||||
};
|
||||
if (state is null)
|
||||
return "—";
|
||||
|
||||
private static Color StateColor(HealthState? state) => state switch
|
||||
{
|
||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
||||
HealthState.Red => Color.FromArgb("#E53935"),
|
||||
HealthState.Gray => Color.FromArgb("#757575"),
|
||||
_ => Color.FromArgb("#F2F2F2")
|
||||
};
|
||||
return ThemeResourceHelper.GetString(
|
||||
state.Value.ToTextKey(),
|
||||
state.Value.ToFallbackText());
|
||||
}
|
||||
|
||||
private static Color StateTextColor(HealthState? state) => state switch
|
||||
private static Color StateColor(HealthState? state)
|
||||
{
|
||||
HealthState.Green => Colors.White,
|
||||
HealthState.Gray => Colors.White,
|
||||
_ => Colors.Black
|
||||
};
|
||||
var key = state?.ToColorKey() ?? ThemeKeys.PanelBackground2;
|
||||
return ThemeResourceHelper.GetColor(key, "#203041");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user