|
22 | 22 | // THE SOFTWARE. |
23 | 23 |
|
24 | 24 | #import "MSIDWebviewUIController.h" |
| 25 | +#import "MSIDFlightManager.h" |
| 26 | +#import "MSIDConstants.h" |
25 | 27 |
|
26 | 28 | #if !MSID_EXCLUDE_WEBKIT |
27 | 29 |
|
28 | 30 | #define DEFAULT_WINDOW_WIDTH 420 |
29 | 31 | #define DEFAULT_WINDOW_HEIGHT 650 |
30 | 32 |
|
| 33 | +NSInteger const MSID_LOADING_INDICATOR_SIZE = 32; |
| 34 | + |
31 | 35 | static WKWebViewConfiguration *s_webConfig; |
32 | 36 |
|
33 | 37 | @interface MSIDWebviewUIController ( ) <NSWindowDelegate> |
@@ -94,6 +98,18 @@ - (BOOL)loadView:(__unused NSError *__autoreleasing*)error |
94 | 98 | { |
95 | 99 | _loadingIndicator = [self prepareLoadingIndicator]; |
96 | 100 | [_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 | + } |
97 | 113 | return YES; |
98 | 114 | } |
99 | 115 |
|
@@ -223,8 +239,8 @@ - (NSProgressIndicator *)prepareLoadingIndicator |
223 | 239 | windowWidth = window.size.width; |
224 | 240 | windowHeight = window.size.height; |
225 | 241 | } |
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)]; |
228 | 244 | [loadingIndicator setStyle:NSProgressIndicatorStyleSpinning]; |
229 | 245 | // Keep the item centered in the window even if it's resized. |
230 | 246 | [loadingIndicator setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin]; |
|
0 commit comments