presence/Presence.Desktop/ViewModels/StartViewModel.cs
2024-12-23 18:12:32 +03:00

42 lines
1.3 KiB
C#

using Demo.Domain.UseCase;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
using System;
using System.Reactive;
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<IGroupUseCase>(),
App.ServiceProvider.GetRequiredService<IUserUseCase>(),
HostScreen
));
});
OpenPresenceCommand = ReactiveCommand.Create(() =>
{
HostScreen.Router.Navigate.Execute(new PresenceViewModel(HostScreen));
});
GoBackCommand = ReactiveCommand.Create(() =>
{
HostScreen.Router.Navigate.Execute(new StartViewModel(HostScreen));
});
}
}
}