ux: re-design merge option style

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-17 15:08:49 +08:00
parent 10fd0f9d15
commit ddfc868df3
No known key found for this signature in database
3 changed files with 28 additions and 11 deletions

View file

@ -6,7 +6,7 @@
[ [
new MergeMode("Default", "Fast-forward if possible", ""), new MergeMode("Default", "Fast-forward if possible", ""),
new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"), new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"),
new MergeMode("Squash", "Use '--squash'", "--squash"), new MergeMode("Squash", "Squash merge", "--squash"),
new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"), new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"),
]; ];

View file

@ -15,7 +15,7 @@ namespace SourceGit.ViewModels
get; get;
} }
public Models.MergeMode SelectedMode public Models.MergeMode Mode
{ {
get; get;
set; set;
@ -28,7 +28,7 @@ namespace SourceGit.ViewModels
Source = source; Source = source;
Into = into; Into = into;
SelectedMode = AutoSelectMergeMode(); Mode = AutoSelectMergeMode();
View = new Views.Merge() { DataContext = this }; View = new Views.Merge() { DataContext = this };
} }
@ -39,7 +39,7 @@ namespace SourceGit.ViewModels
Source = source; Source = source;
Into = into; Into = into;
SelectedMode = AutoSelectMergeMode(); Mode = AutoSelectMergeMode();
View = new Views.Merge() { DataContext = this }; View = new Views.Merge() { DataContext = this };
} }
@ -50,7 +50,7 @@ namespace SourceGit.ViewModels
Source = source; Source = source;
Into = into; Into = into;
SelectedMode = AutoSelectMergeMode(); Mode = AutoSelectMergeMode();
View = new Views.Merge() { DataContext = this }; View = new Views.Merge() { DataContext = this };
} }
@ -61,7 +61,7 @@ namespace SourceGit.ViewModels
return Task.Run(() => return Task.Run(() =>
{ {
new Commands.Merge(_repo.FullPath, _sourceName, SelectedMode.Arg, SetProgressDescription).Exec(); new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true)); CallUIThread(() => _repo.SetWatcherEnabled(true));
return true; return true;
}); });

View file

@ -60,15 +60,32 @@
Height="28" Padding="8,0" Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding Source={x:Static m:MergeMode.Supported}}" ItemsSource="{Binding Source={x:Static m:MergeMode.Supported}}"
SelectedItem="{Binding SelectedMode, Mode=TwoWay}"> SelectedItem="{Binding Mode, Mode=TwoWay}"
Grid.IsSharedSizeScope="True">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="m:MergeMode"> <DataTemplate DataType="m:MergeMode">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center"> <Grid Height="20">
<TextBlock Text="{Binding Name}"/> <Grid.ColumnDefinitions>
<TextBlock Text="{Binding Desc}" Margin="8,0,0,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/> <ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeNameColumn"/>
</StackPanel> <ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeDescriptionColumn"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeOptionColumn"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name}"/>
<TextBlock Grid.Column="1" Text="{Binding Desc}" Margin="8,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Grid.Column="2" Text="{Binding Arg}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
</Grid>
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
<ComboBox.SelectionBoxItemTemplate>
<DataTemplate DataType="m:MergeMode">
<Grid ColumnDefinitions="Auto,*">
<TextBlock Grid.Column="0" Text="{Binding Name}" Margin="0,0,8,0"/>
<TextBlock Grid.Column="1" Text="{Binding Desc}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
</Grid>
</DataTemplate>
</ComboBox.SelectionBoxItemTemplate>
</ComboBox> </ComboBox>
</Grid> </Grid>
</StackPanel> </StackPanel>