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

[NavSvc] make INavigationService.Navigate*() accepts dataContext as argument #944

Merged
merged 2 commits into from
Mar 13, 2024

Conversation

Palatis
Copy link
Contributor

@Palatis Palatis commented Feb 9, 2024

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

INavigationService lacks a way to specify dataContext for navigating.
Yes, we can get the underlying NavigationControl and navigate with dataContext object like this:

NavigationService.GetNavigationControl().Navigate(pageType, dataContext);
// or
NavigationService.GetNavigationControl().NavigateWithHierarchy(pageType, dataContext);

but... that's a bit tedious.

Issue Number: N/A

What is the new behavior?

add these 3 overload methods with dataContext to INavigationService

bool Navigate(Type pageType, object? dataContext);
bool Navigate(string pageIdOrTargetTag, object? dataContext);
bool NavigateWithHierarchy(Type pageType, object? dataContext);

so client code can just do NavigationService.Navigate(type, data) without the hassle.

Other information

However, if the current displaying page (ie. top-most navigation stack) is pageType, Navigate*(...) returns false and does nothing.
I managed to force-refresh the stack by doing this in client code:

while (!NavSvc.NavigateWithHierarchy(typeof(SomePage), someData))
{
    // failed, try pop the stack and try again
    if (!NavSvc.GoBack())
    {
        // cannot pop stack, really failed...
        Log.LogCritical(...);
        break;
    }
}

add these 3 overload methods with `dataContext` to `INavigationService` so that
```C#
bool Navigate(Type pageType, object dataContext);
bool Navigate(string pageIdOrTargetTag, object dataContext);
bool NavigateWithHierarchy(Type pageType, object dataContext);
```

However, if the current displaying page (ie. top-most navigation stack) is `pageType`, `Navigate*(...)` returns `false` and does nothing.
I managed to force-refresh the stack by doing this in client code:
```C#
while (!NavSvc.NavigateWithHierarchy(typeof(SomePage), someData)
{
    // failed, try pop the stack and try again
    if (!NavSvc.GoBack())
    {
        // cannot pop stack, really failed...
        Log.LogCritical(...);
        break;
    }
}
```
@Palatis Palatis requested a review from pomianowski as a code owner February 9, 2024 18:01
@Palatis Palatis changed the title [NavSvc] add dataContext to INavigationService.Navigate*() [NavSvc] make INavigationService.Navigate*() accepts dataContext as argument Feb 9, 2024
@pomianowski
Copy link
Member

Hey @Palatis, thanks for your contribution

@pomianowski pomianowski merged commit 8454e5b into lepoco:development Mar 13, 2024
1 of 2 checks passed
@Palatis Palatis deleted the feature/navsvc/datacontext branch March 13, 2024 11:55
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

Successfully merging this pull request may close these issues.

2 participants