First version
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using cfs_tracker.Models;
|
||||
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
public class DayEntryItemViewModel
|
||||
{
|
||||
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 Color BackgroundColor { get; init; } = Colors.Transparent;
|
||||
public Color TextColor { get; init; } = Colors.Black;
|
||||
|
||||
public static DayEntryItemViewModel FromEntry(HealthEntry entry)
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
var textColor = state switch
|
||||
{
|
||||
HealthState.Gray => Colors.White,
|
||||
HealthState.Green => Colors.White,
|
||||
_ => Colors.Black
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user