style: use TextBox.InnerLeftContent and TextBox.InnerRightContent instead of custom layout for search

This commit is contained in:
leo 2024-03-11 18:54:12 +08:00
parent 13c5c116fd
commit c1c47074f4
5 changed files with 109 additions and 118 deletions

View file

@ -17,30 +17,28 @@
<Grid Grid.Column="0" RowDefinitions="26,*">
<!-- Search & Display Mode -->
<Grid Grid.Row="0" ColumnDefinitions="24,*,24,24">
<Border Grid.Column="0" Grid.ColumnSpan="3"
Background="Transparent"
BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1"/>
<Path Grid.Column="0"
Width="14" Height="14"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"/>
<TextBox Grid.Column="1"
Classes="no_background no_border"
Height="24"
<Grid Grid.Row="0" ColumnDefinitions="*,24">
<TextBox Grid.Column="0"
FontSize="12"
CornerRadius="0"
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchChangeFilter, Mode=TwoWay}"/>
<Button Grid.Column="2"
Classes="icon_button"
Text="{Binding SearchChangeFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
IsVisible="{Binding SearchChangeFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Command="{Binding ClearSearchChangeFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
</TextBox.InnerRightContent>
</TextBox>
<v:ChangeViewModeSwitcher Grid.Column="3"
<v:ChangeViewModeSwitcher Grid.Column="1"
Width="18" Height="18"
HorizontalAlignment="Right"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode, Mode=TwoWay}"/>

View file

@ -359,24 +359,27 @@
<!-- Left Search Mode -->
<Grid Grid.Column="0" RowDefinitions="32,*" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
<!-- Search -->
<Grid Grid.Row="0" Margin="4,2">
<TextBox Grid.Column="1"
<TextBox Grid.Row="0"
x:Name="txtSearchCommitsBox"
Padding="22,0"
Margin="4,2"
FontSize="12"
Height="24"
Background="{DynamicResource Brush.Contents}"
BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1"
CornerRadius="12"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"
Watermark="{DynamicResource Text.Repository.SearchTip}"
Text="{Binding SearchCommitFilter, Mode=TwoWay}"
KeyDown="OnSearchKeyDown"/>
VerticalContentAlignment="Center"
KeyDown="OnSearchKeyDown">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14"
Margin="6,0,0,0"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"
HorizontalAlignment="Left"/>
Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
Width="16"
Margin="0,0,6,0"
@ -388,7 +391,8 @@
Fill="{DynamicResource Brush.FG1}"
Data="{StaticResource Icons.Clear}"/>
</Button>
</Grid>
</TextBox.InnerRightContent>
</TextBox>
<DataGrid Grid.Row="1"
ItemsSource="{Binding SearchedCommits}"

View file

@ -56,30 +56,28 @@
<Grid Grid.Column="0" RowDefinitions="26,*">
<!-- Search & Display Mode -->
<Grid Grid.Row="0" ColumnDefinitions="24,*,24,24">
<Border Grid.Column="0" Grid.ColumnSpan="3"
Background="Transparent"
BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1"/>
<Path Grid.Column="0"
Width="14" Height="14"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"/>
<TextBox Grid.Column="1"
Classes="no_background no_border"
<Grid Grid.Row="0" ColumnDefinitions="*,24">
<TextBox Grid.Column="0"
FontSize="12"
Height="24"
CornerRadius="0"
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchFilter, Mode=TwoWay}"/>
<Button Grid.Column="2"
Classes="icon_button"
Text="{Binding SearchFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Command="{Binding ClearSearchFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
</TextBox.InnerRightContent>
</TextBox>
<v:ChangeViewModeSwitcher Grid.Column="3"
<v:ChangeViewModeSwitcher Grid.Column="1"
Width="18" Height="18"
HorizontalAlignment="Right"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode, Mode=TwoWay}"/>

View file

@ -19,29 +19,25 @@
<Grid Grid.Column="0" RowDefinitions="26,*">
<!-- Search -->
<Grid Grid.Row="0" ColumnDefinitions="24,*,24">
<Border Grid.Column="0" Grid.ColumnSpan="3"
Background="Transparent"
BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1"/>
<Path Grid.Column="0"
Width="14" Height="14"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"/>
<TextBox Grid.Column="1"
Classes="no_background no_border"
<TextBox Grid.Row="0"
FontSize="12"
Height="24"
CornerRadius="0"
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchFileFilter, Mode=TwoWay}"/>
<Button Grid.Column="2"
Classes="icon_button"
Text="{Binding SearchFileFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
IsVisible="{Binding SearchFileFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Command="{Binding ClearSearchFileFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
</Grid>
</TextBox.InnerRightContent>
</TextBox>
<!-- File Tree -->
<Border Grid.Row="1" Margin="0,4,0,0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}">

View file

@ -27,31 +27,26 @@
<Grid Grid.Row="1" Margin="0,8" ColumnDefinitions="*,600,*">
<Grid Grid.Column="1" RowDefinitions="Auto,*">
<Grid Grid.Row="0" ColumnDefinitions="28,*,Auto">
<Border Grid.Column="0" Grid.ColumnSpan="3"
<TextBox Grid.Row="0"
Height="32"
Padding="0"
CornerRadius="16"
BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="1"
Background="{DynamicResource Brush.Contents}"/>
<Path Grid.Column="0"
Width="16" Height="16"
Margin="4,0,0,0"
Data="{StaticResource Icons.Search}"/>
<TextBox Grid.Column="1"
Height="24"
Padding="0"
Classes="no_border no_background"
Background="{DynamicResource Brush.Contents}"
Watermark="{DynamicResource Text.Welcome.Search}"
VerticalContentAlignment="Center"
Text="{Binding SearchFilter, Mode=TwoWay}"/>
Text="{Binding SearchFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="16" Height="16" Margin="6,0,3,0" Data="{StaticResource Icons.Search}" Fill="{DynamicResource Brush.FG1}"/>
</TextBox.InnerLeftContent>
<Button Grid.Column="2" Classes="icon_button" IsVisible="{Binding IsClearSearchVisible}" Command="{Binding ClearSearchFilter}">
<Path Width="16" Height="16" Margin="0,0,4,0" Data="{StaticResource Icons.Clear}"/>
<TextBox.InnerRightContent>
<Button Classes="icon_button" IsVisible="{Binding IsClearSearchVisible}" Command="{Binding ClearSearchFilter}">
<Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
</Button>
</Grid>
</TextBox.InnerRightContent>
</TextBox>
<TreeView Grid.Row="1"
Margin="0,8,8,0"