public void InsertPageBefore(NavigationViewModel viewModel, NavigationViewModel before) { var pageBefore = FormsNavigation.NavigationStack.FirstOrDefault(x => x.BindingContext == before); var view = InstantiateView(viewModel); FormsNavigation.InsertPageBefore((Page)view, pageBefore); }
public async Task ClearModalStack(bool animate = false) { while (FormsNavigation.ModalStack.Count > 0) { await FormsNavigation.PopModalAsync(animate); } }
public void PopTo <T>() where T : class, IViewModel { var pagesToRemove = new List <Page>(); var upper = FormsNavigation.NavigationStack.Count; // Loop through the nav stack backwards for (int i = upper - 1; i >= 0; i--) { var currentPage = FormsNavigation.NavigationStack[i] as IViewFor; // Stop the whole show if one of the pages isn't an IViewFor if (currentPage == null) { return; } var strongTypedPaged = currentPage as IViewFor <T>; // If we hit the view model type, break out if (strongTypedPaged != null) { break; } // Finally - always add to the list pagesToRemove.Add(currentPage as Page); } foreach (var item in pagesToRemove) { FormsNavigation.RemovePage(item); } }
/// <inheritdoc /> public async Task PushAsync(BaseNavigationViewModel viewModel, bool discardCurrent = false) { var currentPage = FormsNavigation.NavigationStack.LastOrDefault(); var view = InstantiateView(viewModel); if (currentPage.BindingContext is INavigationAware navPrevious) { navPrevious.OnNavigatingFrom(); } if (viewModel is INavigationAware navForward) { navForward.OnNavigatingTo(); } await FormsNavigation.PushAsync((Page)view); if (viewModel is INavigationAware navigated) { navigated.OnNavigatedTo(); } if (discardCurrent) { FormsNavigation.RemovePage(currentPage); } }
public async Task PushAsync(Type pageModelType, NavigationState navState) { var page = InstantiatePage(pageModelType, navState); await FormsNavigation.PushAsync((Page)page, false); PrintNavigationStackDepth("PushAsync"); }
/// <inheritdoc /> public async Task PushModalAsync(BaseNavigationViewModel viewModel) { viewModel.IsModal = true; var view = InstantiateView(viewModel); var nv = new NavigationPage((Page)view); await FormsNavigation.PushModalAsync(nv); }
public async Task PushAsync <TViewModel>(object parameter) where TViewModel : CoffeeShopBaseViewModel { Page page = CreatePage(typeof(TViewModel), parameter); await(page.BindingContext as CoffeeShopBaseViewModel).InitializeAsync(parameter); await FormsNavigation.PushAsync(page); }
public async Task PushModalAsync <TViewModel>() where TViewModel : CoffeeShopBaseViewModel { Page page = CreatePage(typeof(TViewModel), null); //Put in NavigationPage to use title bar var nv = new NavigationPage(page); await FormsNavigation.PushModalAsync(nv); }
public async Task PopModalAsync(bool animate = false) { await FormsNavigation.PopModalAsync(animate); var currentPageBindingContext = (NavigationViewModel)NavigationPage?.CurrentPage.BindingContext; currentPageBindingContext?.OnRevealed(); }
public async Task PushModalAsync <T>(T viewModel) where T : class, IViewModel { var view = InstantiateView(viewModel); // Most likely we're going to want to put this into a navigation page so we can have a title bar on it var nv = new NavigationPage((Page)view); await FormsNavigation.PushModalAsync(nv); }
public async Task PushModalAsync(Type pageModelType) { var page = InstantiatePage(pageModelType, new NavigationState(Modal)); await FormsNavigation.PushModalAsync((Page)page, false); PrintModalStackDepth("PushModalAsync"); }
/// <inheritdoc /> public async Task PopToRootAsync(BaseNavigationViewModel vm, bool animate) { var navPage = InstantiateView(vm) as Page; var root = FormsNavigation.NavigationStack.First(); FormsNavigation.InsertPageBefore(navPage, root); await FormsNavigation.PopToRootAsync(animate); }
public async Task ReplaceAsync(Type pageModelType, NavigationState navState) { var oldTopPage = TopPage; await PushAsync(pageModelType, navState); FormsNavigation.RemovePage(oldTopPage); PrintNavigationStackDepth("ReplaceAsync"); }
public async Task PushModalAsync <TViewModel>(object parameter) where TViewModel : CoffeeShopBaseViewModel { Page page = CreatePage(typeof(TViewModel), parameter); await(page.BindingContext as CoffeeShopBaseViewModel).InitializeAsync(parameter); //Put in NavigationPage to use title bar var nv = new NavigationPage(page); await FormsNavigation.PushModalAsync(nv); }
/// <inheritdoc /> public async Task PushAsync(BaseNavigationViewModel viewModel, bool discardCurrent = false) { var currentPage = FormsNavigation.NavigationStack.LastOrDefault(); var view = InstantiateView(viewModel); await FormsNavigation.PushAsync((Page)view); if (discardCurrent && currentPage != null) { FormsNavigation.RemovePage(currentPage); } }
public Task PushModalAsync(BaseNavigationViewModel viewModel) { viewModel.Display = ViewModelDisplay.Modal; var view = InstantiateView(viewModel); // Most likely we're going to want to put this into a navigation page so we can have a title bar on it var nv = new NavigationPage((Page)view); return(FormsNavigation.PushModalAsync(nv)); }
public async Task PushModalAsync(Type viewModelType) { var viewModel = this._viewModelViewDictionary.FirstOrDefault(vm => vm.Key.GetType() == viewModelType).Key; this.InitCurrentViewModel(false); var view = this.GetAssociatedView(viewModel); // Most likely we're going to want to put this into a navigation page so we can have a title bar on it var nv = new NavigationPage((Page)view); await FormsNavigation.PushModalAsync(nv); this.InitCurrentViewModel(true); }
public async Task PopToSharedAsync() { if (SharedPageDepth == 0) { throw new InvalidOperationException( "SharedPageDepth must be greater than 0 if specified"); } while (NavigationStackDepth > (SharedPageDepth ?? 1)) { await FormsNavigation.PopAsync(false); } PrintNavigationStackDepth("PopToSharedAsync"); }
public async Task ReplaceRootAsync(Type pageModelType, NavigationState navState = null) { var pageList = FormsNavigation.NavigationStack.ToList(); await PushAsync(pageModelType, navState); // Clean up old pages foreach (var page in pageList) { FormsNavigation.RemovePage(page); } PrintNavigationStackDepth("ReplaceRootAsync"); }
public async Task PushAsync(NavigationViewModel viewModel, bool animate = false) { try { var oldViewModel = (NavigationViewModel)NavigationPage?.CurrentPage.BindingContext; var view = InstantiateView(viewModel); await FormsNavigation.PushAsync((Page)view, animate); oldViewModel?.OnHidden(); } catch { // ignored as non critical exceptions don't stop the app from working } }
public Task PushModalAsync(BaseViewModel viewModel, bool nestedNavigation = false) { var view = InstantiateView(viewModel); Page page; if (nestedNavigation) { page = new NavigationPage((Page)view); } else { page = (Page)view; } return(FormsNavigation.PushModalAsync(page)); }
/// <inheritdoc /> public async Task PushAsync <T>(Action <T> initialize = null, bool discardCurrent = false) where T : BaseNavigationViewModel { T viewModel; var currentPage = FormsNavigation.NavigationStack.LastOrDefault(); // Instantiate the view model & invoke the initialize method, if any viewModel = Activator.CreateInstance <T>(); initialize?.Invoke(viewModel); await PushAsync(viewModel); if (discardCurrent && currentPage != null) { FormsNavigation.RemovePage(currentPage); } }
public Task PushModalAsync(BaseViewModel viewModel, bool nestedNavigation = false, bool animated = true) { viewModel.ViewDisplay = ViewDisplayType.Modal; var view = InstantiateView(viewModel); Page page; if (nestedNavigation) { page = new NavigationPage((Page)view); } else { page = (Page)view; } return(FormsNavigation.PushModalAsync(page, animated)); }
public async Task PushModalAsync(NavigationViewModel viewModel, bool animate = false) { try { var oldViewModel = (NavigationViewModel)NavigationPage?.CurrentPage.BindingContext; var view = InstantiateView(viewModel); // Most likely we're going to want to put this into a navigation page so we can have a title bar on it var nv = new NavigationPage((Page)view); await FormsNavigation.PushModalAsync(nv, animate); oldViewModel?.OnHidden(); } catch { // ignored as non critical exceptions don't stop the app from working } }
/// <inheritdoc /> public async Task PopAsync() { var currentPage = FormsNavigation.NavigationStack.LastOrDefault(); var pageWeGoBackTo = FormsNavigation.NavigationStack.Reverse().Skip(1).FirstOrDefault(); if (pageWeGoBackTo != null) { if (pageWeGoBackTo.BindingContext is INavigationAware pageWeGoBackNav) { pageWeGoBackNav.OnNavigatingTo(); } if (pageWeGoBackTo is TabbedPage tbPage) { if (tbPage.CurrentPage.InternalChildren[0].BindingContext is INavigationAware tabb) { tabb.OnNavigatingTo(); } } } if (currentPage.BindingContext is INavigationAware nav) { nav.OnNavigatingFrom(); } await FormsNavigation.PopAsync(true); if (pageWeGoBackTo != null) { if (pageWeGoBackTo.BindingContext is INavigationAware pageWeGoBackNav) { pageWeGoBackNav.OnNavigatedTo(); } if (pageWeGoBackTo is TabbedPage tbPage) { if (tbPage.CurrentPage.InternalChildren[0].BindingContext is INavigationAware tabb) { tabb.OnNavigatedTo(); } } } }
/// <inheritdoc /> public async Task PushModalAsync(BaseNavigationViewModel viewModel) { viewModel.IsModal = true; var currentPage = FormsNavigation.NavigationStack.LastOrDefault(); if (currentPage.BindingContext is INavigationAware navPrevious) { navPrevious.OnNavigatingFrom(); } if (viewModel is INavigationAware navForward) { navForward.OnNavigatingTo(); } var view = InstantiateView(viewModel); var nv = new NavigationPage((Page)view); await FormsNavigation.PushModalAsync(nv); }
public async Task PopToRootAsync() { switch (Device.RuntimePlatform) { // TODO Test if still need case Device.UWP: // Fix for Windows and Windows Phone while (NavigationStackDepth > 1) { await FormsNavigation.PopAsync(false); } break; default: await FormsNavigation.PopToRootAsync(false); break; } PrintNavigationStackDepth("PopToRootAsync"); }
public async Task PopModalAsync() { await FormsNavigation.PopModalAsync(true); }
public async Task PushAsync <TViewModel>() where TViewModel : CoffeeShopBaseViewModel { Page page = CreatePage(typeof(TViewModel), null); await FormsNavigation.PushAsync(page); }
public async Task PopToRootAsync() { await FormsNavigation.PopToRootAsync(true); }