FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix-next: ios 10 safe area backwards compat (#6364) · NativeScript/NativeScript@04233b6 · GitHub

Commit 04233b6

Browse files
authored
fix-next: ios 10 safe area backwards compat (#6364)
* fix-next: ios 10 safe area backwards compat * refactor: update a comment * fix-next: ios 10 page on layout fix * fix-next: handle ios 11 flat action bar
1 parent e3d5f0d commit 04233b6

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎tns-core-modules/ui/core/view/view.ios.ts‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -698,16 +698,18 @@ export namespace ios {
698698
}
699699

700700
export function layoutView(controller: UIViewController, owner: View): void {
701-
// apply parent page additional top insets if any. The scenario is when there is a parent page with action bar.
702-
const parentPage = getAncestor(owner, "Page");
703-
if (parentPage) {
704-
const parentPageInsetsTop = parentPage.viewController.view.safeAreaInsets.top;
705-
const currentInsetsTop = controller.view.safeAreaInsets.top;
706-
const additionalInsetsTop = parentPageInsetsTop - currentInsetsTop;
707-
708-
if (additionalInsetsTop > 0) {
709-
const additionalInsets = new UIEdgeInsets({ top: additionalInsetsTop, left: 0, bottom: 0, right: 0 });
710-
controller.additionalSafeAreaInsets = additionalInsets;
701+
if (majorVersion >= 11) {
702+
// apply parent page additional top insets if any. The scenario is when there is a parent page with action bar.
703+
const parentPage = getAncestor(owner, "Page");
704+
if (parentPage) {
705+
const parentPageInsetsTop = parentPage.viewController.view.safeAreaInsets.top;
706+
const currentInsetsTop = controller.view.safeAreaInsets.top;
707+
const additionalInsetsTop = parentPageInsetsTop - currentInsetsTop;
708+
709+
if (additionalInsetsTop > 0) {
710+
const additionalInsets = new UIEdgeInsets({ top: additionalInsetsTop, left: 0, bottom: 0, right: 0 });
711+
controller.additionalSafeAreaInsets = additionalInsets;
712+
}
711713
}
712714
}
713715

‎tns-core-modules/ui/page/page.ios.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import {
99
} from "./page-common";
1010

1111
import { profile } from "../../profiling";
12+
import { ios as iosUtils } from "../../utils/utils";
1213

1314
export * from "./page-common";
1415

1516
const ENTRY = "_entry";
1617
const DELEGATE = "_delegate";
1718

19+
const majorVersion = iosUtils.MajorVersion;
20+
1821
function isBackNavigationTo(page: Page, entry): boolean {
1922
const frame = page.frame;
2023
if (!frame) {
@@ -315,10 +318,23 @@ export class Page extends PageBase {
315318

316319
const insets = this.getSafeAreaInsets();
317320

321+
if (majorVersion <= 10) {
322+
// iOS 10 and below don't have safe area insets API,
323+
// there we need only the top inset on the Page
324+
insets.top = layout.round(layout.toDevicePixels(this.viewController.view.safeAreaLayoutGuide.layoutFrame.origin.y));
325+
}
326+
318327
const childLeft = 0 + insets.left;
319328
const childTop = 0 + insets.top;
320-
const childRight = right - left - insets.right;
321-
const childBottom = bottom - top - insets.bottom;
329+
const childRight = right - insets.right;
330+
let childBottom = bottom - insets.bottom;
331+
332+
if (majorVersion >= 11 && this.actionBar.flat) {
333+
// on iOS 11 the flat action bar changes the fullscreen size
334+
// the top of the page is the new fullscreen
335+
childBottom -= top;
336+
}
337+
322338
View.layoutChild(this, this.layoutView, childLeft, childTop, childRight, childBottom);
323339
}
324340

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL