Skip to content

Commit

Permalink
Merge pull request #3776 from bbirman/windowLevel
Browse files Browse the repository at this point in the history
Ensure window container level is set on underlying window
  • Loading branch information
bbirman authored Nov 25, 2024
2 parents 514a191 + 65fb98d commit 2adad58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ - (BOOL)isEnabled {
#endif
}

- (void)setWindowLevel:(UIWindowLevel)windowLevel {
_windowLevel = windowLevel;
_window.windowLevel = _windowLevel;
}

- (void)presentWindowAnimated:(BOOL)animated withCompletion:(void (^ _Nullable)(void))completion {
if ([self.windowDelegate respondsToSelector:@selector(presentWindow:animated:withCompletion:)]) {
[self.windowDelegate presentWindow:self animated:animated withCompletion:completion];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#import "SFSDKWindowManager.h"

static const CGFloat SFWindowLevelScreenLockOffset = 100;
static const CGFloat SFWindowLevelAuthOffset = 120;
static const CGFloat SFWindowLevelSnapshotOffset = 1000;

@interface SFSDKWindowManager ()

- (UIScene *)defaultScene;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "SFSDKWindowManager.h"
#import "SFSDKWindowManager+Internal.h"
#import "SFSDKWindowContainer.h"
#import "SFApplicationHelper.h"
#import "SFSDKMacDetectUtil.h"
Expand Down Expand Up @@ -70,9 +71,6 @@ - (void)disableWindow;

@implementation SFSDKWindowManager

static const CGFloat SFWindowLevelScreenLockOffset = 100;
static const CGFloat SFWindowLevelAuthOffset = 120;
static const CGFloat SFWindowLevelSnapshotOffset = 1000;
static NSString *const kSFMainWindowKey = @"main";
static NSString *const kSFLoginWindowKey = @"auth";
static NSString *const kSFSnaphotWindowKey = @"snapshot";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#import <XCTest/XCTest.h>
#import "SFSDKWindowManager.h"
#import "SFSDKWindowManager+Internal.h"
#import "SFApplicationHelper.h"

@interface SFSDKWindowManagerTests: XCTestCase{
Expand Down Expand Up @@ -110,6 +111,7 @@ - (void)testLoginWindow {
SFSDKWindowContainer *authWindowNilScene = [[SFSDKWindowManager sharedManager] authWindow:nil];
XCTAssert(authWindowNilScene.window != nil);
XCTAssert(authWindowNilScene.windowType == SFSDKWindowTypeAuth);
XCTAssertEqual(authWindowNilScene.window.windowLevel, SFWindowLevelAuthOffset);

UIScene *scene = [SFApplicationHelper sharedApplication].connectedScenes.allObjects.firstObject;
SFSDKWindowContainer *authWindowScene = [[SFSDKWindowManager sharedManager] authWindow:scene];
Expand All @@ -122,6 +124,7 @@ - (void)testScreenLockWindow {
SFSDKWindowContainer *screenLockWindow = [SFSDKWindowManager sharedManager].screenLockWindow;
XCTAssert(screenLockWindow.window!=nil);
XCTAssert(screenLockWindow.windowType == SFSDKWindowTypeScreenLock);
XCTAssertEqual(screenLockWindow.window.windowLevel, SFWindowLevelScreenLockOffset);
}

- (void)testSnapshotWindow {
Expand All @@ -134,6 +137,7 @@ - (void)testSnapshotWindow {
XCTAssert(snapshowWindowScene.window != nil);
XCTAssert(snapshowWindowScene.windowType == SFSDKWindowTypeSnapshot);
XCTAssertEqualObjects(snapshotWindowNilScene, snapshowWindowScene);
XCTAssertEqual(snapshowWindowScene.window.windowLevel, SFWindowLevelSnapshotOffset);
}

- (void)testEnable {
Expand Down

0 comments on commit 2adad58

Please sign in to comment.