Skip to content

Commit

Permalink
chore(ios): extendSafeArea support for iOS < 11 (#11396)
Browse files Browse the repository at this point in the history
Co-authored-by: Samir Mohammed <ssjsamir@users.noreply.github.com>
  • Loading branch information
vijaysingh-axway and ssjsamir committed Jan 3, 2020
1 parent f02a208 commit 8c95cb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ properties:
default: {android: false, ios: true}
since: {android: "7.5.0", iphone: "6.3.0", ipad: "6.3.0"}
availability: creation
osver: {android: {min: "4.4"}, ios: {min: "11.0"}}
osver: {android: {min: "4.4"}}

- name: fullscreen
summary: Boolean value indicating if the window is fullscreen.
Expand Down
11 changes: 4 additions & 7 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ - (BOOL)belongsToContext:(id<TiEvaluator>)context
- (void)add:(id)arg
{
TiUIWindowProxy *windowProxy = nil;
if ([self isKindOfClass:[TiUIWindowProxy class]] && [TiUtils isIOSVersionOrGreater:@"11.0"]) {
if ([self isKindOfClass:[TiUIWindowProxy class]]) {
windowProxy = (TiUIWindowProxy *)self;
if (arg == windowProxy.safeAreaViewProxy) {
// If adding the safeAreaViewProxy, it need to be add on window.
Expand Down Expand Up @@ -240,7 +240,7 @@ - (void)insertAt:(id)args

- (void)replaceAt:(id)args
{
if ([self isKindOfClass:[TiUIWindowProxy class]] && [TiUtils isIOSVersionOrGreater:@"11.0"]) {
if ([self isKindOfClass:[TiUIWindowProxy class]]) {
TiUIWindowProxy *windowProxy = (TiUIWindowProxy *)self;
if (windowProxy.safeAreaViewProxy) {
[windowProxy.safeAreaViewProxy replaceAt:args];
Expand All @@ -261,7 +261,7 @@ - (void)replaceAt:(id)args

- (void)remove:(id)arg
{
if ([self isKindOfClass:[TiUIWindowProxy class]] && [TiUtils isIOSVersionOrGreater:@"11.0"]) {
if ([self isKindOfClass:[TiUIWindowProxy class]]) {
TiUIWindowProxy *windowProxy = (TiUIWindowProxy *)self;
if (windowProxy.safeAreaViewProxy) {
[windowProxy.safeAreaViewProxy remove:arg];
Expand Down Expand Up @@ -330,7 +330,7 @@ - (void)remove:(id)arg

- (void)removeAllChildren:(id)arg
{
if ([self isKindOfClass:[TiUIWindowProxy class]] && [TiUtils isIOSVersionOrGreater:@"11.0"]) {
if ([self isKindOfClass:[TiUIWindowProxy class]]) {
TiUIWindowProxy *windowProxy = (TiUIWindowProxy *)self;
if (windowProxy.safeAreaViewProxy) {
[windowProxy.safeAreaViewProxy removeAllChildren:arg];
Expand Down Expand Up @@ -1455,9 +1455,6 @@ - (void)createSafeAreaViewProxyForWindowProperties:(NSDictionary *)properties
*/
TiUIWindowProxy *windowProxy = (TiUIWindowProxy *)self;
windowProxy.shouldExtendSafeArea = [TiUtils boolValue:[self valueForUndefinedKey:@"extendSafeArea"] def:YES];
if (![TiUtils isIOSVersionOrGreater:@"11.0"]) {
return;
}

if (!windowProxy.safeAreaViewProxy && !windowProxy.shouldExtendSafeArea) {
NSMutableDictionary *safeAreaProperties = [NSMutableDictionary dictionary];
Expand Down
20 changes: 7 additions & 13 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -1079,22 +1079,16 @@ - (void)processForSafeArea
@"right" : NUMFLOAT(0.0) }
forKey:@"safeAreaPadding"];

if (![TiUtils isIOSVersionOrGreater:@"11.0"]) {
if (self.shouldExtendSafeArea && !hidesStatusBar) {
[self setValue:@{ @"top" : NUMFLOAT(20.0),
@"left" : NUMFLOAT(0.0),
@"bottom" : NUMFLOAT(0.0),
@"right" : NUMFLOAT(0.0) }
forKey:@"safeAreaPadding"];
}
UIEdgeInsets edgeInsets = UIEdgeInsetsZero;
UIEdgeInsets safeAreaInset = UIEdgeInsetsZero;

return;
if ([TiUtils isIOSVersionOrGreater:@"11.0"]) {
UIViewController<TiControllerContainment> *topContainerController = [[[TiApp app] controller] topContainerController];
safeAreaInset = [[topContainerController hostingView] safeAreaInsets];
} else if (!hidesStatusBar) {
safeAreaInset.top = 20.0;
}

UIEdgeInsets edgeInsets = UIEdgeInsetsZero;
UIViewController<TiControllerContainment> *topContainerController = [[[TiApp app] controller] topContainerController];
UIEdgeInsets safeAreaInset = [[topContainerController hostingView] safeAreaInsets];

if (self.tabGroup) {
edgeInsets = [self tabGroupEdgeInsetsForSafeAreaInset:safeAreaInset];
} else if (self.tab) {
Expand Down

0 comments on commit 8c95cb7

Please sign in to comment.