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

Make the Resolve method public #31

Open
IeuanWalker opened this issue Apr 25, 2024 · 1 comment
Open

Make the Resolve method public #31

IeuanWalker opened this issue Apr 25, 2024 · 1 comment

Comments

@IeuanWalker
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'd like to be able to use the Resolve method directly in order to extend the functionality for things other than INavigation.

Describe the solution you'd like
Make certain methods public, or possibly even create a separate project for Mopups support and give it access to internal methods of this project.

Additional context
We use Mopups for our popups in our app. After a quick fiddle, I was able to get PageResolver to work with Mopups.

For example, I registered the popup and ViewModel like any other page -

builder.Services.AddTransient<AddPopup>();
builder.Services.AddTransient<AddReminderViewModel>();

builder.Services.UsePageResolver(new Dictionary<Type, Type>()
{
	{ typeof(AddPopup), typeof(AddReminderViewModel) }
});

I then made the Resolve<T> public, and was able to get this to work -

await MopupService.Instance.PushAsync(Resolver.Resolve<AddPopup>());

Obviously, I'd need to do quite a bit more work to get it to work with parameters.
Just seeing if you're open to something like this?

@IeuanWalker
Copy link
Contributor Author

IeuanWalker commented Apr 25, 2024

@matt-goldman Actually it's quite straightforward.

No parameters

To inject a popup with no parameters, I just need the Resvole method made public -
https://github.com/matt-goldman/Maui.Plugins.PageResolver/blob/ff594dae8a38a20d365ca9748214a17df90aa052/src/Maui.Plugins.PageResolver/Resolver.cs#L63C5-L63C51

await MopupService.Instance.PushAsync(Resolver.Resolve<AddPopup>());

With parameters

To inject a popup with parameters, just need the ResolvePage<T> method made public (PopupPage is just a ContentPage so the current code works fine)

private static Page ResolvePage<T>(params object[] parameters) where T : Page

await MopupService.Instance.PushAsync((PopupPage)NavigationExtensions.ResolvePage<AddPopup>(123));

Might need to think of a way to avoid the cast though

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