-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-25301]:iPhone X: Need to be able to control the Insets / Layout Margins #9475
Changes from 1 commit
312ee2a
0080d45
5a12013
b34604c
3b5c1a5
7f48efa
25709d8
00c0262
378c5c1
5d17368
8aa4c49
73159dc
adeaeaa
e14f1a2
967bdaf
7789988
1d9f24e
ecf5b94
e087ac7
34f9b7c
7651eca
cbc8623
179f75e
d6113d4
c5b9022
de5871c
7db933d
74eed9b
6cd1e94
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 |
---|---|---|
|
@@ -246,6 +246,9 @@ - (BOOL)_handleClose:(id)args | |
|
||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator | ||
{ | ||
[self performSelector:@selector(processForSafeArea) | ||
withObject:nil | ||
afterDelay:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]]; | ||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; | ||
[self willChangeSize]; | ||
} | ||
|
@@ -937,6 +940,49 @@ - (void)cleanupWindowDecorations | |
[barImageView removeFromSuperview]; | ||
} | ||
} | ||
|
||
- (void)processForSafeArea | ||
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. Should be compiled out by |
||
{ | ||
if (self.shouldExtendSafeArea) { | ||
return; | ||
} | ||
#if IS_XCODE_9 | ||
float left = 0.0; | ||
float right = 0.0; | ||
float top = 0.0; | ||
float bottom = 0.0; | ||
if ([TiUtils isIOS11OrGreater]) { | ||
UIViewController<TiControllerContainment> *topContainerController = [[[TiApp app] controller] topContainerController]; | ||
UIView *rootView = [topContainerController hostingView]; | ||
if (self.tabGroup) { | ||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; | ||
if (!UIInterfaceOrientationIsPortrait(orientation)) { | ||
left = rootView.safeAreaInsets.left; | ||
right = rootView.safeAreaInsets.right; | ||
} | ||
} else if (self.tab) { | ||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; | ||
if (!UIInterfaceOrientationIsPortrait(orientation)) { | ||
left = rootView.safeAreaInsets.left; | ||
right = rootView.safeAreaInsets.right; | ||
bottom = rootView.safeAreaInsets.bottom; | ||
} else { | ||
bottom = rootView.safeAreaInsets.bottom; | ||
} | ||
} else { | ||
left = rootView.safeAreaInsets.left; | ||
right = rootView.safeAreaInsets.right; | ||
bottom = rootView.safeAreaInsets.bottom; | ||
top = rootView.safeAreaInsets.top; | ||
} | ||
[self.safeAreaViewProxy setTop:[NSNumber numberWithFloat:top]]; | ||
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.
|
||
[self.safeAreaViewProxy setBottom:[NSNumber numberWithFloat:bottom]]; | ||
[self.safeAreaViewProxy setLeft:[NSNumber numberWithFloat:left]]; | ||
[self.safeAreaViewProxy setRight:[NSNumber numberWithFloat:right]]; | ||
} | ||
#endif | ||
} | ||
|
||
@end | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
#import <QuartzCore/QuartzCore.h> | ||
#import <libkern/OSAtomic.h> | ||
#import <pthread.h> | ||
#import "TiUIWindowProxy.h" | ||
#import "TiUIViewProxy.h" | ||
|
||
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. Compile out for Xcode < 9 |
||
#define IGNORE_IF_NOT_OPENED \ | ||
if (!windowOpened || [self viewAttached] == NO) \ | ||
|
@@ -167,10 +169,25 @@ - (BOOL)belongsToContext:(id<TiEvaluator>)context | |
|
||
- (void)add:(id)arg | ||
{ | ||
TiUIWindowProxy *windowProxy = nil; | ||
if ([self isKindOfClass:[TiUIWindowProxy class]]) { | ||
//Added a transparent safeAreaViewProxy above window for safe area layouts if shouldExtendSafeArea is false. All views added on window will be added on safeAreaViewProxy. Layouts of safeAreaViewProxy is getting modified wherever required. | ||
windowProxy = (TiUIWindowProxy *)self; | ||
windowProxy.shouldExtendSafeArea = [TiUtils boolValue:[self valueForUndefinedKey:@"extendSafeArea"] | ||
def:NO]; | ||
if (!windowProxy.safeAreaViewProxy && !windowProxy.shouldExtendSafeArea) { | ||
windowProxy.safeAreaViewProxy = [[TiUIViewProxy alloc] _initWithPageContext:[self pageContext] args:nil]; | ||
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. May need to be |
||
[self add:windowProxy.safeAreaViewProxy]; | ||
} | ||
} | ||
// allow either an array of arrays or an array of single proxy | ||
if ([arg isKindOfClass:[NSArray class]]) { | ||
for (id a in arg) { | ||
[self add:a]; | ||
if (windowProxy.safeAreaViewProxy) { | ||
[windowProxy.safeAreaViewProxy add:a]; | ||
} else { | ||
[self add:a]; | ||
} | ||
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. Compile out for Xcode < 9, change the access of |
||
} | ||
return; | ||
} | ||
|
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.
Add one tmpty line for readability. Also ensure to format everything with our clang-format