54 lines
2.0 KiB
C#
54 lines
2.0 KiB
C#
using cfs_tracker.Services;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace cfs_tracker.ViewModels;
|
|
|
|
public partial class DayEntryItemViewModel : ObservableObject
|
|
{
|
|
public int Id { get; init; }
|
|
public DateTime Date { get; init; }
|
|
public string SlotText { get; init; } = string.Empty;
|
|
public string StateText { get; init; } = string.Empty;
|
|
public string ActivityText { get; init; } = string.Empty;
|
|
public string DurationText { get; init; } = string.Empty;
|
|
public string SymptomsText { get; init; } = string.Empty;
|
|
public bool IsBackfill { get; init; }
|
|
public Color StateColor { get; init; } = Colors.Transparent;
|
|
public Color ForegroundColor { get; init; } = Colors.White;
|
|
|
|
public bool HasActivity => !string.IsNullOrWhiteSpace(ActivityText);
|
|
public bool HasDuration => !string.IsNullOrWhiteSpace(DurationText);
|
|
public bool HasSymptoms => !string.IsNullOrWhiteSpace(SymptomsText);
|
|
public bool HasDetails => HasActivity || HasDuration || HasSymptoms;
|
|
public string DetailsButtonText => IsExpanded
|
|
? LocalizationService.Translate("DayPage_DetailsHide")
|
|
: LocalizationService.Translate("DayPage_DetailsShow");
|
|
public string ActivitySummaryText => LocalizationService.Format("DayPage_ActivityFormat", ActivityText);
|
|
public string DurationSummaryText => LocalizationService.Format("DayPage_DurationFormat", DurationText);
|
|
public string SymptomsSummaryText => LocalizationService.Format("DayPage_SymptomsFormat", SymptomsText);
|
|
|
|
[ObservableProperty]
|
|
private bool isExpanded;
|
|
|
|
public IRelayCommand ToggleExpandedCommand { get; }
|
|
|
|
public DayEntryItemViewModel()
|
|
{
|
|
ToggleExpandedCommand = new RelayCommand(ToggleExpanded);
|
|
}
|
|
|
|
partial void OnIsExpandedChanged(bool value)
|
|
{
|
|
OnPropertyChanged(nameof(DetailsButtonText));
|
|
}
|
|
|
|
private void ToggleExpanded()
|
|
{
|
|
if (!HasDetails)
|
|
return;
|
|
|
|
IsExpanded = !IsExpanded;
|
|
}
|
|
}
|