diff --git a/CommunityToolkit.Authentication.Uwp/CommunityToolkit.Authentication.Uwp.csproj b/CommunityToolkit.Authentication.Uwp/CommunityToolkit.Authentication.Uwp.csproj
index d6d0735..01d1e55 100644
--- a/CommunityToolkit.Authentication.Uwp/CommunityToolkit.Authentication.Uwp.csproj
+++ b/CommunityToolkit.Authentication.Uwp/CommunityToolkit.Authentication.Uwp.csproj
@@ -3,7 +3,6 @@
uap10.0.17134
Windows Community Toolkit Graph Uwp Authentication Provider
- CommunityToolkit.Authentication.Uwp
This library provides an authentication provider based on the native Windows dialogues. It is part of the Windows Community Toolkit.
@@ -11,28 +10,11 @@
- WindowsProvider:
UWP Toolkit Windows Microsoft Graph AadLogin Authentication Login
- false
- true
- 8.0
- Debug;Release;CI
- AnyCPU;ARM;ARM64;x64;x86
+ 9.0
-
- $(DefineConstants);WINRT
-
-
-
-
-
-
-
-
-
-
-
diff --git a/CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj b/CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj
index 5b061cc..2104762 100644
--- a/CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj
+++ b/CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj
@@ -3,7 +3,6 @@
uap10.0.17763
Windows Community Toolkit Graph Uwp Controls and Helpers
- CommunityToolkit.Graph.Uwp
This library provides Microsoft Graph UWP XAML controls. It is part of the Windows Community Toolkit.
@@ -14,51 +13,37 @@
- PeoplePicker: The PeoplePicker Control is a simple control that allows for selection of one or more users.
UWP Toolkit Windows Controls MSAL Microsoft Graph AadLogin ProfileCard Person PeoplePicker Login
- false
- true
9.0
- Debug;Release;CI
- AnyCPU;ARM;ARM64;x64;x86
-
-
-
+
+
+
+
-
+
+
+
+
+
+
-
-
-
-
-
-
-
- MSBuild:Compile
-
-
-
-
- $(DefineConstants);WINRT
-
-
-
diff --git a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.Properties.cs b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.Properties.cs
index addd2f8..82374bc 100644
--- a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.Properties.cs
+++ b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.Properties.cs
@@ -29,23 +29,5 @@ public User UserDetails
///
public static readonly DependencyProperty UserDetailsProperty =
DependencyProperty.Register(nameof(UserDetails), typeof(User), typeof(LoginButton), new PropertyMetadata(null));
-
- ///
- /// Gets or sets a value indicating whether the control is loading and has not established a sign-in state.
- ///
- public bool IsLoading
- {
- get { return (bool)GetValue(IsLoadingProperty); }
- protected set { SetValue(IsLoadingProperty, value); }
- }
-
- ///
- /// Identifies the dependency property.
- ///
- ///
- /// The identifier for the dependency property.
- ///
- public static readonly DependencyProperty IsLoadingProperty =
- DependencyProperty.Register(nameof(IsLoading), typeof(bool), typeof(LoginButton), new PropertyMetadata(true));
}
}
diff --git a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.cs b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.cs
index 05b01c8..b69b3d6 100644
--- a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.cs
+++ b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.cs
@@ -4,7 +4,6 @@
using System;
using System.ComponentModel;
-using System.Diagnostics;
using System.Threading.Tasks;
using CommunityToolkit.Authentication;
using CommunityToolkit.Graph.Extensions;
@@ -27,6 +26,21 @@ public partial class LoginButton : Control
private Button _loginButton;
private ButtonBase _signOutButton;
+ private bool _isLoading;
+
+ ///
+ /// Gets or sets a value indicating whether the control is loading and has not established a sign-in state.
+ ///
+ protected bool IsLoading
+ {
+ get => _isLoading;
+ set
+ {
+ _isLoading = value;
+ UpdateButtonEnablement();
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
@@ -37,14 +51,22 @@ public LoginButton()
ProviderManager.Instance.ProviderStateChanged += (sender, args) => LoadData();
}
+ ///
+ /// Update the enablement state of the button in relation to the _isLoading property.
+ ///
+ protected void UpdateButtonEnablement()
+ {
+ if (_loginButton != null)
+ {
+ _loginButton.IsEnabled = !_isLoading;
+ }
+ }
+
///
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
- IsLoading = true;
- LoadData();
-
if (_loginButton != null)
{
_loginButton.Click -= LoginButton_Click;
@@ -68,6 +90,8 @@ protected override void OnApplyTemplate()
{
_signOutButton.Click += SignOutButton_Click;
}
+
+ LoadData();
}
private async void LoginButton_Click(object sender, RoutedEventArgs e)
@@ -99,41 +123,37 @@ private async void SignOutButton_Click(object sender, RoutedEventArgs e)
private async void LoadData()
{
var provider = ProviderManager.Instance.GlobalProvider;
-
- if (provider == null)
+ switch (provider?.State)
{
- return;
- }
+ case ProviderState.Loading:
+ IsLoading = true;
+ break;
- if (provider.State == ProviderState.Loading)
- {
- IsLoading = true;
- }
- else if (provider.State == ProviderState.SignedIn)
- {
- try
- {
- // https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/master/src/components/mgt-login/mgt-login.ts#L139
- // TODO: Batch with photo request later? https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/issues/29
- UserDetails = await provider.GetClient().GetMeAsync();
- }
- catch (Exception e)
- {
- LoginFailed?.Invoke(this, new LoginFailedEventArgs(e));
- }
+ case ProviderState.SignedIn:
+ try
+ {
+ IsLoading = true;
- IsLoading = false;
- }
- else if (provider.State == ProviderState.SignedOut)
- {
- UserDetails = null; // What if this was user provided? Should we not hook into these events then?
+ // https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/master/src/components/mgt-login/mgt-login.ts#L139
+ // TODO: Batch with photo request later? https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/issues/29
+ UserDetails = await provider.GetClient().GetMeAsync();
+ }
+ catch (Exception e)
+ {
+ LoginFailed?.Invoke(this, new LoginFailedEventArgs(e));
+ }
+ finally
+ {
+ IsLoading = false;
+ }
- IsLoading = false;
- }
- else
- {
- // Provider in Loading state
- Debug.Fail("unsupported state");
+ break;
+
+ case ProviderState.SignedOut:
+ default:
+ UserDetails = null; // What if this was user provided? Should we not hook into these events then?
+ IsLoading = false;
+ break;
}
}
diff --git a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.xaml b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.xaml
index c15d51a..acbae71 100644
--- a/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.xaml
+++ b/CommunityToolkit.Graph.Uwp/Controls/LoginButton/LoginButton.xaml
@@ -22,8 +22,7 @@