Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented relative back behavior ("../../") #1427

Merged
merged 2 commits into from
Apr 27, 2018

Conversation

brianlagunas
Copy link
Member

@brianlagunas brianlagunas commented Apr 27, 2018

Description of Change

We have improved the relative back navigation feature to not require a page to push after the relative back instructions.

Behavioral Changes

Previously, when using the relative back feature ("../" ) you would be required to provide a page that would be pushed onto the navigation stack. That is no longer required. You may now chain together any number of relative go-back instructions to "go back".

For example:
Given your navigation stack looked like this: NavigationPage/UserList/UserDetails/LoginPage/EditUser

You can now indicate how many pages to remove, or "go back" by chaining the relative go-back instruction "../".

NavigationService.NavigateAsync("../../../");

This would result in going back three pages leaving you with the following navigation stack:

``NavigationPage/UserList`

NOTE - The pages in the stack prior to the current page (last page in the nav stack) will be removed without calling any INavAware methods. Only the current page (EditUser in this example) would perform a proper GoBackAsync and execute the INavAware methods.

NOTE - This feature is only supported while within the context of a NavigationPage.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard

@brianlagunas brianlagunas changed the title Implemented realtive back behavior ("../../") Implemented relative back behavior ("../../") Apr 27, 2018
@brianlagunas brianlagunas merged commit 47b306a into master Apr 27, 2018
@brianlagunas brianlagunas deleted the RelativeBackNavigation branch April 27, 2018 19:26
@dansiegel dansiegel added this to the Prism 7.1 for Xamarin.Forms milestone May 2, 2018
@mr5z
Copy link

mr5z commented Sep 23, 2019

Supposedly I want to remove a PopupPage from the navigation stack that is in the middle of other pages, how should I do it?
I'm unsure if that makes sense since, iirc, PopupPages are pushed on different stack (modal stack?)

Use case: I have multiple Rg.Plugins' popups that doesn't occupy the entire screen. I used this as contextual menus, snackbar, non-block/blocking loaders. I want to dismiss a specific popups only for a certain condition. Currently, I have this extension as a workaround:

public static async Task<INavigationResult> RemovePopupAsync<TViewModel>(this INavigationService navigationService) where TViewModel : ViewModelBase
{
    try
    {
        var service = Rg.Plugins.Popup.Services.PopupNavigation.Instance;
        var popupStack = service.PopupStack;
        if (popupStack.Count > 0)
        {
            var pageName = ToPage<TViewModel>();
            var page = popupStack.LastOrDefault(e => e.GetType().Name == pageName);
            await service.RemovePageAsync(page);
            return new NavigationResult { Success = true };
        }

        return new NavigationResult
        {
            Exception = new Exception("Popup stack is empty")
        };
    }
    catch (Exception ex)
    {
        return new NavigationResult { Exception = ex };
    }
}

The INavigationService is unused in the mean time since I don't know how can I invoke the INavigationAware methods.

Can we have something like this in the library?

@lock
Copy link

lock bot commented Jan 28, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants