From 6553e27d368f4eb018ce5541810454d83f41396b Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 4 Jul 2024 18:11:10 +0800 Subject: [PATCH] refactor: rewrite the way to get local & remote branch tree height --- src/Views/Repository.axaml.cs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index a7ba1a33..012eca75 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -404,29 +404,20 @@ namespace SourceGit.Views worktreeList.Height = desiredHeight; } - var desiredLocalBranchHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24; - var desiredRemoteHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24; - - if (!vm.IsRemoteGroupExpanded) + if (vm.IsLocalBranchGroupExpanded) { - if (vm.IsLocalBranchGroupExpanded) - { - var localBranchHeight = Math.Min(leftHeight, desiredLocalBranchHeight); + var localBranchMax = vm.IsRemoteGroupExpanded ? leftHeight * 0.5 : leftHeight; + var desiredHeight = GetTreeRowsCount(vm.LocalBranchTrees) * 24; + var localBranchHeight = Math.Min(localBranchMax, desiredHeight); + if (!localBranchTree.Height.IsClose(localBranchHeight)) localBranchTree.Height = localBranchHeight; - } + leftHeight -= localBranchHeight; } - else + + if (vm.IsRemoteGroupExpanded) { - if (vm.IsLocalBranchGroupExpanded) - { - var localBranchHeight = Math.Min(leftHeight * 0.5, desiredLocalBranchHeight); - if (!localBranchTree.Height.IsClose(localBranchHeight)) - localBranchTree.Height = localBranchHeight; - - leftHeight -= localBranchHeight; - } - - var remoteHeight = Math.Min(leftHeight, desiredRemoteHeight); + var desiredHeight = GetTreeRowsCount(vm.RemoteBranchTrees) * 24; + var remoteHeight = Math.Min(leftHeight, desiredHeight); if (!remoteBranchTree.Height.IsClose(remoteHeight)) remoteBranchTree.Height = remoteHeight; }