feat: add iosExpandSafeArea property

Also apply insets on page's children.
This commit is contained in:
Vasil Chimev
2018-08-22 14:37:51 +03:00
committed by Martin Yankov
parent ec98fd6f5f
commit 429ac8712f
4 changed files with 22 additions and 6 deletions

View File

@@ -817,7 +817,7 @@ export class View extends ViewCommon {
}
export class ContainerView extends View {
//
public iosExpandSafeArea: boolean;
}
export class CustomLayoutView extends ContainerView implements CustomLayoutViewDefinition {

View File

@@ -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;
}
/**

View File

@@ -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;