Skip to content

Commit

Permalink
another parameter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dhindrik committed Jun 27, 2022
1 parent 941399c commit 8bc2793
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/MAUI/TinyMvvm.Maui/TinyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ protected bool Set<T>(ref T field, T newValue, [CallerMemberName] string? proper
return false;
}

private const string TinyParameterKey = "tinyParameter";
/// <inheritdoc />
public async void ApplyQueryAttributes(IDictionary<string, object> query)
{
Expand All @@ -178,9 +179,26 @@ public async void ApplyQueryAttributes(IDictionary<string, object> query)
return;
}

if (query.ContainsKey("tinyParameter"))
if (query.ContainsKey(TinyParameterKey))
{
NavigationParameter = query["tinyParameter"];
NavigationParameter = query[TinyParameterKey];

if (query.Count > 1)
{
var queryParameters = new Dictionary<string, object>();

foreach (var item in query)
{
if (item.Key == TinyParameterKey)
{
continue;
}

queryParameters.Add(item.Key, item.Value);
}

QueryParameters = queryParameters;
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/MAUI/TinyMvvm.Sample/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string Text
private ICommand show;
public ICommand Show => show ??= new TinyCommand<City>(async (city) =>
{
await Navigation.NavigateTo(nameof(DetailsViewModel), city);
await Navigation.NavigateTo($"{nameof(DetailsViewModel)}?id=1", city);
});

private ObservableCollection<City> cities = new ObservableCollection<City>();
Expand Down

0 comments on commit 8bc2793

Please sign in to comment.