Implement NavigateFromAsync method without recreating a page.#3182
Implement NavigateFromAsync method without recreating a page.#3182niimima wants to merge 15 commits intoPrismLibrary:masterfrom
Conversation
|
I have a concern regarding the pull request I've created. When searching for a page using In the current implementation, pages specified by route appears directly under the window. |
| { | ||
| if (page is not null && ViewModelLocator.GetNavigationName(page) == viewName) | ||
| break; | ||
| page = page.GetParentPage(); |
There was a problem hiding this comment.
Parent page? Shouldn't this be the page before the current page in the stack and if it is the root page then we get the parent page?
There was a problem hiding this comment.
@AmrAlSayed0 is correct. While we do care about the parent in some scenarios, what we really need is the previous page in the navigation stack.
There was a problem hiding this comment.
There are still some issues remaining, but I have made corrections to use the NavigationStack as described in the following link.
Prism/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
Lines 351 to 383 in 7f8a12f
|
This PR is not performing the actions required of the issue. Per the issue
This means you must first find the page, while keeping track of the number of times we must navigate back until we reach this page, and then begin navigating forward from there. Decisions must also be made as to whether this can be supported in both a modal and non-modal navigation stack. While also considering the page's parent such as a TabbedPage or FlyoutPage |
Thank you for your feedback. Firstly, I am working on ensuring that the navigation works correctly with both TabbedPage and FlyoutPage. The FlyoutPage seems to be working well, but I need to confirm the specifications for the TabbedPage. In the existing NavigateAsync method, you can use KnownNavigationParameters to either create or select a tab. For the NavigateFromAsync method, which approach would be more appropriate? Or, would it be better to dynamically switch between creating and selecting tabs based on the situation? |
dansiegel
left a comment
There was a problem hiding this comment.
This really should work across both Modal and Non-Modal Navigation Stacks. I would suggest looking at the helpers we have that walk the NavigationStack today. That should help you to build something that can go the reverse direction to locate a given view.
| public static Task<INavigationResult> NavigateFromAsync(this INavigationService navigationService, string viewName, Uri route) => | ||
| navigationService.NavigateFromAsync(viewName, route, new NavigationParameters()); |
There was a problem hiding this comment.
This would need some overloads that take a string for the route as well.
There was a problem hiding this comment.
I have addressed this in the following commit: 5ce2b81
There was a problem hiding this comment.
@dansiegel
We have completed the implementation to ensure it works across both Modal and Non-Modal Navigation Stacks. In our unit tests, it is working as expected. Could you please review and confirm? Let us know if there are any issues or further improvements needed.
This reverts commit 5af4754.
7f8a12f to
75ef645
Compare
Co-authored-by: Dan Siegel <[email protected]>
Co-authored-by: Dan Siegel <[email protected]>
Description of Change
Adding NavigateFromAsync methods without recreating a page.
Bugs Fixed
API Changes
List all API changes here (or just put None),
Added:
Behavioral Changes
No changes. Only additions of features.
PR Checklist