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:
@@ -1,13 +1,11 @@
|
||||
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;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
@@ -15,12 +13,13 @@ public partial class MonthViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly AggregationService _aggregationService;
|
||||
private readonly CalendarStateService _calendarState;
|
||||
private readonly CultureInfo _culture = new("de-DE");
|
||||
|
||||
private DateTime _currentMonth = new(DateTime.Today.Year, DateTime.Today.Month, 1);
|
||||
|
||||
[ObservableProperty]
|
||||
private string selectedMonthText = "";
|
||||
private string selectedMonthText = string.Empty;
|
||||
|
||||
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
||||
|
||||
@@ -31,10 +30,12 @@ public partial class MonthViewModel : ObservableObject
|
||||
|
||||
public MonthViewModel(
|
||||
HealthEntryRepository repository,
|
||||
AggregationService aggregationService)
|
||||
AggregationService aggregationService,
|
||||
CalendarStateService calendarState)
|
||||
{
|
||||
_repository = repository;
|
||||
_aggregationService = aggregationService;
|
||||
_calendarState = calendarState;
|
||||
|
||||
PreviousMonthCommand = new AsyncRelayCommand(PreviousMonthAsync);
|
||||
NextMonthCommand = new AsyncRelayCommand(NextMonthAsync);
|
||||
@@ -69,15 +70,7 @@ public partial class MonthViewModel : ObservableObject
|
||||
|
||||
private MonthCellViewModel BuildCell(CalendarDaySummary summary)
|
||||
{
|
||||
Color background = summary.DisplayState switch
|
||||
{
|
||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
||||
HealthState.Red => Color.FromArgb("#E53935"),
|
||||
HealthState.Gray => Color.FromArgb("#757575"),
|
||||
_ => Color.FromArgb("#F2F2F2")
|
||||
};
|
||||
|
||||
var colorKey = summary.DisplayState?.ToColorKey() ?? ThemeKeys.PanelBackground2;
|
||||
bool isToday = summary.Date.Date == DateTime.Today.Date;
|
||||
|
||||
return new MonthCellViewModel
|
||||
@@ -85,10 +78,12 @@ public partial class MonthViewModel : ObservableObject
|
||||
IsRealDay = true,
|
||||
Date = summary.Date,
|
||||
DayNumberText = summary.Date.Day.ToString(),
|
||||
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : "",
|
||||
BackgroundColor = background,
|
||||
BorderColor = isToday ? Colors.Black : Color.FromArgb("#D0D0D0"),
|
||||
TextColor = summary.DisplayState == HealthState.Gray ? Colors.White : Colors.Black
|
||||
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : string.Empty,
|
||||
BackgroundColor = ThemeResourceHelper.GetColor(colorKey, "#203041"),
|
||||
BorderColor = isToday
|
||||
? ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||
: ThemeResourceHelper.GetColor(ThemeKeys.PanelBorder, "#2B3E52"),
|
||||
TextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -106,8 +101,7 @@ public partial class MonthViewModel : ObservableObject
|
||||
|
||||
private async Task SetTodayAsync()
|
||||
{
|
||||
_currentMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
|
||||
await RefreshAsync();
|
||||
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||
}
|
||||
|
||||
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
||||
@@ -115,7 +109,6 @@ public partial class MonthViewModel : ObservableObject
|
||||
if (cell is null || !cell.IsRealDay)
|
||||
return;
|
||||
|
||||
string date = cell.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
||||
await Shell.Current.GoToAsync($"{nameof(QuickEntryPage)}?date={date}");
|
||||
await _calendarState.ShowDayTabAsync(cell.Date);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user