presence/Presence.Desktop/ViewModels/StartViewModel.cs

47 lines
1.5 KiB
C#
Raw Permalink Normal View History

2025-04-30 01:13:44 +00:00
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));
});
}
}