Improve Prime Time Picker
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Globalization;
|
||||||
using ClaudeDo.Ui.Services;
|
using ClaudeDo.Ui.Services;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
@@ -23,8 +24,26 @@ public sealed partial class PrimeScheduleRowViewModel : ViewModelBase
|
|||||||
|
|
||||||
public string LastRunLabel => LastRunAt is { } v ? v.LocalDateTime.ToString("g") : "—";
|
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 OnLastRunAtChanged(DateTimeOffset? value) => OnPropertyChanged(nameof(LastRunLabel));
|
||||||
|
|
||||||
|
partial void OnTimeOfDayChanged(TimeSpan value) => OnPropertyChanged(nameof(TimeText));
|
||||||
|
|
||||||
public PrimeScheduleRowViewModel(PrimeScheduleDto dto, bool isExisting)
|
public PrimeScheduleRowViewModel(PrimeScheduleDto dto, bool isExisting)
|
||||||
{
|
{
|
||||||
Id = dto.Id;
|
Id = dto.Id;
|
||||||
|
|||||||
@@ -224,10 +224,10 @@
|
|||||||
<ToggleButton Classes="day-toggle" Content="{loc:Tr settings.prime.daySa}" IsChecked="{Binding Saturday, Mode=TwoWay}"/>
|
<ToggleButton Classes="day-toggle" Content="{loc:Tr settings.prime.daySa}" IsChecked="{Binding Saturday, Mode=TwoWay}"/>
|
||||||
<ToggleButton Classes="day-toggle" Content="{loc:Tr settings.prime.daySu}" IsChecked="{Binding Sunday, Mode=TwoWay}"/>
|
<ToggleButton Classes="day-toggle" Content="{loc:Tr settings.prime.daySu}" IsChecked="{Binding Sunday, Mode=TwoWay}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TimePicker Grid.Column="2"
|
<TextBox Grid.Column="2"
|
||||||
SelectedTime="{Binding TimeOfDay, Mode=TwoWay}"
|
Text="{Binding TimeText, Mode=TwoWay}"
|
||||||
ClockIdentifier="24HourClock" MinuteIncrement="5"
|
PlaceholderText="HH:mm" MaxLength="5"
|
||||||
VerticalAlignment="Center"/>
|
Width="68" VerticalAlignment="Center"/>
|
||||||
<TextBlock Classes="meta" Grid.Column="3" Text="{Binding LastRunLabel}" VerticalAlignment="Center"
|
<TextBlock Classes="meta" Grid.Column="3" Text="{Binding LastRunLabel}" VerticalAlignment="Center"
|
||||||
MinWidth="80"/>
|
MinWidth="80"/>
|
||||||
<Button Classes="icon-btn" Grid.Column="4" Content="✕"
|
<Button Classes="icon-btn" Grid.Column="4" Content="✕"
|
||||||
|
|||||||
Reference in New Issue
Block a user