/// <summary> /// Registers and shows the page to act as the application's primary Home view /// </summary> /// <typeparam name="TView"></typeparam> /// <param name="wrapInNavigationPage">Set to <b>true</b> if the view is not already a NavigationPage.</param> /// <param name="showImmediately">Set to <b>true</b> to have this call to show the view. <b>False</b> to have it only created and registered.</param> public static void SetHomeView <TView>(bool wrapInNavigationPage, bool showImmediately = true) where TView : Page, new() { var fromPageName = Analytics.GetPageName(CurrentView); lock (m_mainViewSyncRoot) { var view = CreateViewAndViewModel <TView>(); if (wrapInNavigationPage) { m_homeView = new NavigationPage(view) { Title = view.Title ?? "[Title not set]" }; } else { m_homeView = view; } if (showImmediately) { Application.Current.MainPage = m_homeView; } } var toPageName = Analytics.GetPageName(m_homeView); Analytics.LogPageNavigation(fromPageName, toPageName); }
private static async Task ShowView(Page view, bool animated, bool modal) { Validate.Begin() .IsNotNull(m_homeView, "SetHomeView has not been called") .Check(); var fromViewName = Analytics.GetPageName(CurrentView); var toViewName = Analytics.GetPageName(view); if (view.Parent != null) { view.Parent = null; } if (modal) { await m_homeView.Navigation.PushModalAsync(view, animated); } else { await m_homeView.Navigation.PushAsync(view, animated); } Analytics.LogPageNavigation(fromViewName, toViewName); }
private static void OnMultiPageChanged(object sender, EventArgs e) { var source = sender as CarouselPage; var toPage = Analytics.GetPageName(source.CurrentPage); Analytics.LogPageNavigation(null, toPage); }
public async static Task NavigateBack(bool animated) { Validate.Begin() .IsTrue(Navigation.NavigationStack.Count > 1, "Already at the start of the navigation stack") .Check(); var fromPageName = Analytics.GetPageName(CurrentView); if (m_navigating) { return; } try { await m_homeView.Navigation.PopAsync(animated); } finally { m_navigating = false; } var toPageName = Analytics.GetPageName(CurrentView); Analytics.LogPageNavigation(fromPageName, toPageName); }
public async static Task HideModal(bool animated) { Validate.Begin() .IsTrue(Navigation.ModalStack.Count > 0, "No modal found") .Check(); var fromPageName = Analytics.GetPageName(CurrentView); await m_homeView.Navigation.PopModalAsync(animated); var toPageName = Analytics.GetPageName(CurrentView); Analytics.LogPageNavigation(fromPageName, toPageName); }
/// <summary> /// Registers a Page to be used as the LoginView /// </summary> /// <typeparam name="TView">Type of the page that is your Login page</typeparam> /// <param name="showImmediately">Set to <b>true</b> to have this call to show the view. <b>False</b> to have it only created and registered.</param> public static void SetLoginView <TView>(bool showImmediately = false) where TView : Page, new() { var fromPageName = Analytics.GetPageName(CurrentView); lock (m_mainViewSyncRoot) { var view = CreateViewAndViewModel <TView>(); m_loginView = view; if (showImmediately) { Application.Current.MainPage = m_loginView; } } var toPageName = Analytics.GetPageName(m_homeView); Analytics.LogPageNavigation(fromPageName, toPageName); }
public async static Task ShowLogin(bool animate = false) { var fromPageName = Analytics.GetPageName(CurrentView); Validate.Begin() .IsNotNull(m_loginView, "SetLoginView has not been called") .Check(); // if we have no main page yet (first opening app), this becomes the main page if (Application.Current.MainPage == null) { Application.Current.MainPage = m_loginView; } // otherwise (user session timeout, etc), we're just a modal on top of whatever is there else { await ShowView(m_loginView, animate, false); } var toPageName = Analytics.GetPageName(CurrentView); Analytics.LogPageNavigation(fromPageName, toPageName); }
public async static Task ShowHome() { Validate.Begin() .IsNotNull(m_homeView, "SetHomeView has not been called") .Check(); var fromPageName = Analytics.GetPageName(CurrentView); // if the current page is the login, just show the home page if (Application.Current.MainPage == m_loginView) { Application.Current.MainPage = m_homeView; } // otherwise pop everything off the nav stack back to home else { await m_homeView.Navigation.PopToRootAsync(true); } var toPageName = Analytics.GetPageName(CurrentView); Analytics.LogPageNavigation(fromPageName, toPageName); }