Skip to content

Commit 655dfb8

Browse files
authored
Merge pull request #1628 from AzureAD/sedemche/fix_loading_indicator
Use autolayout for loading indicator
2 parents eba56bb + 7e9b0b6 commit 655dfb8

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

IdentityCore/src/MSIDConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ extern NSString * _Nonnull const MSID_FLIGHT_DISABLE_REMOVE_ACCOUNT_ARTIFACTS;
235235
extern NSString * _Nonnull const MSID_FLIGHT_ENABLE_QUERYING_STK;
236236
extern NSString * _Nonnull const MSID_FLIGHT_IS_BART_SUPPORTED;
237237

238+
extern NSString * _Nonnull const MSID_FLIGHT_USE_AUTOLAYOUT_FOR_LOADING_INDICATOR;
239+
238240
extern NSString * _Nonnull const MSID_DOMAIN_HINT_KEY;
239241

240242
extern NSString * _Nonnull const MSID_FLIGHT_ENABLE_THREAD_STARVATION;

IdentityCore/src/MSIDConstants.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
NSString *const MSID_FLIGHT_ENABLE_QUERYING_STK = @"enable_querying_stk";
101101
NSString *const MSID_FLIGHT_IS_BART_SUPPORTED = @"is_msal_bart_supported";
102102

103+
NSString *const MSID_FLIGHT_USE_AUTOLAYOUT_FOR_LOADING_INDICATOR = @"use_autolayout_for_loading_indicator";
104+
103105
NSString *const MSID_DOMAIN_HINT_KEY = @"domain_hint";
104106

105107
// This is SsoExt flow only flight

IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222
// THE SOFTWARE.
2323

2424
#import "MSIDWebviewUIController.h"
25+
#import "MSIDFlightManager.h"
26+
#import "MSIDConstants.h"
2527

2628
#if !MSID_EXCLUDE_WEBKIT
2729

2830
#define DEFAULT_WINDOW_WIDTH 420
2931
#define DEFAULT_WINDOW_HEIGHT 650
3032

33+
NSInteger const MSID_LOADING_INDICATOR_SIZE = 32;
34+
3135
static WKWebViewConfiguration *s_webConfig;
3236

3337
@interface MSIDWebviewUIController ( ) <NSWindowDelegate>
@@ -94,6 +98,18 @@ - (BOOL)loadView:(__unused NSError *__autoreleasing*)error
9498
{
9599
_loadingIndicator = [self prepareLoadingIndicator];
96100
[_webView addSubview:_loadingIndicator];
101+
102+
BOOL useAutolayout = [MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_USE_AUTOLAYOUT_FOR_LOADING_INDICATOR];
103+
if (useAutolayout)
104+
{
105+
_loadingIndicator.translatesAutoresizingMaskIntoConstraints = NO;
106+
[NSLayoutConstraint activateConstraints:@[
107+
[_loadingIndicator.centerXAnchor constraintEqualToAnchor:_webView.centerXAnchor],
108+
[_loadingIndicator.centerYAnchor constraintEqualToAnchor:_webView.centerYAnchor],
109+
[_loadingIndicator.widthAnchor constraintEqualToConstant:MSID_LOADING_INDICATOR_SIZE],
110+
[_loadingIndicator.heightAnchor constraintEqualToConstant:MSID_LOADING_INDICATOR_SIZE]
111+
]];
112+
}
97113
return YES;
98114
}
99115

@@ -223,8 +239,8 @@ - (NSProgressIndicator *)prepareLoadingIndicator
223239
windowWidth = window.size.width;
224240
windowHeight = window.size.height;
225241
}
226-
227-
NSProgressIndicator *loadingIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(windowWidth / 2 - 16, windowHeight / 2 - 16, 32, 32)];
242+
243+
NSProgressIndicator *loadingIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(windowWidth / 2 - MSID_LOADING_INDICATOR_SIZE / 2, windowHeight / 2 - MSID_LOADING_INDICATOR_SIZE / 2, MSID_LOADING_INDICATOR_SIZE, MSID_LOADING_INDICATOR_SIZE)];
228244
[loadingIndicator setStyle:NSProgressIndicatorStyleSpinning];
229245
// Keep the item centered in the window even if it's resized.
230246
[loadingIndicator setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin];

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Version TBD
22
* Silent token request should use FRT first when single FRT is enabled (#1624)
3+
* Use autolayout for loading indicator #1628
34

45
Version 1.17.0
56
* Add flag to indicate app is requesting broker for Bound app RT #1578

0 commit comments

Comments
 (0)