Merge Common to Desktop

This commit is contained in:
Jöran Malek 2024-02-16 02:23:58 +01:00
parent 26915defe1
commit e9c6e14965
40 changed files with 447 additions and 282 deletions

View file

@ -0,0 +1,36 @@
using InkForge.Desktop.Controllers;
using InkForge.Desktop.Models;
using ReactiveUI;
namespace InkForge.Desktop.ViewModels;
public class AppViewModel : ReactiveObject
{
private readonly LandingViewModel _landingViewModel;
private readonly WorkspaceController _workspace;
private object _view;
public object View
{
get => _view;
set => this.RaiseAndSetIfChanged(ref _view, value);
}
public AppViewModel(WorkspaceController workspace, LandingViewModel landingViewModel)
{
_workspace = workspace;
_landingViewModel = landingViewModel;
this.WhenAnyValue(v => v._workspace.Workspace).Subscribe(OnWorkspaceChanged);
}
private void OnWorkspaceChanged(Workspace workspace)
{
View = workspace switch
{
null => _landingViewModel,
{ } => new WorkspaceViewModel(workspace) // scoped?
};
}
}