ux: style of tab switch in file histories view
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions

This commit is contained in:
leo 2024-09-27 18:23:55 +08:00
parent 699bfe8208
commit 2346082228
No known key found for this signature in database
4 changed files with 27 additions and 76 deletions

View file

@ -963,7 +963,6 @@
</Style> </Style>
<Style Selector="RadioButton.switch_button"> <Style Selector="RadioButton.switch_button">
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="24"/> <Setter Property="Height" Value="24"/>
<Setter Property="BorderThickness" Value="0"/> <Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
@ -988,6 +987,12 @@
<Style Selector="^:checked Path"> <Style Selector="^:checked Path">
<Setter Property="Fill" Value="White"/> <Setter Property="Fill" Value="White"/>
</Style> </Style>
<Style Selector="^ TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
</Style>
<Style Selector="^:checked TextBlock">
<Setter Property="Foreground" Value="White"/>
</Style>
</Style> </Style>
<Style Selector="ToggleButton.group_expander"> <Style Selector="ToggleButton.group_expander">

View file

@ -41,12 +41,12 @@ namespace SourceGit.ViewModels
} }
} }
public int ViewMode public bool IsViewContent
{ {
get => _viewMode; get => _isViewContent;
set set
{ {
if (SetProperty(ref _viewMode, value)) if (SetProperty(ref _isViewContent, value))
RefreshViewContent(); RefreshViewContent();
} }
} }
@ -93,10 +93,10 @@ namespace SourceGit.ViewModels
return; return;
} }
if (_viewMode == 0) if (_isViewContent)
SetViewContentAsDiff();
else
SetViewContentAsRevisionFile(); SetViewContentAsRevisionFile();
else
SetViewContentAsDiff();
} }
private void SetViewContentAsRevisionFile() private void SetViewContentAsRevisionFile()
@ -197,7 +197,7 @@ namespace SourceGit.ViewModels
private bool _isLoading = true; private bool _isLoading = true;
private List<Models.Commit> _commits = null; private List<Models.Commit> _commits = null;
private Models.Commit _selectedCommit = null; private Models.Commit _selectedCommit = null;
private int _viewMode = 0; private bool _isViewContent = false;
private object _viewContent = null; private object _viewContent = null;
} }
} }

View file

@ -115,75 +115,19 @@
IsVisible="{Binding IsLoading}"/> IsVisible="{Binding IsLoading}"/>
<Grid Grid.Column="2" RowDefinitions="Auto,*,Auto" IsVisible="{Binding !IsLoading}"> <Grid Grid.Column="2" RowDefinitions="Auto,*,Auto" IsVisible="{Binding !IsLoading}">
<ListBox Grid.Row="0" <StackPanel Grid.Row="0" Margin="0,8" Height="28" HorizontalAlignment="Center" Orientation="Horizontal">
Margin="0,8" <RadioButton Classes="switch_button"
SelectedIndex="{Binding ViewMode, Mode=TwoWay}" GroupName="SearchGroup"
HorizontalAlignment="Center" IsChecked="{Binding !IsViewContent, Mode=OneWay}">
VerticalAlignment="Center" <TextBlock Margin="16,0" Text="{DynamicResource Text.FileHistory.FileChange}" FontWeight="Bold"/>
Background="Transparent" </RadioButton>
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
CornerRadius="14"
Padding="3,0">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Styles> <RadioButton Classes="switch_button"
<Style Selector="ListBoxItem"> GroupName="SearchGroup"
<Setter Property="Height" Value="28"/> IsChecked="{Binding IsViewContent, Mode=TwoWay}">
<Setter Property="Padding" Value="0"/> <TextBlock Margin="16,0" Text="{DynamicResource Text.FileHistory.FileContent}" FontWeight="Bold"/>
<Setter Property="Background" Value="Transparent"/> </RadioButton>
</Style> </StackPanel>
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem Border.switcher_bg">
<Setter Property="Height" Value="22"/>
<Setter Property="CornerRadius" Value="11"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="16,0"/>
</Style>
<Style Selector="ListBoxItem:selected Border.switcher_bg">
<Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
</Style>
<Style Selector="TextBlock.view_mode_switcher">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
</Style>
<Style Selector="ListBoxItem:pointerover TextBlock.view_mode_switcher">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
</Style>
<Style Selector="ListBoxItem:selected TextBlock.view_mode_switcher">
<Setter Property="Foreground" Value="White"/>
</Style>
</ListBox.Styles>
<ListBoxItem>
<Border Classes="switcher_bg">
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.FileHistory.FileChange}"/>
</Border>
</ListBoxItem>
<ListBoxItem>
<Border Classes="switcher_bg">
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.FileHistory.FileContent}"/>
</Border>
</ListBoxItem>
</ListBox>
<ContentControl Grid.Row="1" Margin="4,4,8,8" Content="{Binding ViewContent}"> <ContentControl Grid.Row="1" Margin="4,4,8,8" Content="{Binding ViewContent}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>

View file

@ -21,12 +21,14 @@
<!-- Page Switcher for Left Contents (Dashboard or CommitSearch) --> <!-- Page Switcher for Left Contents (Dashboard or CommitSearch) -->
<StackPanel Grid.Row="0" Margin="0,6" Height="24" HorizontalAlignment="Center" Orientation="Horizontal"> <StackPanel Grid.Row="0" Margin="0,6" Height="24" HorizontalAlignment="Center" Orientation="Horizontal">
<RadioButton Classes="switch_button" <RadioButton Classes="switch_button"
Width="48"
GroupName="SearchGroup" GroupName="SearchGroup"
IsChecked="{Binding !IsSearching, Mode=OneWay}"> IsChecked="{Binding !IsSearching, Mode=OneWay}">
<Path Width="12" Height="12" Stretch="Fill" HorizontalAlignment="Center" Data="{StaticResource Icons.Home}"/> <Path Width="12" Height="12" Stretch="Fill" HorizontalAlignment="Center" Data="{StaticResource Icons.Home}"/>
</RadioButton> </RadioButton>
<RadioButton Classes="switch_button" <RadioButton Classes="switch_button"
Width="48"
GroupName="SearchGroup" GroupName="SearchGroup"
IsChecked="{Binding IsSearching, Mode=TwoWay}"> IsChecked="{Binding IsSearching, Mode=TwoWay}">
<Path Width="12" Height="12" Stretch="Fill" HorizontalAlignment="Center" Data="{StaticResource Icons.Search}"/> <Path Width="12" Height="12" Stretch="Fill" HorizontalAlignment="Center" Data="{StaticResource Icons.Search}"/>