Merge branch 'develop' into feature/allowing_to_checkout_commit

This commit is contained in:
Filipe Ramalho 2024-05-25 15:43:27 -03:00 committed by GitHub
commit db9ca5ba25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 822 additions and 283 deletions

View file

@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using Avalonia;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
{
public enum BranchTreeNodeType
@ -13,8 +17,10 @@ namespace SourceGit.ViewModels
Branch,
}
public class BranchTreeNode
public class BranchTreeNode : ObservableObject
{
public const double DEFAULT_CORNER = 4.0;
public string Name { get; set; }
public BranchTreeNodeType Type { get; set; }
public object Backend { get; set; }
@ -57,6 +63,43 @@ namespace SourceGit.ViewModels
get => IsBranch && (Backend as Models.Branch).IsCurrent;
}
public bool IsSelected
{
get => _isSelected;
set => SetProperty(ref _isSelected, value);
}
public CornerRadius CornerRadius
{
get => _cornerRadius;
set => SetProperty(ref _cornerRadius, value);
}
public void UpdateCornerRadius(ref BranchTreeNode prev)
{
if (_isSelected && prev != null && prev.IsSelected)
{
var prevTop = prev.CornerRadius.TopLeft;
prev.CornerRadius = new CornerRadius(prevTop, 0);
CornerRadius = new CornerRadius(0, DEFAULT_CORNER);
}
else if (CornerRadius.TopLeft != DEFAULT_CORNER ||
CornerRadius.BottomLeft != DEFAULT_CORNER)
{
CornerRadius = new CornerRadius(DEFAULT_CORNER);
}
prev = this;
if (!IsBranch && IsExpanded)
{
foreach (var child in Children)
child.UpdateCornerRadius(ref prev);
}
}
private bool _isSelected = false;
private CornerRadius _cornerRadius = new CornerRadius(DEFAULT_CORNER);
public class Builder
{
public List<BranchTreeNode> Locals => _locals;