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

[TIMOB-25301]:iPhone X: Need to be able to control the Insets / Layout Margins #9475

Merged
merged 29 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
312ee2a
[TIMOB-25301]:iPhone X: Need to be able to control the Insets / Layou…
vijaysingh-axway Sep 23, 2017
0080d45
[TIMOB-25301]:iPhone X Need to be able to control the Insets / Layout…
vijaysingh-axway Sep 25, 2017
5a12013
Update Window.yml
hansemannn Sep 25, 2017
b34604c
[TIMOB-25301]:Indentation fix
vijaysingh-axway Sep 25, 2017
3b5c1a5
Merge branch 'TIMOB-25301' of https://github.com/vijaysingh-axway/tit…
vijaysingh-axway Sep 25, 2017
7f48efa
[TIMOB-25301] : iPhone X Need to be able to control the Insets / Layo…
vijaysingh-axway Sep 29, 2017
25709d8
[TIMOB-25301] : iPhone X Need to be able to control the Insets / Layo…
vijaysingh-axway Sep 29, 2017
00c0262
[TIMOB-25301] : Update layout only when it needed.
vijaysingh-axway Oct 2, 2017
378c5c1
[TIMOB-25301]: iPhone X Need to be able to control the Insets / Layou…
vijaysingh-axway Oct 4, 2017
5d17368
[TIMOB-25301]: window property passed to safeAreaView
vijaysingh-axway Oct 5, 2017
8aa4c49
[TIMOB-25301]: Safe area layout calculated early
vijaysingh-axway Oct 6, 2017
73159dc
[TIMOB-25301]:Indentation fixed
vijaysingh-axway Oct 6, 2017
adeaeaa
Merge branch 'master' into TIMOB-25301
vijaysingh-axway Oct 6, 2017
e14f1a2
[TIMOB-25301] : early calculation of safe area for tab group’s window
vijaysingh-axway Oct 10, 2017
967bdaf
[TIMOB-25301]: Added safeAreaViewProxy after creating it
vijaysingh-axway Oct 11, 2017
7789988
[TIMOB-25301] : Support for split window
vijaysingh-axway Oct 11, 2017
1d9f24e
Merge branch 'master' into TIMOB-25301
hansemannn Oct 11, 2017
ecf5b94
Rephrase safe-area docs
hansemannn Oct 12, 2017
e087ac7
Update Window.yml
hansemannn Oct 12, 2017
34f9b7c
Merge branch 'master' into TIMOB-25301
ewieberappc Oct 31, 2017
7651eca
Merge branch 'master' into TIMOB-25301
mukherjee2 Nov 3, 2017
cbc8623
Merge branch 'master' into TIMOB-25301
ewieberappc Nov 6, 2017
179f75e
Merge branch 'master' into TIMOB-25301
vijaysingh-axway Nov 8, 2017
d6113d4
Merge branch 'master' into TIMOB-25301
vijaysingh-axway Nov 9, 2017
c5b9022
[TIMOB-25301] : Window.yml doc updated
vijaysingh-axway Nov 9, 2017
de5871c
Merge branch 'master' into TIMOB-25301
mukherjee2 Nov 10, 2017
7db933d
Update Window.yml
hansemannn Nov 10, 2017
74eed9b
Merge branch 'master' into TIMOB-25301
hansemannn Nov 10, 2017
6cd1e94
Merge branch 'master' into TIMOB-25301
mukherjee2 Nov 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIWindowProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- (void)refreshBackButton;
- (void)updateNavBar;
- (void)boot:(BOOL)timeout args:(id)args;
@property (nonatomic, assign) TiViewProxy *safeAreaViewProxy;
Copy link
Collaborator

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

@property (nonatomic) BOOL shouldExtendSafeArea;

@end

Expand Down
46 changes: 46 additions & 0 deletions iphone/Classes/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -937,6 +940,49 @@ - (void)cleanupWindowDecorations
[barImageView removeFromSuperview];
}
}

- (void)processForSafeArea
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be compiled out by #if IS_XCODE_9 to decrease the code-size for Xcode < 9.

{
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]];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use NUMFLOAT for all 4 sizes
  • Access safeAreaViewProxy via [self safeAreaViewProxy]

[self.safeAreaViewProxy setBottom:[NSNumber numberWithFloat:bottom]];
[self.safeAreaViewProxy setLeft:[NSNumber numberWithFloat:left]];
[self.safeAreaViewProxy setRight:[NSNumber numberWithFloat:right]];
}
#endif
}

@end

#endif
19 changes: 18 additions & 1 deletion iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#import <QuartzCore/QuartzCore.h>
#import <libkern/OSAtomic.h>
#import <pthread.h>
#import "TiUIWindowProxy.h"
#import "TiUIViewProxy.h"

Copy link
Collaborator

Choose a reason for hiding this comment

The 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) \
Expand Down Expand Up @@ -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];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to be [[TiUIViewProxy alloc] _initWithPageContext:[self pageContext]] autorelease]

[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];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compile out for Xcode < 9, change the access of safeAreaViewProxy as well.

}
return;
}
Expand Down
7 changes: 7 additions & 0 deletions iphone/Classes/TiWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "TiApp.h"
#import "TiErrorController.h"
#import "TiUIWindow.h"
#import "TiUIWindowProxy.h"

@interface TiWindowProxy (Private)
- (void)openOnUIThread:(id)args;
Expand Down Expand Up @@ -425,6 +426,7 @@ - (void)gainFocus
}
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
[[self view] setAccessibilityElementsHidden:NO];
[self processForSafeArea];
}
TiThreadPerformOnMainThread(^{
[self forceNavBarFrame];
Expand Down Expand Up @@ -856,4 +858,9 @@ - (void)setTransitionAnimation:(id)args
}
#endif

- (void)processForSafeArea
{
// Overridden in subclass
}

@end