Skip to content

Commit

Permalink
Add a refresh time button to DateTime pickers
Browse files Browse the repository at this point in the history
  • Loading branch information
89netraM committed May 12, 2024
1 parent 8cdf511 commit 7dba092
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/TimeKeep.App/Controls/DateTimePicker.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:c="using:TimeKeep.App.Controls"
xmlns:converters="using:TimeKeep.App.Converters"
xmlns:fi="using:FluentAvalonia.FluentIcons"
mc:Ignorable="d" d:DesignWidth="240" d:DesignHeight="30"
mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="30"
x:Class="TimeKeep.App.Controls.DateTimePicker"
x:DataType="c:CategoriesDisplay"
x:Name="Root">
Expand All @@ -20,7 +20,7 @@
</Style>
</UserControl.Styles>

<Grid DataContext="{Binding #Root}" ColumnDefinitions="Auto,Auto">
<Grid DataContext="{Binding #Root}" ColumnDefinitions="Auto,Auto,Auto">
<MaskedTextBox x:Name="DateBox"
Grid.Column="0"
Padding="{Binding #DateBox.Bounds.Height, Converter={StaticResource ThicknessSelector}, ConverterParameter='r,10,6,6,5'}"
Expand Down Expand Up @@ -68,5 +68,13 @@
</Flyout>
</Button.Flyout>
</Button>

<Button Grid.Column="2"
Margin="10,0,0,0" Padding="7.5"
VerticalAlignment="Stretch"
Height="{Binding Bounds.Height}"
Tapped="OnRefreshTimeTapped">
<fi:FluentIcon Icon="ArrowClockwise20Regular"/>
</Button>
</Grid>
</UserControl>
6 changes: 6 additions & 0 deletions app/TimeKeep.App/Controls/DateTimePicker.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Input.TextInput;
using Avalonia.Media;

Expand Down Expand Up @@ -82,4 +83,9 @@ private void OnTimePickerDismissed(object? sender, EventArgs e)
{
TimeButton.Flyout?.Hide();
}

private void OnRefreshTimeTapped(object? sender, TappedEventArgs e)
{
DateTime = DateTimeOffset.Now;
}
}

0 comments on commit 7dba092

Please sign in to comment.