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,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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user