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

Added GlobalProviderState to ProviderManager property for easy binding #117

Merged
merged 2 commits into from
Jun 24, 2021

Conversation

shweaver-MSFT
Copy link
Member

@shweaver-MSFT shweaver-MSFT commented Jun 11, 2021

Fixes #

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

SwitchPresenter from WCT doesn't work well with the GlobalProvider state as it exists today. It is not possible to simply use ProviderManager.Instance.GlobalProvider.State because the GlobalProvider.State is only available after the provider has been set, so the initial binding fails and updates are never processed.

What is the new behavior?

Use the new GlobalProviderState getter to retrieve the current state of the active GlobalProvider, or null if none.

This is helpful for binding in XAML, since GlobalProviderState is consistently available via the ProviderManager.Instance singleton.

<controls:SwitchPresenter Value="{x:Bind auth:ProviderManager.Instance.GlobalProviderState, Mode=OneWay}">

    <controls:Case Value="{x:Bind auth:ProviderState.SignedIn}">
        <TextBlock Text="Signed in!" />
    </controls:Case>

    <controls:Case Value="{x:Bind auth:ProviderState.SignedOut}">
        <TextBlock Text="Signed out" />
    </controls:Case>

    <controls:Case Value="{x:Bind auth:ProviderState.Loading}">
        <TextBlock Text="Loading..." />
    </controls:Case>

    <controls:Case IsDefault="True">
        <TextBlock Text="No provider is set" />
    </controls:Case>
</controls:SwitchPresenter>

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Jun 11, 2021

Thanks shweaver-MSFT for opening a Pull Request! The reviewers will test the PR and highlight if there is any merge conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@shweaver-MSFT shweaver-MSFT merged commit b13ff7b into dev/7.1.0 Jun 24, 2021
@shweaver-MSFT shweaver-MSFT deleted the shweaver/switch-presenter branch June 24, 2021 18:02
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.

3 participants