mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 10:22:13 +08:00
refactor: use a single property to indicate drop direction
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Threading;
|
||||
|
||||
@@ -82,16 +82,10 @@ namespace SourceGit.ViewModels
|
||||
set => SetProperty(ref _isFullMessageUsed, value);
|
||||
}
|
||||
|
||||
public bool IsDropBeforeVisible
|
||||
public Thickness DropDirectionIndicator
|
||||
{
|
||||
get => _isDropBeforeVisible;
|
||||
set => SetProperty(ref _isDropBeforeVisible, value);
|
||||
}
|
||||
|
||||
public bool IsDropAfterVisible
|
||||
{
|
||||
get => _isDropAfterVisible;
|
||||
set => SetProperty(ref _isDropAfterVisible, value);
|
||||
get => _dropDirectionIndicator;
|
||||
set => SetProperty(ref _dropDirectionIndicator, value);
|
||||
}
|
||||
|
||||
public bool IsMessageUserEdited
|
||||
@@ -116,8 +110,7 @@ namespace SourceGit.ViewModels
|
||||
private bool _canSquashOrFixup = true;
|
||||
private bool _showEditMessageButton = false;
|
||||
private bool _isFullMessageUsed = true;
|
||||
private bool _isDropBeforeVisible = false;
|
||||
private bool _isDropAfterVisible = false;
|
||||
private Thickness _dropDirectionIndicator = new Thickness(0);
|
||||
}
|
||||
|
||||
public class InteractiveRebase : ObservableObject
|
||||
|
||||
@@ -118,6 +118,12 @@
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="CommitTimeColumn"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Drop Direction Indicator -->
|
||||
<Border Grid.Column="0" Grid.ColumnSpan="8"
|
||||
Background="Transparent"
|
||||
BorderThickness="{Binding DropDirectionIndicator, Mode=OneWay}"
|
||||
BorderBrush="{DynamicResource Brush.Accent}"/>
|
||||
|
||||
<!-- Original Order -->
|
||||
<TextBlock Grid.Column="0"
|
||||
Margin="4,0,0,0"
|
||||
@@ -189,20 +195,6 @@
|
||||
Text="{Binding Commit.CommitterTimeStr}"
|
||||
Opacity="{Binding IsFullMessageUsed, Converter={x:Static c:BoolConverters.IsMergedToOpacity}}"/>
|
||||
</Border>
|
||||
|
||||
<!-- Drop Indicator -->
|
||||
<Rectangle Grid.Column="0" Grid.ColumnSpan="8"
|
||||
Height="2"
|
||||
VerticalAlignment="Top"
|
||||
Fill="{DynamicResource Brush.Accent}"
|
||||
IsVisible="{Binding IsDropBeforeVisible, Mode=OneWay}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Rectangle Grid.Column="0" Grid.ColumnSpan="8"
|
||||
Height="2"
|
||||
VerticalAlignment="Bottom"
|
||||
Fill="{DynamicResource Brush.Accent}"
|
||||
IsVisible="{Binding IsDropAfterVisible, Mode=OneWay}"
|
||||
IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</v:InteractiveRebaseListBox.ItemTemplate>
|
||||
|
||||
@@ -266,9 +266,7 @@ namespace SourceGit.Views
|
||||
|
||||
var p = e.GetPosition(control);
|
||||
var before = p.Y < control.Bounds.Height * 0.5;
|
||||
|
||||
dst.IsDropBeforeVisible = before;
|
||||
dst.IsDropAfterVisible = !before;
|
||||
dst.DropDirectionIndicator = before ? new Thickness(0, 2, 0, 0) : new Thickness(0, 0, 0, 2);
|
||||
e.DragEffects = DragDropEffects.Move;
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -278,8 +276,7 @@ namespace SourceGit.Views
|
||||
if (sender is not Control { DataContext: ViewModels.InteractiveRebaseItem dst })
|
||||
return;
|
||||
|
||||
dst.IsDropBeforeVisible = false;
|
||||
dst.IsDropAfterVisible = false;
|
||||
dst.DropDirectionIndicator = new Thickness(0);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
@@ -315,8 +312,7 @@ namespace SourceGit.Views
|
||||
vm.Move(commits, before ? idx : idx + 1);
|
||||
IRItemListBox.SelectedItems = commits;
|
||||
|
||||
dst.IsDropBeforeVisible = false;
|
||||
dst.IsDropAfterVisible = false;
|
||||
dst.DropDirectionIndicator = new Thickness(0);
|
||||
e.DragEffects = DragDropEffects.None;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user