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

@ -7,67 +7,6 @@ using Avalonia.Interactivity;
namespace SourceGit.Views
{
public class LauncherTab : Grid
{
public static readonly StyledProperty<bool> UseFixedTabWidthProperty =
AvaloniaProperty.Register<LauncherTab, bool>(nameof(UseFixedTabWidth), false);
public bool UseFixedTabWidth
{
get => GetValue(UseFixedTabWidthProperty);
set => SetValue(UseFixedTabWidthProperty, value);
}
protected override Type StyleKeyOverride => typeof(Grid);
static LauncherTab()
{
UseFixedTabWidthProperty.Changed.AddClassHandler<LauncherTab>((tab, ev) =>
{
tab.Width = tab.UseFixedTabWidth ? 200.0 : double.NaN;
});
}
}
public class LauncherBody : Border
{
public static readonly StyledProperty<object> DataProperty =
AvaloniaProperty.Register<LauncherBody, object>(nameof(Data), false);
public object Data
{
get => GetValue(DataProperty);
set => SetValue(DataProperty, value);
}
protected override Type StyleKeyOverride => typeof(Border);
static LauncherBody()
{
DataProperty.Changed.AddClassHandler<LauncherBody>((body, ev) =>
{
var data = body.Data;
if (data == null)
{
body.Child = null;
}
else if (data is ViewModels.Welcome)
{
body.Child = new Welcome { DataContext = data };
}
else if (data is ViewModels.Repository)
{
body.Child = new Repository { DataContext = data };
}
else
{
body.Child = null;
}
});
}
}
public partial class Launcher : Window, Models.INotificationReceiver
{
public Launcher()