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

Ensure window container level is set on underlying window #3776

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading