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:
2026-03-22 20:37:35 +01:00
parent 8615d1de07
commit 2b0797f50f
68 changed files with 1746 additions and 1351 deletions
+95 -11
View File
@@ -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.";
}
}