-
Notifications
You must be signed in to change notification settings - Fork 493
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
Consider Safe Area Insets for Some Screens #3084
Changes from all commits
113a568
5d9737f
f3c4df8
8f7b7fe
5615463
578e240
f753d97
3ea5a00
ac3f3b2
0e2648a
1376c6b
9a2bdef
a2e3535
475deda
9270813
c7fe30d
4b409e2
3834381
ec9148f
7d5b7f1
cf29ff4
3f6dd1a
e39e22b
42590b3
90ebc08
a50358f
d632ee8
2259f02
75eb8b0
8c6a179
1cb9829
c5d8034
96d1403
7dda136
58de3a7
c642c41
9e01e22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4081,6 +4081,11 @@ - (void)presentJitsiViewController:(void (^)(void))completion | |
|
||
if (_jitsiViewController) | ||
{ | ||
if (@available(iOS 13.0, *)) | ||
{ | ||
_jitsiViewController.modalPresentationStyle = UIModalPresentationFullScreen; | ||
} | ||
|
||
[self presentViewController:_jitsiViewController animated:YES completion:completion]; | ||
} | ||
} | ||
|
@@ -4232,11 +4237,26 @@ - (void)askNativeWidgetPermissionWithWidget:(Widget*)widget completion:(void (^) | |
|
||
#pragma mark - Call status handling | ||
|
||
/// Returns a suitable height for call status bar. Considers safe area insets if available and notch status. | ||
- (CGFloat)calculateCallStatusBarHeight | ||
{ | ||
CGFloat result = CALL_STATUS_BAR_HEIGHT; | ||
if (@available(iOS 11.0, *)) | ||
{ | ||
if (UIDevice.currentDevice.hasNotch) | ||
{ | ||
// this device has a notch (iPhone X +) | ||
result += UIApplication.sharedApplication.keyWindow.safeAreaInsets.top; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
- (void)addCallStatusBar:(NSString*)buttonTitle | ||
{ | ||
// Add a call status bar | ||
CGSize topBarSize = CGSizeMake([[UIScreen mainScreen] bounds].size.width, CALL_STATUS_BAR_HEIGHT); | ||
CGSize topBarSize = CGSizeMake([[UIScreen mainScreen] bounds].size.width, [self calculateCallStatusBarHeight]); | ||
|
||
_callStatusBarWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, topBarSize.width, topBarSize.height)]; | ||
_callStatusBarWindow.windowLevel = UIWindowLevelStatusBar; | ||
|
||
|
@@ -4246,8 +4266,9 @@ - (void)addCallStatusBar:(NSString*)buttonTitle | |
|
||
[_callStatusBarButton setTitle:buttonTitle forState:UIControlStateNormal]; | ||
[_callStatusBarButton setTitle:buttonTitle forState:UIControlStateHighlighted]; | ||
|
||
_callStatusBarButton.titleLabel.textColor = ThemeService.shared.theme.backgroundColor; | ||
|
||
_callStatusBarButton.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium]; | ||
|
||
[_callStatusBarButton setBackgroundColor:ThemeService.shared.theme.tintColor]; | ||
|
@@ -4322,6 +4343,11 @@ - (void)presentCallViewController:(BOOL)animated completion:(void (^)(void))comp | |
|
||
if (currentCallViewController) | ||
{ | ||
if (@available(iOS 13.0, *)) | ||
{ | ||
currentCallViewController.modalPresentationStyle = UIModalPresentationFullScreen; | ||
} | ||
|
||
[self presentViewController:currentCallViewController animated:animated completion:completion]; | ||
} | ||
} | ||
|
@@ -4333,36 +4359,52 @@ - (void)statusBarDidChangeFrame | |
|
||
// Refresh the root view controller frame | ||
CGRect rootControllerFrame = [[UIScreen mainScreen] bounds]; | ||
|
||
if (_callStatusBarWindow) | ||
{ | ||
CGFloat callStatusBarHeight = [self calculateCallStatusBarHeight]; | ||
|
||
UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation; | ||
|
||
switch (statusBarOrientation) | ||
{ | ||
case UIInterfaceOrientationLandscapeLeft: | ||
{ | ||
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT); | ||
_callStatusBarWindow.transform = CGAffineTransformMake(0, -1, 1, 0, CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width / 2); | ||
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -callStatusBarHeight / 2, rootControllerFrame.size.width, callStatusBarHeight); | ||
_callStatusBarWindow.transform = CGAffineTransformMake(0, -1, 1, 0, callStatusBarHeight / 2, rootControllerFrame.size.width / 2); | ||
break; | ||
} | ||
case UIInterfaceOrientationLandscapeRight: | ||
{ | ||
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT); | ||
_callStatusBarWindow.transform = CGAffineTransformMake(0, 1, -1, 0, rootControllerFrame.size.height - CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width / 2); | ||
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -callStatusBarHeight / 2, rootControllerFrame.size.width, callStatusBarHeight); | ||
_callStatusBarWindow.transform = CGAffineTransformMake(0, 1, -1, 0, rootControllerFrame.size.height - callStatusBarHeight / 2, rootControllerFrame.size.width / 2); | ||
break; | ||
} | ||
default: | ||
{ | ||
_callStatusBarWindow.transform = CGAffineTransformIdentity; | ||
_callStatusBarWindow.frame = CGRectMake(0, 0, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT); | ||
_callStatusBarWindow.frame = CGRectMake(0, 0, rootControllerFrame.size.width, callStatusBarHeight); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done with some changes. |
||
break; | ||
} | ||
} | ||
|
||
UIEdgeInsets callBarButtonContentEdgeInsets = UIEdgeInsetsZero; | ||
|
||
if (@available(iOS 11.0, *)) | ||
{ | ||
callBarButtonContentEdgeInsets = UIApplication.sharedApplication.keyWindow.safeAreaInsets; | ||
// should override top inset | ||
callBarButtonContentEdgeInsets.top = callStatusBarHeight - CALL_STATUS_BAR_HEIGHT; | ||
// should ignore bottom inset | ||
callBarButtonContentEdgeInsets.bottom = 0.0; | ||
// should keep left, and right insets as original | ||
} | ||
|
||
_callStatusBarButton.contentEdgeInsets = callBarButtonContentEdgeInsets; | ||
|
||
// Apply the vertical offset due to call status bar | ||
rootControllerFrame.origin.y = CALL_STATUS_BAR_HEIGHT; | ||
rootControllerFrame.size.height -= CALL_STATUS_BAR_HEIGHT; | ||
rootControllerFrame.origin.y = callStatusBarHeight; | ||
rootControllerFrame.size.height -= callStatusBarHeight; | ||
} | ||
|
||
rootController.view.frame = rootControllerFrame; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using hasNotch we could use this: