2026-03-11 01:39:32 +01:00
|
|
|
using System.Threading.Tasks;
|
2026-03-12 14:55:07 +01:00
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
2026-03-11 01:39:32 +01:00
|
|
|
using Wino.Core.Domain;
|
|
|
|
|
using Wino.Core.Domain.Enums;
|
|
|
|
|
using Wino.Core.Domain.Interfaces;
|
|
|
|
|
using Wino.Core.Domain.MenuItems;
|
|
|
|
|
using Wino.Core.Domain.Models;
|
|
|
|
|
using Wino.Core.Domain.Models.Navigation;
|
|
|
|
|
using Wino.Core.ViewModels;
|
2026-03-12 14:55:07 +01:00
|
|
|
using Wino.Messaging.Client.Contacts;
|
2026-03-11 01:39:32 +01:00
|
|
|
|
|
|
|
|
namespace Wino.Mail.WinUI.ViewModels;
|
|
|
|
|
|
|
|
|
|
public sealed class ContactsShellClient(INavigationService navigationService) : CoreBaseViewModel, IShellClient
|
|
|
|
|
{
|
2026-03-12 14:55:07 +01:00
|
|
|
private readonly NewContactMenuItem _newContactMenuItem = new();
|
|
|
|
|
|
2026-03-11 01:39:32 +01:00
|
|
|
public WinoApplicationMode Mode => WinoApplicationMode.Contacts;
|
|
|
|
|
public MenuItemCollection? MenuItems { get; private set; }
|
|
|
|
|
public object? SelectedMenuItem { get; set; }
|
|
|
|
|
public bool HandlesNavigationSelection => false;
|
|
|
|
|
|
|
|
|
|
protected override void OnDispatcherAssigned()
|
|
|
|
|
{
|
|
|
|
|
base.OnDispatcherAssigned();
|
|
|
|
|
MenuItems ??= new MenuItemCollection(Dispatcher);
|
2026-03-12 14:55:07 +01:00
|
|
|
|
|
|
|
|
if (MenuItems.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MenuItems.Add(_newContactMenuItem);
|
|
|
|
|
}
|
2026-03-11 01:39:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Activate(ShellModeActivationContext activationContext)
|
|
|
|
|
{
|
|
|
|
|
OnNavigatedTo(NavigationMode.New, activationContext);
|
|
|
|
|
navigationService.Navigate(WinoPage.ContactsPage, null, NavigationReferenceFrame.InnerShellFrame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Deactivate()
|
|
|
|
|
{
|
|
|
|
|
OnNavigatedFrom(NavigationMode.New, null!);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 14:55:07 +01:00
|
|
|
public Task HandleNavigationItemInvokedAsync(IMenuItem? menuItem)
|
|
|
|
|
{
|
|
|
|
|
if (menuItem is NewContactMenuItem)
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new NewContactRequested());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
2026-03-11 01:39:32 +01:00
|
|
|
|
|
|
|
|
public Task HandleNavigationSelectionChangedAsync(IMenuItem? menuItem) => Task.CompletedTask;
|
|
|
|
|
}
|