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

View file

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

View file

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

View file

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