refactor: code cleanup

This commit is contained in:
leo 2024-05-30 15:13:59 +08:00
parent 04f4293421
commit fa3a3b2dad
25 changed files with 174 additions and 233 deletions

View file

@ -11,51 +11,6 @@ using Avalonia.VisualTree;
namespace SourceGit.Views
{
public class RepositorySubView : Border
{
public static readonly StyledProperty<object> DataProperty =
AvaloniaProperty.Register<RepositorySubView, object>(nameof(Data), false);
public object Data
{
get => GetValue(DataProperty);
set => SetValue(DataProperty, value);
}
protected override Type StyleKeyOverride => typeof(Border);
static RepositorySubView()
{
DataProperty.Changed.AddClassHandler<RepositorySubView>((view, ev) =>
{
var data = view.Data;
if (data == null)
{
view.Child = null;
}
else if (data is ViewModels.Histories)
{
view.Child = new Histories { DataContext = data };
}
else if (data is ViewModels.WorkingCopy)
{
view.Child = new WorkingCopy { DataContext = data };
}
else if (data is ViewModels.StashesPage)
{
view.Child = new StashesPage { DataContext = data };
}
else
{
view.Child = null;
}
GC.Collect();
});
}
}
public partial class Repository : UserControl
{
public Repository()