feature: supports to search/filter tags (#215)

This commit is contained in:
leo 2024-06-27 21:43:15 +08:00
parent 575f902a5d
commit f8c4137c78
No known key found for this signature in database
6 changed files with 50 additions and 7 deletions

View file

@ -206,7 +206,7 @@
BorderThickness="1"
CornerRadius="4"
BorderBrush="{DynamicResource Brush.Border2}"
Watermark="{DynamicResource Text.Repository.FilterBranchTip}"
Watermark="{DynamicResource Text.Repository.SearchBranchTag}"
Text="{Binding SearchBranchFilter, Mode=TwoWay}"
VerticalContentAlignment="Center">
<TextBox.InnerLeftContent>
@ -375,10 +375,9 @@
</ToggleButton>
<DataGrid Grid.Row="7"
x:Name="tagsList"
MaxHeight="200"
Margin="8,0,4,0"
Background="Transparent"
ItemsSource="{Binding Tags}"
ItemsSource="{Binding VisibleTags}"
SelectionMode="Single"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
@ -391,7 +390,8 @@
VerticalScrollBarVisibility="Auto"
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
SelectionChanged="OnTagDataGridSelectionChanged"
ContextRequested="OnTagContextRequested">
ContextRequested="OnTagContextRequested"
PropertyChanged="OnTagPropertyChanged">
<DataGrid.Styles>
<Style Selector="DataGridRow">
<Setter Property="CornerRadius" Value="4" />

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Avalonia;
@ -279,6 +280,18 @@ namespace SourceGit.Views
e.Handled = true;
}
private void OnTagPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property == DataGrid.ItemsSourceProperty && DataContext is ViewModels.Repository vm)
{
if (vm.VisibleTags == null)
return;
var desiredHeight = tagsList.RowHeight * vm.VisibleTags.Count;
tagsList.Height = Math.Min(200, desiredHeight);
}
}
private void OnToggleFilter(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton toggle)