Files
Wino-Mail/Wino.Calendar/Services/NavigationService.cs

63 lines
2.0 KiB
C#
Raw Normal View History

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Wino.Calendar.Views;
using Wino.Calendar.Views.Account;
using Wino.Calendar.Views.Settings;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Navigation;
using Wino.Core.UWP.Services;
using Wino.Views;
2025-05-18 14:06:25 +02:00
namespace Wino.Calendar.Services;
public class NavigationService : NavigationServiceBase, INavigationService
{
2025-05-18 14:06:25 +02:00
public Type GetPageType(WinoPage winoPage)
{
2025-05-18 14:06:25 +02:00
return winoPage switch
{
2025-05-18 14:06:25 +02:00
WinoPage.CalendarPage => typeof(CalendarPage),
WinoPage.SettingsPage => typeof(SettingsPage),
WinoPage.CalendarSettingsPage => typeof(CalendarSettingsPage),
WinoPage.AccountManagementPage => typeof(AccountManagementPage),
WinoPage.ManageAccountsPage => typeof(ManageAccountsPage),
WinoPage.PersonalizationPage => typeof(PersonalizationPage),
WinoPage.AccountDetailsPage => typeof(AccountDetailsPage),
WinoPage.EventDetailsPage => typeof(EventDetailsPage),
_ => throw new Exception("Page is not implemented yet."),
};
}
2025-05-18 14:06:25 +02:00
public void GoBack()
{
if (Window.Current.Content is Frame appFrame && appFrame.Content is AppShell shellPage)
2025-01-14 00:53:54 +01:00
{
2025-05-18 14:06:25 +02:00
var shellFrame = shellPage.GetShellFrame();
2025-01-14 00:53:54 +01:00
2025-05-18 14:06:25 +02:00
if (shellFrame.CanGoBack)
{
shellFrame.GoBack();
2025-01-14 00:53:54 +01:00
}
}
2025-05-18 14:06:25 +02:00
}
2025-01-14 00:53:54 +01:00
2025-05-18 14:06:25 +02:00
public bool Navigate(WinoPage page, object parameter = null, NavigationReferenceFrame frame = NavigationReferenceFrame.ShellFrame, NavigationTransitionType transition = NavigationTransitionType.None)
{
// All navigations are performed on shell frame for calendar.
2025-05-18 14:06:25 +02:00
if (Window.Current.Content is Frame appFrame && appFrame.Content is AppShell shellPage)
{
var shellFrame = shellPage.GetShellFrame();
2025-05-18 14:06:25 +02:00
var pageType = GetPageType(page);
2025-05-18 14:06:25 +02:00
shellFrame.Navigate(pageType, parameter);
return true;
}
2025-05-18 14:06:25 +02:00
return false;
}
}