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:
@@ -0,0 +1,14 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public partial class AppearanceColorItemViewModel : ObservableObject
|
||||
{
|
||||
public string Key { get; init; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string title = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string value = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public partial class AppearanceTextItemViewModel : ObservableObject
|
||||
{
|
||||
public string Key { get; init; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string title = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string value = string.Empty;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public enum CalendarMode
|
||||
{
|
||||
Day,
|
||||
Week,
|
||||
Month,
|
||||
Year
|
||||
}
|
||||
|
||||
public partial class CalendarViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private CalendarMode currentMode = CalendarMode.Month;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime selectedDate = DateTime.Today;
|
||||
|
||||
public IRelayCommand ShowDayCommand { get; }
|
||||
public IRelayCommand ShowWeekCommand { get; }
|
||||
public IRelayCommand ShowMonthCommand { get; }
|
||||
public IRelayCommand ShowYearCommand { get; }
|
||||
public IRelayCommand TodayCommand { get; }
|
||||
|
||||
public CalendarViewModel()
|
||||
{
|
||||
ShowDayCommand = new RelayCommand(() => CurrentMode = CalendarMode.Day);
|
||||
ShowWeekCommand = new RelayCommand(() => CurrentMode = CalendarMode.Week);
|
||||
ShowMonthCommand = new RelayCommand(() => CurrentMode = CalendarMode.Month);
|
||||
ShowYearCommand = new RelayCommand(() => CurrentMode = CalendarMode.Year);
|
||||
TodayCommand = new RelayCommand(() => SelectedDate = DateTime.Today);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +1,44 @@
|
||||
using cfs_tracker.Models;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Maui.Graphics;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public class DayEntryItemViewModel
|
||||
public partial class DayEntryItemViewModel : ObservableObject
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public DateTime Timestamp { get; init; }
|
||||
|
||||
public string TimeText { get; init; } = "";
|
||||
public string StateText { get; init; } = "";
|
||||
public string SourceText { get; init; } = "";
|
||||
public string TimeText { get; init; } = string.Empty;
|
||||
public string StateText { get; init; } = string.Empty;
|
||||
|
||||
public string ActivityText { get; init; } = string.Empty;
|
||||
public string SymptomsText { get; init; } = string.Empty;
|
||||
|
||||
public bool HasActivity => !string.IsNullOrWhiteSpace(ActivityText);
|
||||
public bool HasSymptoms => !string.IsNullOrWhiteSpace(SymptomsText);
|
||||
public bool HasDetails => HasActivity || HasSymptoms;
|
||||
|
||||
public string FoldoutText => IsExpanded ? "Details ausblenden" : "Details anzeigen";
|
||||
|
||||
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
||||
public Color TextColor { get; init; } = Colors.Black;
|
||||
public Color TextColor { get; init; } = Colors.White;
|
||||
|
||||
public static DayEntryItemViewModel FromEntry(HealthEntry entry)
|
||||
[ObservableProperty]
|
||||
private bool isExpanded;
|
||||
|
||||
public IRelayCommand ToggleExpandedCommand { get; }
|
||||
|
||||
public DayEntryItemViewModel()
|
||||
{
|
||||
var state = entry.State;
|
||||
var background = state switch
|
||||
{
|
||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
||||
HealthState.Red => Color.FromArgb("#E53935"),
|
||||
HealthState.Gray => Color.FromArgb("#757575"),
|
||||
_ => Colors.Transparent
|
||||
};
|
||||
ToggleExpandedCommand = new RelayCommand(ToggleExpanded);
|
||||
}
|
||||
|
||||
var textColor = state switch
|
||||
{
|
||||
HealthState.Gray => Colors.White,
|
||||
HealthState.Green => Colors.White,
|
||||
_ => Colors.Black
|
||||
};
|
||||
private void ToggleExpanded()
|
||||
{
|
||||
if (!HasDetails)
|
||||
return;
|
||||
|
||||
return new DayEntryItemViewModel
|
||||
{
|
||||
Id = entry.Id,
|
||||
Timestamp = entry.Timestamp,
|
||||
TimeText = entry.Timestamp.ToString("HH:mm"),
|
||||
StateText = state switch
|
||||
{
|
||||
HealthState.Green => "Gut",
|
||||
HealthState.Yellow => "So lala",
|
||||
HealthState.Red => "Schlecht",
|
||||
HealthState.Gray => "Totalausfall",
|
||||
_ => ""
|
||||
},
|
||||
SourceText = entry.Source switch
|
||||
{
|
||||
EntrySource.App => "App",
|
||||
EntrySource.Notification => "Push",
|
||||
_ => ""
|
||||
},
|
||||
BackgroundColor = background,
|
||||
TextColor = textColor
|
||||
};
|
||||
IsExpanded = !IsExpanded;
|
||||
OnPropertyChanged(nameof(FoldoutText));
|
||||
}
|
||||
}
|
||||
+110
-11
@@ -1,22 +1,27 @@
|
||||
using cfs_tracker.Data;
|
||||
using cfs_tracker.Models;
|
||||
using cfs_tracker.Views;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
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 cfs_tracker.Views;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public partial class DayViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly ActivityRepository _activityRepository;
|
||||
private readonly SymptomRepository _symptomRepository;
|
||||
private readonly CalendarStateService _calendarState;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime selectedDate = DateTime.Today;
|
||||
|
||||
[ObservableProperty]
|
||||
private string selectedDateText = "";
|
||||
private string selectedDateText = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private int greenCount;
|
||||
@@ -30,6 +35,18 @@ public partial class DayViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private int grayCount;
|
||||
|
||||
[ObservableProperty]
|
||||
private string greenStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGreenText, "Grün");
|
||||
|
||||
[ObservableProperty]
|
||||
private string yellowStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusYellowText, "Gelb");
|
||||
|
||||
[ObservableProperty]
|
||||
private string redStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusRedText, "Rot");
|
||||
|
||||
[ObservableProperty]
|
||||
private string grayStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGrayText, "Grau");
|
||||
|
||||
public ObservableCollection<DayEntryItemViewModel> Entries { get; } = new();
|
||||
|
||||
public IAsyncRelayCommand PreviousDayCommand { get; }
|
||||
@@ -38,9 +55,24 @@ public partial class DayViewModel : ObservableObject
|
||||
public IAsyncRelayCommand AddEntryCommand { get; }
|
||||
public IAsyncRelayCommand<DayEntryItemViewModel> DeleteEntryCommand { get; }
|
||||
|
||||
public DayViewModel(HealthEntryRepository repository)
|
||||
public IAsyncRelayCommand SaveGreenQuickCommand { get; }
|
||||
public IAsyncRelayCommand SaveYellowQuickCommand { get; }
|
||||
public IAsyncRelayCommand SaveRedQuickCommand { get; }
|
||||
public IAsyncRelayCommand SaveGrayQuickCommand { get; }
|
||||
|
||||
public DayViewModel(
|
||||
HealthEntryRepository repository,
|
||||
ActivityRepository activityRepository,
|
||||
SymptomRepository symptomRepository,
|
||||
CalendarStateService calendarState)
|
||||
{
|
||||
_repository = repository;
|
||||
_activityRepository = activityRepository;
|
||||
_symptomRepository = symptomRepository;
|
||||
_calendarState = calendarState;
|
||||
|
||||
SelectedDate = _calendarState.SelectedDate;
|
||||
_calendarState.SelectedDateChanged += OnSharedSelectedDateChanged;
|
||||
|
||||
PreviousDayCommand = new AsyncRelayCommand(PreviousDayAsync);
|
||||
NextDayCommand = new AsyncRelayCommand(NextDayAsync);
|
||||
@@ -48,7 +80,13 @@ public partial class DayViewModel : ObservableObject
|
||||
AddEntryCommand = new AsyncRelayCommand(OpenQuickEntryAsync);
|
||||
DeleteEntryCommand = new AsyncRelayCommand<DayEntryItemViewModel>(DeleteEntryAsync);
|
||||
|
||||
SaveGreenQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Green));
|
||||
SaveYellowQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Yellow));
|
||||
SaveRedQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Red));
|
||||
SaveGrayQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Gray));
|
||||
|
||||
UpdateDateText();
|
||||
RefreshStatusTexts();
|
||||
}
|
||||
|
||||
partial void OnSelectedDateChanged(DateTime value)
|
||||
@@ -56,8 +94,17 @@ public partial class DayViewModel : ObservableObject
|
||||
UpdateDateText();
|
||||
}
|
||||
|
||||
private async void OnSharedSelectedDateChanged(DateTime date)
|
||||
{
|
||||
SelectedDate = date;
|
||||
await RefreshAsync();
|
||||
}
|
||||
|
||||
public async Task RefreshAsync()
|
||||
{
|
||||
SelectedDate = _calendarState.SelectedDate;
|
||||
RefreshStatusTexts();
|
||||
|
||||
var entries = await _repository.GetEntriesForDateAsync(SelectedDate);
|
||||
|
||||
GreenCount = entries.Count(x => x.State == HealthState.Green);
|
||||
@@ -67,25 +114,69 @@ public partial class DayViewModel : ObservableObject
|
||||
|
||||
Entries.Clear();
|
||||
|
||||
var activityMap = await _activityRepository.GetNameMapAsync();
|
||||
var symptomMapByEntry = await _symptomRepository.GetSymptomsByEntryIdsAsync(entries.Select(x => x.Id));
|
||||
|
||||
foreach (var entry in entries.OrderBy(x => x.Timestamp))
|
||||
Entries.Add(DayEntryItemViewModel.FromEntry(entry));
|
||||
{
|
||||
string activityText = string.Empty;
|
||||
if (entry.ActivityId.HasValue && activityMap.TryGetValue(entry.ActivityId.Value, out var activityName))
|
||||
activityText = activityName;
|
||||
|
||||
symptomMapByEntry.TryGetValue(entry.Id, out var symptoms);
|
||||
string symptomsText = symptoms is { Count: > 0 }
|
||||
? string.Join(", ", symptoms)
|
||||
: string.Empty;
|
||||
|
||||
Entries.Add(new DayEntryItemViewModel
|
||||
{
|
||||
Id = entry.Id,
|
||||
TimeText = entry.Timestamp.ToString("HH:mm"),
|
||||
StateText = ThemeResourceHelper.GetString(
|
||||
entry.State.ToTextKey(),
|
||||
entry.State.ToFallbackText()),
|
||||
ActivityText = activityText,
|
||||
SymptomsText = symptomsText,
|
||||
BackgroundColor = ThemeResourceHelper.GetColor(entry.State.ToColorKey(), "#203041"),
|
||||
TextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async Task QuickSaveAsync(HealthState state)
|
||||
{
|
||||
if (SelectedDate.Date == DateTime.Today)
|
||||
{
|
||||
await _repository.AddEntryAsync(
|
||||
state,
|
||||
EntrySource.App,
|
||||
DateTime.Now);
|
||||
|
||||
await RefreshAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await OpenQuickEntryAsync();
|
||||
}
|
||||
|
||||
private async Task PreviousDayAsync()
|
||||
{
|
||||
SelectedDate = SelectedDate.AddDays(-1);
|
||||
_calendarState.SelectedDate = SelectedDate.AddDays(-1);
|
||||
SelectedDate = _calendarState.SelectedDate;
|
||||
await RefreshAsync();
|
||||
}
|
||||
|
||||
private async Task NextDayAsync()
|
||||
{
|
||||
SelectedDate = SelectedDate.AddDays(1);
|
||||
_calendarState.SelectedDate = SelectedDate.AddDays(1);
|
||||
SelectedDate = _calendarState.SelectedDate;
|
||||
await RefreshAsync();
|
||||
}
|
||||
|
||||
private async Task SetTodayAsync()
|
||||
{
|
||||
SelectedDate = DateTime.Today;
|
||||
_calendarState.SelectedDate = DateTime.Today;
|
||||
SelectedDate = _calendarState.SelectedDate;
|
||||
await RefreshAsync();
|
||||
}
|
||||
|
||||
@@ -108,4 +199,12 @@ public partial class DayViewModel : ObservableObject
|
||||
{
|
||||
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
||||
}
|
||||
|
||||
private void RefreshStatusTexts()
|
||||
{
|
||||
GreenStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGreenText, "Grün");
|
||||
YellowStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusYellowText, "Gelb");
|
||||
RedStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusRedText, "Rot");
|
||||
GrayStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGrayText, "Grau");
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,13 @@
|
||||
using Microsoft.Maui.Graphics;
|
||||
|
||||
using Microsoft.Maui.Graphics;
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public class MonthCellViewModel
|
||||
{
|
||||
public bool IsRealDay { get; init; }
|
||||
public DateTime Date { get; init; }
|
||||
|
||||
public string DayNumberText { get; init; } = "";
|
||||
public string CountText { get; init; } = "";
|
||||
|
||||
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
||||
public Color BorderColor { get; init; } = Colors.Transparent;
|
||||
public Color TextColor { get; init; } = Colors.Black;
|
||||
|
||||
public static MonthCellViewModel Placeholder() => new()
|
||||
{
|
||||
IsRealDay = false,
|
||||
BackgroundColor = Colors.Transparent,
|
||||
BorderColor = Colors.Transparent,
|
||||
TextColor = Colors.Transparent,
|
||||
DayNumberText = "",
|
||||
CountText = ""
|
||||
};
|
||||
}
|
||||
public static MonthCellViewModel Placeholder() => new() { IsRealDay = false };
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using cfs_tracker.Data;
|
||||
using cfs_tracker.Services;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public partial class OptionsViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly HealthEntryRepository _healthRepository;
|
||||
private readonly AppearanceRepository _appearanceRepository;
|
||||
private readonly AppearanceService _appearanceService;
|
||||
|
||||
[ObservableProperty]
|
||||
private string deleteConfirmationText = string.Empty;
|
||||
@@ -14,12 +18,25 @@ public partial class OptionsViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string statusText = string.Empty;
|
||||
|
||||
public IAsyncRelayCommand DeleteAllDataCommand { get; }
|
||||
public ObservableCollection<AppearanceColorItemViewModel> AppearanceColors { get; } = new();
|
||||
public ObservableCollection<AppearanceTextItemViewModel> StatusTexts { get; } = new();
|
||||
|
||||
public OptionsViewModel(HealthEntryRepository repository)
|
||||
public IAsyncRelayCommand DeleteAllDataCommand { get; }
|
||||
public IAsyncRelayCommand SaveAppearanceCommand { get; }
|
||||
public IAsyncRelayCommand ResetAppearanceCommand { get; }
|
||||
|
||||
public OptionsViewModel(
|
||||
HealthEntryRepository healthRepository,
|
||||
AppearanceRepository appearanceRepository,
|
||||
AppearanceService appearanceService)
|
||||
{
|
||||
_repository = repository;
|
||||
_healthRepository = healthRepository;
|
||||
_appearanceRepository = appearanceRepository;
|
||||
_appearanceService = appearanceService;
|
||||
|
||||
DeleteAllDataCommand = new AsyncRelayCommand(DeleteAllDataAsync, CanDeleteAllData);
|
||||
SaveAppearanceCommand = new AsyncRelayCommand(SaveAppearanceAsync);
|
||||
ResetAppearanceCommand = new AsyncRelayCommand(ResetAppearanceAsync);
|
||||
}
|
||||
|
||||
partial void OnDeleteConfirmationTextChanged(string value)
|
||||
@@ -27,19 +44,86 @@ public partial class OptionsViewModel : ObservableObject
|
||||
DeleteAllDataCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
await LoadAppearanceAsync();
|
||||
}
|
||||
|
||||
private bool CanDeleteAllData()
|
||||
{
|
||||
return string.Equals(
|
||||
DeleteConfirmationText?.Trim(),
|
||||
"löschen",
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
return string.Equals(DeleteConfirmationText?.Trim(), "löschen", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private async Task DeleteAllDataAsync()
|
||||
{
|
||||
await _repository.DeleteAllAsync();
|
||||
|
||||
await _healthRepository.DeleteAllAsync();
|
||||
DeleteConfirmationText = string.Empty;
|
||||
StatusText = "Alle gespeicherten Einträge wurden gelöscht.";
|
||||
}
|
||||
|
||||
private async Task LoadAppearanceAsync()
|
||||
{
|
||||
AppearanceColors.Clear();
|
||||
StatusTexts.Clear();
|
||||
|
||||
var all = await _appearanceRepository.GetAllAsync();
|
||||
|
||||
AddColor(all, "AppBackground", "App-Hintergrund");
|
||||
AddColor(all, "PanelBackground", "Panel-Hintergrund");
|
||||
AddColor(all, "PanelBackground2", "Sekundäre Fläche");
|
||||
AddColor(all, "PanelBorder", "Panel-Rand");
|
||||
AddColor(all, "TextPrimary", "Haupttext");
|
||||
AddColor(all, "TextMuted", "Gedimmter Text");
|
||||
AddColor(all, "StateGreen", "Statusfarbe Grün");
|
||||
AddColor(all, "StateYellow", "Statusfarbe Gelb");
|
||||
AddColor(all, "StateRed", "Statusfarbe Rot");
|
||||
AddColor(all, "StateGray", "Statusfarbe Grau");
|
||||
|
||||
AddText(all, "StatusGreenText", "Text für Grün");
|
||||
AddText(all, "StatusYellowText", "Text für Gelb");
|
||||
AddText(all, "StatusRedText", "Text für Rot");
|
||||
AddText(all, "StatusGrayText", "Text für Grau");
|
||||
}
|
||||
|
||||
private void AddColor(List<Models.AppearanceSetting> all, string key, string title)
|
||||
{
|
||||
var value = all.FirstOrDefault(x => x.Key == key)?.Value ?? string.Empty;
|
||||
|
||||
AppearanceColors.Add(new AppearanceColorItemViewModel
|
||||
{
|
||||
Key = key,
|
||||
Title = title,
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
|
||||
private void AddText(List<Models.AppearanceSetting> all, string key, string title)
|
||||
{
|
||||
var value = all.FirstOrDefault(x => x.Key == key)?.Value ?? string.Empty;
|
||||
|
||||
StatusTexts.Add(new AppearanceTextItemViewModel
|
||||
{
|
||||
Key = key,
|
||||
Title = title,
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
|
||||
private async Task SaveAppearanceAsync()
|
||||
{
|
||||
foreach (var item in AppearanceColors)
|
||||
await _appearanceService.SaveColorAsync(item.Key, item.Value);
|
||||
|
||||
foreach (var item in StatusTexts)
|
||||
await _appearanceService.SaveTextAsync(item.Key, item.Value);
|
||||
|
||||
StatusText = "Aussehen wurde gespeichert.";
|
||||
}
|
||||
|
||||
private async Task ResetAppearanceAsync()
|
||||
{
|
||||
await _appearanceService.ResetAsync();
|
||||
await LoadAppearanceAsync();
|
||||
StatusText = "Aussehen wurde auf Standard zurückgesetzt.";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -9,112 +9,84 @@ namespace cfs_tracker.ViewModels;
|
||||
|
||||
public partial class QuickEntryViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly HealthEntryRepository _repo;
|
||||
private readonly ActivityRepository _activityRepo;
|
||||
private readonly SymptomRepository _symptomRepo;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime selectedDate = DateTime.Today;
|
||||
[ObservableProperty] private DateTime selectedDate = DateTime.Today;
|
||||
[ObservableProperty] private string selectedDateText = "";
|
||||
[ObservableProperty] private bool isPastDate;
|
||||
[ObservableProperty] private bool isFutureDate;
|
||||
[ObservableProperty] private string selectedPartText = "Vormittag";
|
||||
[ObservableProperty] private SelectableItemViewModel? selectedActivity;
|
||||
|
||||
[ObservableProperty]
|
||||
private string selectedDateText = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isPastDate;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isFutureDate;
|
||||
|
||||
[ObservableProperty]
|
||||
private string selectedPartText = "Vormittag";
|
||||
|
||||
public ObservableCollection<string> AvailableParts { get; } = new()
|
||||
{
|
||||
"Vormittag",
|
||||
"Nachmittag"
|
||||
};
|
||||
public ObservableCollection<string> AvailableParts { get; } = new() { "Vormittag", "Nachmittag" };
|
||||
public ObservableCollection<SelectableItemViewModel> Activities { get; } = new();
|
||||
public ObservableCollection<SelectableItemViewModel> Symptoms { get; } = new();
|
||||
|
||||
public IAsyncRelayCommand SaveGreenCommand { get; }
|
||||
public IAsyncRelayCommand SaveYellowCommand { get; }
|
||||
public IAsyncRelayCommand SaveRedCommand { get; }
|
||||
public IAsyncRelayCommand SaveGrayCommand { get; }
|
||||
|
||||
public QuickEntryViewModel(HealthEntryRepository repository)
|
||||
public QuickEntryViewModel(HealthEntryRepository repo, ActivityRepository activityRepo, SymptomRepository symptomRepo)
|
||||
{
|
||||
_repository = repository;
|
||||
_repo=repo; _activityRepo=activityRepo; _symptomRepo=symptomRepo;
|
||||
SaveGreenCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Green));
|
||||
SaveYellowCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Yellow));
|
||||
SaveRedCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Red));
|
||||
SaveGrayCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Gray));
|
||||
}
|
||||
|
||||
SaveGreenCommand = new AsyncRelayCommand(() => SaveAsync(HealthState.Green));
|
||||
SaveYellowCommand = new AsyncRelayCommand(() => SaveAsync(HealthState.Yellow));
|
||||
SaveRedCommand = new AsyncRelayCommand(() => SaveAsync(HealthState.Red));
|
||||
SaveGrayCommand = new AsyncRelayCommand(() => SaveAsync(HealthState.Gray));
|
||||
|
||||
UpdateState();
|
||||
public async Task LoadLookupsAsync()
|
||||
{
|
||||
Activities.Clear();
|
||||
Symptoms.Clear();
|
||||
Activities.Add(new SelectableItemViewModel { Id = 0, Name = "Keine Angabe" });
|
||||
foreach (var a in await _activityRepo.GetActiveAsync()) Activities.Add(new SelectableItemViewModel { Id = a.Id, Name = a.Name });
|
||||
foreach (var s in await _symptomRepo.GetActiveAsync()) Symptoms.Add(new SelectableItemViewModel { Id = s.Id, Name = s.Name });
|
||||
SelectedActivity ??= Activities.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void SetDateFromQuery(string? dateText)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(dateText) &&
|
||||
DateTime.TryParseExact(
|
||||
dateText,
|
||||
"yyyy-MM-dd",
|
||||
CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.None,
|
||||
out var parsed))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(dateText) && DateTime.TryParseExact(dateText, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var parsed))
|
||||
SelectedDate = parsed.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedDate = DateTime.Today;
|
||||
}
|
||||
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
partial void OnSelectedDateChanged(DateTime value)
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
partial void OnSelectedDateChanged(DateTime value) => UpdateState();
|
||||
|
||||
private async Task SaveAsync(HealthState state)
|
||||
{
|
||||
if (IsFutureDate)
|
||||
return;
|
||||
|
||||
if (IsFutureDate) return;
|
||||
int? activityId = SelectedActivity is not null && SelectedActivity.Id > 0 ? SelectedActivity.Id : null;
|
||||
int entryId;
|
||||
if (IsPastDate)
|
||||
{
|
||||
await _repository.UpsertBackfillAsync(
|
||||
SelectedDate,
|
||||
GetSelectedPart(),
|
||||
state,
|
||||
EntrySource.App);
|
||||
await _repo.UpsertBackfillAsync(SelectedDate, SelectedPartText == "Nachmittag" ? DayPart.Afternoon : DayPart.Morning, state, EntrySource.App, activityId);
|
||||
var saved = await _repo.GetBackfillEntryAsync(SelectedDate, SelectedPartText == "Nachmittag" ? DayPart.Afternoon : DayPart.Morning);
|
||||
entryId = saved?.Id ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
await _repository.AddEntryAsync(
|
||||
state,
|
||||
EntrySource.App,
|
||||
DateTime.Now);
|
||||
entryId = await _repo.AddEntryAndReturnIdAsync(state, EntrySource.App, DateTime.Now, activityId);
|
||||
}
|
||||
if (entryId > 0)
|
||||
{
|
||||
await _symptomRepo.SetSymptomsForEntryAsync(entryId, Symptoms.Where(x=>x.IsSelected).Select(x=>x.Id));
|
||||
}
|
||||
|
||||
await Shell.Current.GoToAsync("..");
|
||||
}
|
||||
|
||||
private DayPart GetSelectedPart()
|
||||
{
|
||||
return SelectedPartText == "Nachmittag"
|
||||
? DayPart.Afternoon
|
||||
: DayPart.Morning;
|
||||
}
|
||||
|
||||
private void UpdateState()
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
|
||||
IsPastDate = SelectedDate.Date < today;
|
||||
IsFutureDate = SelectedDate.Date > today;
|
||||
|
||||
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
||||
|
||||
if (!IsPastDate)
|
||||
SelectedPartText = "Vormittag";
|
||||
if (!IsPastDate) SelectedPartText = "Vormittag";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
namespace cfs_tracker.ViewModels;
|
||||
public partial class SelectableItemViewModel : ObservableObject
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = "";
|
||||
[ObservableProperty] private bool isSelected;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Maui.Graphics;
|
||||
using Microsoft.Maui.Graphics;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
@@ -6,20 +6,20 @@ public class WeekCellViewModel
|
||||
{
|
||||
public DateTime Date { get; init; }
|
||||
|
||||
public string DayText { get; init; } = "";
|
||||
public string DateText { get; init; } = "";
|
||||
public string DayText { get; init; } = string.Empty;
|
||||
public string DateText { get; init; } = string.Empty;
|
||||
|
||||
public string MorningText { get; init; } = "";
|
||||
public string AfternoonText { get; init; } = "";
|
||||
public string MorningText { get; init; } = string.Empty;
|
||||
public string AfternoonText { get; init; } = string.Empty;
|
||||
|
||||
public string MorningCountText { get; init; } = "";
|
||||
public string AfternoonCountText { get; init; } = "";
|
||||
public string MorningCountText { get; init; } = string.Empty;
|
||||
public string AfternoonCountText { get; init; } = string.Empty;
|
||||
|
||||
public Color MorningBackgroundColor { get; init; } = Colors.Transparent;
|
||||
public Color AfternoonBackgroundColor { get; init; } = Colors.Transparent;
|
||||
|
||||
public Color MorningTextColor { get; init; } = Colors.Black;
|
||||
public Color AfternoonTextColor { get; init; } = Colors.Black;
|
||||
public Color MorningTextColor { get; init; } = Colors.White;
|
||||
public Color AfternoonTextColor { get; init; } = Colors.White;
|
||||
|
||||
public bool IsToday { get; init; }
|
||||
}
|
||||
+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");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public class YearMonthViewModel
|
||||
{
|
||||
public int MonthNumber { get; init; }
|
||||
public string MonthText { get; init; } = "";
|
||||
|
||||
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
+20
-25
@@ -1,11 +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.Views;
|
||||
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;
|
||||
|
||||
@@ -13,12 +13,13 @@ public partial class YearViewModel : ObservableObject
|
||||
{
|
||||
private readonly HealthEntryRepository _repository;
|
||||
private readonly AggregationService _aggregationService;
|
||||
private readonly CalendarStateService _calendarState;
|
||||
private readonly CultureInfo _culture = new("de-DE");
|
||||
|
||||
private int _currentYear = DateTime.Today.Year;
|
||||
|
||||
[ObservableProperty]
|
||||
private string selectedYearText = "";
|
||||
private string selectedYearText = string.Empty;
|
||||
|
||||
public ObservableCollection<YearMonthViewModel> Months { get; } = new();
|
||||
|
||||
@@ -29,10 +30,12 @@ public partial class YearViewModel : ObservableObject
|
||||
|
||||
public YearViewModel(
|
||||
HealthEntryRepository repository,
|
||||
AggregationService aggregationService)
|
||||
AggregationService aggregationService,
|
||||
CalendarStateService calendarState)
|
||||
{
|
||||
_repository = repository;
|
||||
_aggregationService = aggregationService;
|
||||
_calendarState = calendarState;
|
||||
|
||||
PreviousYearCommand = new AsyncRelayCommand(PreviousYearAsync);
|
||||
NextYearCommand = new AsyncRelayCommand(NextYearAsync);
|
||||
@@ -78,15 +81,7 @@ public partial class YearViewModel : 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
|
||||
@@ -94,10 +89,12 @@ public partial class YearViewModel : 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")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -115,8 +112,7 @@ public partial class YearViewModel : ObservableObject
|
||||
|
||||
private async Task SetTodayAsync()
|
||||
{
|
||||
_currentYear = DateTime.Today.Year;
|
||||
await RefreshAsync();
|
||||
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||
}
|
||||
|
||||
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
||||
@@ -124,7 +120,6 @@ public partial class YearViewModel : 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