- shit: Cleanup this mess
This commit is contained in:
34
Nebula.Launcher/ViewModels/Popup/ExceptionViewModel.cs
Normal file
34
Nebula.Launcher/ViewModels/Popup/ExceptionViewModel.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Nebula.Launcher.Views.Popup;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
[ViewModelRegister(typeof(ExceptionView), false)]
|
||||
[ConstructGenerator]
|
||||
public sealed partial class ExceptionViewModel : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
public override string Title => "Oopsie! Some shit is happened now!";
|
||||
public override bool IsClosable => true;
|
||||
|
||||
public ObservableCollection<Exception> Errors { get; } = new();
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
var e = new Exception("TEST");
|
||||
AppendError(e);
|
||||
}
|
||||
|
||||
public void AppendError(Exception exception)
|
||||
{
|
||||
Errors.Add(exception);
|
||||
if (exception.InnerException != null)
|
||||
AppendError(exception.InnerException);
|
||||
}
|
||||
}
|
||||
25
Nebula.Launcher/ViewModels/Popup/InfoPopupViewModel.cs
Normal file
25
Nebula.Launcher/ViewModels/Popup/InfoPopupViewModel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Nebula.Launcher.Views.Popup;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
[ViewModelRegister(typeof(InfoPopupView), false)]
|
||||
[ConstructGenerator]
|
||||
public partial class InfoPopupViewModel : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
|
||||
[ObservableProperty] private string _infoText = "Test";
|
||||
|
||||
public override string Title => "Info";
|
||||
public override bool IsClosable => true;
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
}
|
||||
}
|
||||
50
Nebula.Launcher/ViewModels/Popup/LoadingContextViewModel.cs
Normal file
50
Nebula.Launcher/ViewModels/Popup/LoadingContextViewModel.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Nebula.Launcher.Views.Popup;
|
||||
using Nebula.Shared.Models;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
[ViewModelRegister(typeof(LoadingContextView), false)]
|
||||
[ConstructGenerator]
|
||||
public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadingHandler
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
|
||||
[ObservableProperty] private int _currJobs;
|
||||
|
||||
[ObservableProperty] private int _resolvedJobs;
|
||||
|
||||
public string LoadingName { get; set; } = "Loading...";
|
||||
public override bool IsClosable => false;
|
||||
|
||||
public override string Title => LoadingName;
|
||||
|
||||
public void SetJobsCount(int count)
|
||||
{
|
||||
CurrJobs = count;
|
||||
}
|
||||
|
||||
public int GetJobsCount()
|
||||
{
|
||||
return CurrJobs;
|
||||
}
|
||||
|
||||
public void SetResolvedJobsCount(int count)
|
||||
{
|
||||
ResolvedJobs = count;
|
||||
}
|
||||
|
||||
public int GetResolvedJobsCount()
|
||||
{
|
||||
return ResolvedJobs;
|
||||
}
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
}
|
||||
}
|
||||
38
Nebula.Launcher/ViewModels/Popup/LogPopupModelView.cs
Normal file
38
Nebula.Launcher/ViewModels/Popup/LogPopupModelView.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Nebula.Launcher.Views.Popup;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
[ViewModelRegister(typeof(LogPopupView), false)]
|
||||
[ConstructGenerator]
|
||||
public sealed partial class LogPopupModelView : PopupViewModelBase
|
||||
{
|
||||
[GenerateProperty] public override PopupMessageService PopupMessageService { get; }
|
||||
public override string Title => "LOG";
|
||||
public override bool IsClosable => true;
|
||||
|
||||
public ObservableCollection<LogInfo> Logs { get; } = new();
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
Logs.Add(new LogInfo
|
||||
{
|
||||
Category = "DEBG", Message = "MEOW MEOW TEST"
|
||||
});
|
||||
|
||||
Logs.Add(new LogInfo
|
||||
{
|
||||
Category = "ERRO", Message = "MEOW MEOW TEST 11\naaaaa"
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Append(string str)
|
||||
{
|
||||
Logs.Add(LogInfo.FromString(str));
|
||||
}
|
||||
}
|
||||
17
Nebula.Launcher/ViewModels/Popup/PopupViewModelBase.cs
Normal file
17
Nebula.Launcher/ViewModels/Popup/PopupViewModelBase.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels.Popup;
|
||||
|
||||
public abstract class PopupViewModelBase : ViewModelBase, IDisposable
|
||||
{
|
||||
public abstract PopupMessageService PopupMessageService { get; }
|
||||
|
||||
public abstract string Title { get; }
|
||||
public abstract bool IsClosable { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PopupMessageService.ClosePopup(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user