feat(ui): use a 24h TimePicker for prime schedule time entry

Replace the free-text time TextBox (which silently reset bad input to 07:00)
with Avalonia's TimePicker (24-hour, 5-minute steps), making invalid times
impossible. Drops the now-unused TimeSpanToHhmmConverter.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-06-02 17:03:04 +02:00
parent f1715a34fa
commit c42eaa057b
2 changed files with 4 additions and 28 deletions

View File

@@ -1,21 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace ClaudeDo.Ui.Converters;
public sealed class TimeSpanToHhmmConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value is TimeSpan t ? $"{t.Hours:00}:{t.Minutes:00}" : "07:00";
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string s) return new TimeSpan(7, 0, 0);
var parts = s.Split(':');
if (parts.Length == 2 &&
int.TryParse(parts[0], out var h) && h is >= 0 and <= 23 &&
int.TryParse(parts[1], out var m) && m is >= 0 and <= 59)
return new TimeSpan(h, m, 0);
return new TimeSpan(7, 0, 0);
}
}

View File

@@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals" xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
xmlns:settings="using:ClaudeDo.Ui.ViewModels.Modals.Settings" xmlns:settings="using:ClaudeDo.Ui.ViewModels.Modals.Settings"
xmlns:conv="using:ClaudeDo.Ui.Converters"
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls" xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
x:Class="ClaudeDo.Ui.Views.Modals.SettingsModalView" x:Class="ClaudeDo.Ui.Views.Modals.SettingsModalView"
x:DataType="vm:SettingsModalViewModel" x:DataType="vm:SettingsModalViewModel"
@@ -19,9 +18,6 @@
<KeyBinding Gesture="Escape" Command="{Binding CancelCommand}"/> <KeyBinding Gesture="Escape" Command="{Binding CancelCommand}"/>
</Window.KeyBindings> </Window.KeyBindings>
<Window.Resources>
<conv:TimeSpanToHhmmConverter x:Key="TimeSpanToHhmm"/>
</Window.Resources>
<ctl:ModalShell Title="SETTINGS" CloseCommand="{Binding CancelCommand}"> <ctl:ModalShell Title="SETTINGS" CloseCommand="{Binding CancelCommand}">
<ctl:ModalShell.Footer> <ctl:ModalShell.Footer>
@@ -198,9 +194,10 @@
<ToggleButton Classes="day-toggle" Content="Sa" IsChecked="{Binding Saturday, Mode=TwoWay}"/> <ToggleButton Classes="day-toggle" Content="Sa" IsChecked="{Binding Saturday, Mode=TwoWay}"/>
<ToggleButton Classes="day-toggle" Content="Su" IsChecked="{Binding Sunday, Mode=TwoWay}"/> <ToggleButton Classes="day-toggle" Content="Su" IsChecked="{Binding Sunday, Mode=TwoWay}"/>
</StackPanel> </StackPanel>
<TextBox Grid.Column="2" Width="64" <TimePicker Grid.Column="2"
Text="{Binding TimeOfDay, Mode=TwoWay, Converter={StaticResource TimeSpanToHhmm}}" SelectedTime="{Binding TimeOfDay, Mode=TwoWay}"
VerticalAlignment="Center"/> ClockIdentifier="24HourClock" MinuteIncrement="5"
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="✕"