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

[Feature] URL-based navigation #1

Closed
BurkusCat opened this issue Oct 2, 2023 · 3 comments · Fixed by #23
Closed

[Feature] URL-based navigation #1

BurkusCat opened this issue Oct 2, 2023 · 3 comments · Fixed by #23
Assignees
Labels
enhancement New feature or request

Comments

@BurkusCat
Copy link
Owner

Is your feature request related to a problem? Please describe.
When doing a complicated navigation, I need to build up multiple push calls and use animation parameters in a certain way to get the navigation I want. A URI based navigation option would simplify complex navigation and provide a way for the library to do more optimised/performant navigation (with less jank).

Describe the solution you'd like
New navigation service methods for navigation to URIs. I want to be able to build up a URI manually for simpler scenarios. I should be able to pass parameters. I also should be able to use a custom, static URI builder to generate more complex URIs (e.g. where I have different parameters passed to each page along the URI). The builder should be separate from the navigation methods to allow for testability.

Describe alternatives you've considered
N/A

Proposed APIs

// INavigationService
Task Navigate(string uri);

Task Navigate(Uri uri);

Task Navigate(string uri, NavigationParameters parameters);

Task Navigate(Uri uri, NavigationParameters parameters);

This needs thought about more and improved:

// BurkusMvvmUriBuilder
var uri = new BurkusMvvmUriBuilder()
    .AddSegment(nameof(PageOne))
    .AddParameters(new NavigationParameters { { "test", 2 } })
    .AddSegment(nameof(PageTwo))
    .Build()

navigationService.Navigate(uri);

Additional context
N/A

@BurkusCat BurkusCat added the enhancement New feature or request label Oct 2, 2023
@BurkusCat
Copy link
Owner Author

Some implementation ideas:

  • Split the URL into a series of steps
  • Is it an absolute URL?
    • Do a reset and push navigation page first?
  • Push pages and trigger their OnNavigatedToEvents in sequence
    • Presumably OnNavigatedFrom shouldn't be triggered for most pages?
  • Trigger OnNavigatedFrom for the page before the navigation begins (probably the first thing that should be done)
  • Parameters should be taken into account at each segment for tab switching, modals and animations

@BurkusCat
Copy link
Owner Author

BurkusCat commented Oct 7, 2023

In the proposal, I suggested Task Navigate(Uri uri); as an option. In practice, I think passing a real Uri object to this method is unlikely to be more useful than a string given the URI syntax for this framework isn't really a proper URL with a domain etc. It probably makes sense to not have this method, and just have the string method.

@BurkusCat BurkusCat linked a pull request Oct 12, 2023 that will close this issue
@BurkusCat BurkusCat removed a link to a pull request Oct 12, 2023
@BurkusCat BurkusCat linked a pull request Oct 12, 2023 that will close this issue
@BurkusCat
Copy link
Owner Author

The merged PR adds this feature but I expect the behaviour to need to change over time. I expect that the jankiness of the visuals could be improved, that when parameters trigger could be improved etc.

@BurkusCat BurkusCat unpinned this issue Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant