Skip to content

Commit

Permalink
Fix tapping categories in app
Browse files Browse the repository at this point in the history
  • Loading branch information
89netraM committed Oct 4, 2023
1 parent f2d78dc commit ad29ebd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
13 changes: 12 additions & 1 deletion app/TimeKeep.App/Views/AddEntryView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<Style Selector="Label">
<Setter Property="Margin" Value="0,10,0,5"/>
</Style>
<Style Selector="AutoCompleteBox ListBoxItem">
<Setter Property="Padding" Value="0"/>
</Style>
</UserControl.Styles>
<UserControl.Resources>
<converters:LocationConverter x:Key="LocationConverter"/>
Expand Down Expand Up @@ -62,7 +65,15 @@
<c:CategoriesDisplay Categories="{Binding Categories}" CanRemove="True"/>
<Panel>
<AutoCompleteBox x:Name="CategoriesBox" ItemsSource="{Binding ExistingCategories}"
KeyDown="OnAddCategoryKeyDown"/>
KeyDown="OnAddCategoryKeyDown">
<AutoCompleteBox.ItemTemplate>
<DataTemplate DataType="x:String">
<Grid Background="Transparent" PointerPressed="OnCategoryPressed" Tag="{Binding}">
<TextBlock Text="{Binding}" Margin="12,9"/>
</Grid>
</DataTemplate>
</AutoCompleteBox.ItemTemplate>
</AutoCompleteBox>
<Button CornerRadius="0,3,3,0"
Height="{Binding #CategoriesBox.Bounds.Height}"
HorizontalAlignment="Right"
Expand Down
13 changes: 13 additions & 0 deletions app/TimeKeep.App/Views/AddEntryView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ private async void AddCategory()
CategoriesBox.Text = string.Empty;
}

private async void OnCategoryPressed(object? sender, PointerPressedEventArgs e)
{
if (sender is not Grid { Tag: string category } || string.IsNullOrWhiteSpace(category))
{
return;
}

e.Handled = true;
await ViewModel!.AddCategoryCommand.Execute(category).ToTask();
CategoriesBox.Text = string.Empty;
CategoriesBox.Focus();
}

private void OnEndTimeIsCheckedChanged(object? sender, RoutedEventArgs e)
{
if (sender is CheckBox { IsChecked: true })
Expand Down
13 changes: 12 additions & 1 deletion app/TimeKeep.App/Views/AddProjectView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<Style Selector="Label">
<Setter Property="Margin" Value="0,10,0,5"/>
</Style>
<Style Selector="AutoCompleteBox ListBoxItem">
<Setter Property="Padding" Value="0"/>
</Style>
</UserControl.Styles>
<UserControl.Resources>
<Flyout x:Key="ErrorFlyout" Placement="Center">
Expand Down Expand Up @@ -40,7 +43,15 @@
<c:CategoriesDisplay Categories="{Binding Categories}" CanRemove="True"/>
<Panel>
<AutoCompleteBox x:Name="CategoriesBox" ItemsSource="{Binding ExistingCategories}"
KeyDown="OnAddCategoryKeyDown"/>
KeyDown="OnAddCategoryKeyDown">
<AutoCompleteBox.ItemTemplate>
<DataTemplate DataType="x:String">
<Grid Background="Transparent" PointerPressed="OnCategoryPressed" Tag="{Binding}">
<TextBlock Text="{Binding}" Margin="12,9"/>
</Grid>
</DataTemplate>
</AutoCompleteBox.ItemTemplate>
</AutoCompleteBox>
<Button CornerRadius="0,3,3,0"
Height="{Binding #CategoriesBox.Bounds.Height}"
HorizontalAlignment="Right"
Expand Down
13 changes: 13 additions & 0 deletions app/TimeKeep.App/Views/AddProjectView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ private async void AddCategory()
CategoriesBox.Text = string.Empty;
}

private async void OnCategoryPressed(object? sender, PointerPressedEventArgs e)
{
if (sender is not Grid { Tag: string category } || string.IsNullOrWhiteSpace(category))
{
return;
}

e.Handled = true;
await ViewModel!.AddCategoryCommand.Execute(category).ToTask();
CategoriesBox.Text = string.Empty;
CategoriesBox.Focus();
}

private async void OnAddClick(object? sender, RoutedEventArgs e)
{
var result = await ViewModel!.AddProjectCommand
Expand Down

0 comments on commit ad29ebd

Please sign in to comment.