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

Add the ability to perform non-Shell page navigation #421

Open
Dreamescaper opened this issue Oct 15, 2021 · 2 comments
Open

Add the ability to perform non-Shell page navigation #421

Dreamescaper opened this issue Oct 15, 2021 · 2 comments

Comments

@Dreamescaper
Copy link
Contributor

Dreamescaper commented Oct 15, 2021

Currently we have ShellNavigationManager for url-based navigation, but it has its own limitations:

  • Can be used with Shell only
  • Cannot pass arbitrary parameters, only the ones based on URL
  • Cannot be used with modals (we have ModalContainer for modals, but it's not very convenient)

I would suggest to add a service for navigation, which would allow to work with components:

interface INavigationService
{
    Task PushAsync<T>(Dictionary<string, object> arguments = null, bool animated = true) where T: IComponent;
    Task PushModalAsync<T>(Dictionary<string, object> arguments = null, bool animated = true) where T: IComponent;

    // Optional, just for convenience (as you can do same now via NativeElement property)
    Task PopToRootAsync(bool animated = true);
    Task PopModalAsync(bool animated = true);
    Task PopAsync(bool animated = true);    
}

This way navigation would look smth like that:

       @inject INavigationService NavigationService

	async Task Navigate()
	{
		await NavigationService.PushAsync<MyPage>(new()
		{
			[nameof(MyPage.Parameter1)] = arg1,
			[nameof(MyPage.Parameter2)] = arg2
		});
	}

It would be great to design this service with extensibility in mind, so that I could, for example, add extension method ShowPopupAsync to display XCT's Popup.

Open questions:

  • How to name it to avoid confusion? We have ShellNavigationManager, we have NavigationManager from web Blazor, would NavigationService be fine?
  • Would it make any sense to merge it with existing ShellNavigationManager ?
  • Can I always use Application.Current.MainPage.Navigation to get INavigation?
  • Is there any Navigated event we could use to dispose the renderer when the page is closed?
@Dreamescaper
Copy link
Contributor Author

Requires #418 .

@Dreamescaper
Copy link
Contributor Author

Dreamescaper commented Oct 15, 2021

We could also provide RenderFragment overloads to allow a bit exotic syntax:

async Task Navigate()
{
    await NavigationService.PushAsync(
        @<MyPage Parameter1="arg1" Parameter2="arg2" />
    );
}

@Dreamescaper Dreamescaper mentioned this issue Jun 8, 2022
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant