59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Asistencia.Models;
|
|
using Asistencia.Services;
|
|
using Avalonia.Controls;
|
|
using Asistencia.Views;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace Asistencia.ViewModels;
|
|
|
|
public partial class MainWindowViewModel : ObservableObject
|
|
{
|
|
private readonly AuthService _authService;
|
|
private readonly AsistenciaService _asistenciaService;
|
|
private object? _currentView;
|
|
|
|
[ObservableProperty]
|
|
private string _currentViewTitle = "Login";
|
|
|
|
public object? CurrentView
|
|
{
|
|
get => _currentView;
|
|
set => SetProperty(ref _currentView, value);
|
|
}
|
|
|
|
public MainWindowViewModel(AuthService authService, AsistenciaService asistenciaService)
|
|
{
|
|
_authService = authService;
|
|
_asistenciaService = asistenciaService;
|
|
CurrentView = new LoginViewModel(authService, this);
|
|
}
|
|
|
|
public void NavigateToLogin()
|
|
{
|
|
CurrentViewTitle = "Login";
|
|
CurrentView = new LoginViewModel(_authService, this);
|
|
}
|
|
|
|
public void NavigateToDashboard()
|
|
{
|
|
CurrentViewTitle = "Panel Principal";
|
|
CurrentView = new DashboardViewModel(_authService, _asistenciaService, this);
|
|
}
|
|
|
|
public void NavigateToAsistencia(CursoAbierto curso)
|
|
{
|
|
CurrentViewTitle = "Asistencia";
|
|
CurrentView = new AsistenciaViewModel(_asistenciaService, _authService, curso, this);
|
|
}
|
|
|
|
public void NavigateToPerfil()
|
|
{
|
|
CurrentViewTitle = "Mi Perfil";
|
|
CurrentView = new PerfilViewModel(_authService, this);
|
|
}
|
|
|
|
public string UsuarioActual => _authService.CurrentUser?.NombreCompleto ?? "";
|
|
}
|