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}"/>
IsVisible="{Binding SearchChangeFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" </TextBox.InnerLeftContent>
Command="{Binding ClearSearchChangeFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
<v:ChangeViewModeSwitcher Grid.Column="3" <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="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,36 +359,40 @@
<!-- 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" Margin="4,2"
Padding="22,0" FontSize="12"
FontSize="12" Height="24"
Height="24" CornerRadius="12"
Background="{DynamicResource Brush.Contents}" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1" Background="{DynamicResource Brush.Contents}"
CornerRadius="12" Watermark="{DynamicResource Text.Repository.SearchTip}"
Watermark="{DynamicResource Text.Repository.SearchTip}" Text="{Binding SearchCommitFilter, Mode=TwoWay}"
Text="{Binding SearchCommitFilter, Mode=TwoWay}" VerticalContentAlignment="Center"
KeyDown="OnSearchKeyDown"/> KeyDown="OnSearchKeyDown">
<Path Width="14" Height="14" <TextBox.InnerLeftContent>
Margin="6,0,0,0"
Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Search}"
HorizontalAlignment="Left"/>
<Button Classes="icon_button"
Width="16"
Margin="0,0,6,0"
Command="{Binding ClearSearchCommitFilter}"
IsVisible="{Binding SearchCommitFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
HorizontalAlignment="Right">
<Path Width="14" Height="14" <Path Width="14" Height="14"
Margin="0,1,0,0" Margin="6,0,0,0"
Fill="{DynamicResource Brush.FG1}" Fill="{DynamicResource Brush.FG2}"
Data="{StaticResource Icons.Clear}"/> Data="{StaticResource Icons.Search}"/>
</Button> </TextBox.InnerLeftContent>
</Grid>
<TextBox.InnerRightContent>
<Button Classes="icon_button"
Width="16"
Margin="0,0,6,0"
Command="{Binding ClearSearchCommitFilter}"
IsVisible="{Binding SearchCommitFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
HorizontalAlignment="Right">
<Path Width="14" Height="14"
Margin="0,1,0,0"
Fill="{DynamicResource Brush.FG1}"
Data="{StaticResource Icons.Clear}"/>
</Button>
</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}"/>
IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" </TextBox.InnerLeftContent>
Command="{Binding ClearSearchFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
<v:ChangeViewModeSwitcher Grid.Column="3" <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="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" FontSize="12"
Background="Transparent" Height="26"
BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
BorderThickness="1"/> Background="Transparent"
<Path Grid.Column="0" Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Width="14" Height="14" Text="{Binding SearchFileFilter, Mode=TwoWay}">
Fill="{DynamicResource Brush.FG2}" <TextBox.InnerLeftContent>
Data="{StaticResource Icons.Search}"/> <Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
<TextBox Grid.Column="1" </TextBox.InnerLeftContent>
Classes="no_background no_border"
FontSize="12" <TextBox.InnerRightContent>
Height="24" <Button Classes="icon_button"
CornerRadius="0" IsVisible="{Binding SearchFileFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}" Command="{Binding ClearSearchFileFilter}">
Text="{Binding SearchFileFilter, Mode=TwoWay}"/> <Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
<Button Grid.Column="2" </Button>
Classes="icon_button" </TextBox.InnerRightContent>
IsVisible="{Binding SearchFileFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" </TextBox>
Command="{Binding ClearSearchFileFilter}">
<Path Width="14" Height="14" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Clear}"/>
</Button>
</Grid>
<!-- 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}"
Watermark="{DynamicResource Text.Welcome.Search}"
VerticalContentAlignment="Center"
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>
<Path Grid.Column="0" <TextBox.InnerRightContent>
Width="16" Height="16" <Button Classes="icon_button" IsVisible="{Binding IsClearSearchVisible}" Command="{Binding ClearSearchFilter}">
Margin="4,0,0,0" <Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
Data="{StaticResource Icons.Search}"/> </Button>
</TextBox.InnerRightContent>
<TextBox Grid.Column="1" </TextBox>
Height="24"
Padding="0"
Classes="no_border no_background"
Watermark="{DynamicResource Text.Welcome.Search}"
VerticalContentAlignment="Center"
Text="{Binding SearchFilter, Mode=TwoWay}"/>
<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}"/>
</Button>
</Grid>
<TreeView Grid.Row="1" <TreeView Grid.Row="1"
Margin="0,8,8,0" Margin="0,8,8,0"