Factories and Views
This commit is contained in:
parent
4e7dfc56a8
commit
2529b728ba
16 changed files with 188 additions and 4 deletions
|
|
@ -14,8 +14,8 @@ public class AppViewModel : ReactiveObject
|
|||
set => this.RaiseAndSetIfChanged(ref _view, value);
|
||||
}
|
||||
|
||||
public AppViewModel(WorkspaceController workspace)
|
||||
public AppViewModel(WorkspaceController workspace, LandingViewModel landingViewModel)
|
||||
{
|
||||
View = new LandingViewModel();
|
||||
View = landingViewModel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
using InkForge.Common.ReactiveUI;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
namespace InkForge.Common.ViewModels.Landing;
|
||||
|
||||
public class CreateWorkspaceViewModel : LandingViewModelBase
|
||||
{
|
||||
public override string? UrlPathSegment => null;
|
||||
|
||||
public CreateWorkspaceViewModel(LandingViewModel landing) : base(landing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using InkForge.Common.ReactiveUI;
|
||||
|
||||
namespace InkForge.Common.ViewModels.Landing;
|
||||
|
||||
public abstract class LandingViewModelBase(LandingViewModel landing) : RoutableReactiveObject(landing)
|
||||
{
|
||||
public LandingViewModel Landing => landing;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace InkForge.Common.ViewModels.Landing;
|
||||
|
||||
public class LandingViewModelFactory(IServiceProvider serviceProvider)
|
||||
{
|
||||
public T Create<T>(LandingViewModel landing) where T : LandingViewModelBase
|
||||
{
|
||||
LandingViewModelsObjectParameters objectParameters = new(landing);
|
||||
return TypeFactory<LandingViewModelsObjectParameters, T>.Create(objectParameters, serviceProvider);
|
||||
}
|
||||
|
||||
readonly record struct LandingViewModelsObjectParameters(
|
||||
LandingViewModel Landing
|
||||
) : IObjectParameters<LandingViewModelsObjectParameters>
|
||||
{
|
||||
public static Type[] Types => [typeof(LandingViewModel)];
|
||||
|
||||
public static implicit operator object[](in LandingViewModelsObjectParameters self) => [self.Landing];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using InkForge.Common.ReactiveUI;
|
||||
|
||||
namespace InkForge.Common.ViewModels.Landing;
|
||||
|
||||
public class OpenRecentViewModel : LandingViewModelBase
|
||||
{
|
||||
public override string? UrlPathSegment => null;
|
||||
|
||||
public OpenRecentViewModel(LandingViewModel landing) : base(landing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,28 @@
|
|||
using System.Reactive.Linq;
|
||||
|
||||
using InkForge.Common.ViewModels.Landing;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
namespace InkForge.Common.ViewModels;
|
||||
|
||||
public class LandingViewModel : ReactiveObject
|
||||
public class LandingViewModel : ReactiveObject, IScreen
|
||||
{
|
||||
private readonly LandingViewModelFactory _factory;
|
||||
|
||||
public RoutingState Router { get; } = new();
|
||||
|
||||
public LandingViewModel(LandingViewModelFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
|
||||
Router.CurrentViewModel.Where(x => x is null)
|
||||
.InvokeCommand<IRoutableViewModel>(Router.NavigateAndReset);
|
||||
}
|
||||
|
||||
public void Navigate<T>() where T : LandingViewModelBase
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue