fix(ui): default-expand diff tree; reliable row-click toggle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ public sealed partial class WorktreeNodeViewModel : ViewModelBase
|
||||
public bool IsDirectory { get; init; }
|
||||
public string RelativePath { get; init; } = "";
|
||||
public ObservableCollection<WorktreeNodeViewModel> Children { get; } = new();
|
||||
[ObservableProperty] private bool _isExpanded = true;
|
||||
}
|
||||
|
||||
public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
SelectedItem="{Binding SelectedNode, Mode=TwoWay}"
|
||||
Background="Transparent"
|
||||
Margin="8,0,4,8">
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem" x:DataType="vm:WorktreeNodeViewModel">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</TreeView.Styles>
|
||||
<TreeView.ItemTemplate>
|
||||
<TreeDataTemplate DataType="vm:WorktreeNodeViewModel"
|
||||
ItemsSource="{Binding Children}">
|
||||
|
||||
@@ -62,9 +62,8 @@ public partial class WorktreeModalView : Window
|
||||
if (sender is not Control c) return;
|
||||
if (c.DataContext is not WorktreeNodeViewModel node) return;
|
||||
if (!node.IsDirectory) return;
|
||||
var tvi = c.FindAncestorOfType<TreeViewItem>();
|
||||
if (tvi is null) return;
|
||||
tvi.IsExpanded = !tvi.IsExpanded;
|
||||
node.IsExpanded = !node.IsExpanded;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user