mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: add iosExpandSafeArea property
Also apply insets on page's children.
This commit is contained in:
committed by
Martin Yankov
parent
ec98fd6f5f
commit
429ac8712f
@@ -817,7 +817,7 @@ export class View extends ViewCommon {
|
||||
}
|
||||
|
||||
export class ContainerView extends View {
|
||||
//
|
||||
public iosExpandSafeArea: boolean;
|
||||
}
|
||||
|
||||
export class CustomLayoutView extends ContainerView implements CustomLayoutViewDefinition {
|
||||
|
||||
5
tns-core-modules/ui/core/view/view.d.ts
vendored
5
tns-core-modules/ui/core/view/view.d.ts
vendored
@@ -728,7 +728,10 @@ export abstract class View extends ViewBase {
|
||||
* Base class for all UI components that are containers.
|
||||
*/
|
||||
export class ContainerView extends View {
|
||||
|
||||
/**
|
||||
* Instruct container view to expand the safe area. This property is iOS specific. Default value: true
|
||||
*/
|
||||
public iosExpandSafeArea: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Definitions.
|
||||
import { Point, View as ViewDefinition, dip } from ".";
|
||||
import { ViewBase } from "../view-base";
|
||||
import { booleanConverter, Property } from "../view";
|
||||
|
||||
import {
|
||||
ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty,
|
||||
@@ -607,8 +608,11 @@ export class View extends ViewCommon {
|
||||
View.prototype._nativeBackgroundState = "unset";
|
||||
|
||||
export class ContainerView extends View {
|
||||
|
||||
public iosExpandSafeArea: boolean;
|
||||
|
||||
protected applySafeAreaInsets(frame: CGRect): CGRect {
|
||||
if (majorVersion > 10) {
|
||||
if (this.iosExpandSafeArea && majorVersion > 10) {
|
||||
const locationOnScreen = this.getLocationOnScreen();
|
||||
|
||||
if (locationOnScreen) {
|
||||
@@ -648,6 +652,9 @@ export class ContainerView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
export const iosExpandSafeAreaProperty = new Property<ContainerView, boolean>({ name: "iosExpandSafeArea", defaultValue: true, valueConverter: booleanConverter });
|
||||
iosExpandSafeAreaProperty.register(ContainerView);
|
||||
|
||||
export class CustomLayoutView extends ContainerView {
|
||||
|
||||
nativeViewProtected: UIView;
|
||||
|
||||
@@ -120,7 +120,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
// Skip navigation events if modal page is shown.
|
||||
if (!owner._presentedViewController && frame) {
|
||||
const newEntry = this[ENTRY];
|
||||
|
||||
|
||||
let isBack: boolean;
|
||||
// We are on the current page which happens when navigation is canceled so isBack should be false.
|
||||
if (frame.currentPage === owner && frame._navigationQueue.length === 0) {
|
||||
@@ -309,7 +309,13 @@ export class Page extends PageBase {
|
||||
public onLayout(left: number, top: number, right: number, bottom: number) {
|
||||
const { width: actionBarWidth, height: actionBarHeight } = this.actionBar._getActualSize;
|
||||
View.layoutChild(this, this.actionBar, 0, 0, actionBarWidth, actionBarHeight);
|
||||
View.layoutChild(this, this.layoutView, left, top, right, bottom);
|
||||
|
||||
const insets = this.getSafeAreaInsets();
|
||||
const childLeft = left + insets.left;
|
||||
const childTop = top + insets.top;
|
||||
const childRight = right - insets.right;
|
||||
const childBottom = bottom - insets.bottom;
|
||||
View.layoutChild(this, this.layoutView, childLeft, childTop, childRight, childBottom);
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
|
||||
@@ -327,7 +333,7 @@ export class Page extends PageBase {
|
||||
if (this.viewController.presentedViewController === viewController) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
this.viewController.addChildViewController(viewController);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user