Improve Prime Time Picker

This commit is contained in:
Mika Kuns
2026-06-03 14:27:06 +02:00
parent 00ef11ac33
commit ffe0fb9820
2 changed files with 23 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
using System.Globalization;
using ClaudeDo.Ui.Services;
using CommunityToolkit.Mvvm.ComponentModel;
@@ -23,8 +24,26 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
public string LastRunLabel => LastRunAt is { } v ? v.LocalDateTime.ToString("g") : "—";
private static readonly string[] TimeFormats = { @"h\:mm", @"hh\:mm" };
public string TimeText
{
get => TimeOfDay.ToString(@"hh\:mm", CultureInfo.InvariantCulture);
set
{
if (TimeSpan.TryParseExact(value, TimeFormats, CultureInfo.InvariantCulture, out var t)
&& t >= TimeSpan.Zero && t < TimeSpan.FromDays(1))
{
TimeOfDay = t;
}
OnPropertyChanged(nameof(TimeText));
}
}
partial void OnLastRunAtChanged(DateTimeOffset? value) => OnPropertyChanged(nameof(LastRunLabel));
partial void OnTimeOfDayChanged(TimeSpan value) => OnPropertyChanged(nameof(TimeText));
public PrimeScheduleRowViewModel(PrimeScheduleDto dto, bool isExisting)
{
Id = dto.Id;