Skip to content

Commit

Permalink
fix: fix AvantiPoint#21 circulation dependence of DefaultNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
maonaoda committed May 22, 2024
1 parent 41fb4b1 commit fc1206b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/MauiMicroMvvm/Internals/DefaultNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ namespace MauiMicroMvvm.Internals;
[EditorBrowsable(EditorBrowsableState.Never)]
public class DefaultNavigation<TShell> : INavigation where TShell : Shell
{
private readonly TShell _shell;
private readonly Lazy<TShell> _lazyShell;
private TShell Shell => _lazyShell.Value;

public DefaultNavigation(TShell shell)
public DefaultNavigation(IServiceProvider services)
{
_shell = shell;
_lazyShell = new Lazy<TShell>(services.GetRequiredService<TShell>);
}

public async Task GoToAsync(string uri) =>
await _shell.GoToAsync(uri);
await Shell.GoToAsync(uri);

public async Task GoToAsync(string uri, IDictionary<string, object> parameters) =>
await _shell.GoToAsync(uri, parameters);
await Shell.GoToAsync(uri, parameters);

public async Task GoToAsync(string uri, bool animate) =>
await _shell.GoToAsync(uri, animate);
await Shell.GoToAsync(uri, animate);

public async Task GoToAsync(string uri, bool animate, IDictionary<string, object> parameters) =>
await _shell.GoToAsync(uri, animate, parameters);
await Shell.GoToAsync(uri, animate, parameters);
}

0 comments on commit fc1206b

Please sign in to comment.