using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using LehrerApp.Core.Services; using LehrerApp.Desktop.ViewModels.Groups; using LehrerApp.Desktop.ViewModels.Students; using Microsoft.Extensions.DependencyInjection; namespace LehrerApp.Desktop.ViewModels; public partial class MainWindowViewModel : ObservableObject { private readonly IServiceProvider _services; [ObservableProperty] private ObservableObject? _currentPage; [ObservableProperty] private NavItem _activeNavItem = NavItem.Dashboard; [ObservableProperty] private string _currentSchoolYear = ""; public MainWindowViewModel(IServiceProvider services, DashboardViewModel dashboard, SchoolYearService sy) { _services = services; CurrentSchoolYear = sy.CurrentSchoolYear(); CurrentPage = dashboard; } [RelayCommand] private void NavigateTo(NavItem item) { ActiveNavItem = item; CurrentPage = item switch { NavItem.Dashboard => _services.GetRequiredService(), NavItem.Groups => _services.GetRequiredService(), NavItem.Students => _services.GetRequiredService(), NavItem.Exams => new PlaceholderViewModel { Title = "Klausuren", Icon = "📝" }, NavItem.Planner => new PlaceholderViewModel { Title = "Unterrichtsplanung", Icon = "📅" }, NavItem.Workload => new PlaceholderViewModel { Title = "Arbeitszeit", Icon = "⏱" }, NavItem.Settings => new PlaceholderViewModel { Title = "Einstellungen", Icon = "⚙️" }, _ => CurrentPage, }; } public void NavigateToGroupDetail(Guid groupId) { ActiveNavItem = NavItem.Groups; var vm = _services.GetRequiredService(); vm.LoadGroup(groupId); CurrentPage = vm; } public void NavigateToStudent(Guid studentId) { ActiveNavItem = NavItem.Students; var vm = _services.GetRequiredService(); vm.LoadStudent(studentId); CurrentPage = vm; } } public enum NavItem { Dashboard, Groups, Students, Exams, Planner, Workload, Settings } public partial class PlaceholderViewModel : ObservableObject { [ObservableProperty] private string _title = ""; [ObservableProperty] private string _icon = ""; }