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

[Enhancement] GetNavigationUriPath For Maui #3092

Open
Axemasta opened this issue Feb 28, 2024 · 3 comments
Open

[Enhancement] GetNavigationUriPath For Maui #3092

Axemasta opened this issue Feb 28, 2024 · 3 comments

Comments

@Axemasta
Copy link
Contributor

Summary

In Prism Forms we had the extension method GetNavigationUriPath, which when called would give you the current Uri of the INavigationService. In maui this extension no longer exists and reading the current Uri from a Viewmodel is incredibly difficult. We can observe the current Uri using the global navigation observer, however performing viewmodel based logic on the current Uri path is difficult.

API Changes

Add a new INavigationServiceExtension method named GetNavigationUriPath

Intended Use Case

Performing logic in a view model based on the page uri stack. For example we could have a Login page which can be accessed in multiple ways:

  1. Open app for the first time, see a welcome flow & agree to privacy policy, complete flow and show login page. For this scneario we want to show a back button to go back into the privacy flow
  2. Open app after agreeing to privacy, go directly to the login page. In this case we don't want to show a back button because we are at the bottom of our navigation stack.
@NiranjanXamarin
Copy link

NiranjanXamarin commented Feb 29, 2024

Hello @Axemasta I am also facing this issue when I am migration Xamarin.Forms application to MAUI. Please let me know if you have any workaround to get NavigationStack in MAUI then please share. will be really appreciated. Thanks.

@maonaoda
Copy link

maonaoda commented Mar 8, 2024

@NiranjanXamarin
you can use IPageAccessor to get the NavigationStack

codes like this:

public XXXViewModel(IPageAccessor pageAccessor){
  var nvStack = pageAccessor.Page.Navigation.NavigationStack;
}

@NiranjanXamarin
Copy link

@maonaoda thanks alot. You saved my time. Appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants