47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
|
using System.Reactive;
|
||
|
using Demo.Data.Repository;
|
||
|
using Demo.Domain.UseCase;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using presence_client.ApiClients.Interfaces;
|
||
|
using ReactiveUI;
|
||
|
|
||
|
namespace Presence.Desktop.ViewModels;
|
||
|
|
||
|
public class StartViewModel : ViewModelBase, IRoutableViewModel
|
||
|
{
|
||
|
public IScreen HostScreen { get; }
|
||
|
public string? UrlPathSegment => "start";
|
||
|
|
||
|
public ReactiveCommand<Unit, Unit> OpenGroupCommand { get; }
|
||
|
public ReactiveCommand<Unit, Unit> OpenPresenceCommand { get; }
|
||
|
public ReactiveCommand<Unit, Unit> GoBackCommand { get; }
|
||
|
|
||
|
public StartViewModel(IScreen hostScreen)
|
||
|
{
|
||
|
HostScreen = hostScreen;
|
||
|
|
||
|
OpenGroupCommand = ReactiveCommand.Create(() =>
|
||
|
{
|
||
|
HostScreen.Router.Navigate.Execute(new GroupViewModel(
|
||
|
App.ServiceProvider.GetRequiredService<IGroupApiClient>(),
|
||
|
App.ServiceProvider.GetRequiredService<IUserApiClient>(),
|
||
|
HostScreen
|
||
|
));
|
||
|
});
|
||
|
|
||
|
OpenPresenceCommand = ReactiveCommand.Create(() =>
|
||
|
{
|
||
|
HostScreen.Router.Navigate.Execute(new PresenceViewModel(
|
||
|
App.ServiceProvider.GetRequiredService<IPresenceApiClient>(),
|
||
|
App.ServiceProvider.GetRequiredService<IGroupApiClient>(),
|
||
|
HostScreen
|
||
|
));
|
||
|
});
|
||
|
|
||
|
GoBackCommand = ReactiveCommand.Create(() =>
|
||
|
{
|
||
|
HostScreen.Router.Navigate.Execute(new StartViewModel(HostScreen));
|
||
|
});
|
||
|
}
|
||
|
}
|