mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
add right and bottom to insets
This commit is contained in:
@@ -641,7 +641,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
}
|
||||
|
||||
public abstract onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
||||
public abstract onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void;
|
||||
public abstract onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void;
|
||||
public abstract layoutNativeView(left: number, top: number, right: number, bottom: number): void;
|
||||
|
||||
public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number {
|
||||
|
||||
2
tns-core-modules/ui/core/view/view.d.ts
vendored
2
tns-core-modules/ui/core/view/view.d.ts
vendored
@@ -404,7 +404,7 @@ export abstract class View extends ViewBase {
|
||||
* @param right Right position, relative to parent
|
||||
* @param bottom Bottom position, relative to parent
|
||||
*/
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void;
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void;
|
||||
|
||||
/**
|
||||
* This method must be called by onMeasure(int, int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.
|
||||
|
||||
@@ -92,16 +92,16 @@ export class View extends ViewCommon {
|
||||
}
|
||||
|
||||
if (boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED) {
|
||||
let insetLeft = 0;
|
||||
let insetTop = 0;
|
||||
let insets = { left: 0, top: 0, right: 0, bottom: 0};
|
||||
|
||||
if (this.nativeViewProtected.safeAreaInsets) {
|
||||
insetLeft = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.left);
|
||||
insetTop = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.top);
|
||||
insets.left = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.left);
|
||||
insets.top = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.top);
|
||||
insets.right = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.right);
|
||||
insets.bottom = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.bottom);
|
||||
}
|
||||
|
||||
// this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insetLeft, insetTop, insetRight, insetBottom);
|
||||
this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insetLeft, insetTop);
|
||||
this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insets);
|
||||
this._privateFlags &= ~PFLAG_LAYOUT_REQUIRED;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ export class View extends ViewCommon {
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number, insetRight?: number, insetBottom?: number): void {
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -156,11 +156,11 @@ export class GridLayout extends GridLayoutBase {
|
||||
this.setMeasuredDimension(widthSizeAndState, heightSizeAndState);
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void {
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void {
|
||||
super.onLayout(left, top, right, bottom);
|
||||
|
||||
let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insetLeft;
|
||||
let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insetTop;
|
||||
let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left;
|
||||
let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top;
|
||||
|
||||
this.columnOffsets.length = 0;
|
||||
this.rowOffsets.length = 0;
|
||||
|
||||
@@ -75,11 +75,12 @@ export class LayoutBase extends LayoutBaseCommon {
|
||||
newHeight = height + onScreenTop;
|
||||
}
|
||||
|
||||
if (onScreenLeft + width >= layout.toDevicePixels(safeArea.origin.x) + layout.toDevicePixels(safeArea.size.width)) {
|
||||
if (width && onScreenLeft + width >= layout.toDevicePixels(safeArea.origin.x) + layout.toDevicePixels(safeArea.size.width)) {
|
||||
newWidth = newWidth + (layout.toDevicePixels(fullscreen.size.width) - (onScreenLeft + width));
|
||||
}
|
||||
|
||||
if (onScreenTop + height >= layout.toDevicePixels(safeArea.origin.y) + layout.toDevicePixels(safeArea.size.height)) {
|
||||
if (height && onScreenTop + height >= layout.toDevicePixels(safeArea.origin.y) + layout.toDevicePixels(safeArea.size.height)) {
|
||||
// console.log(">>>>>>>> Bottom Layout: onScreenTop - " + onScreenTop + " height - " + height + " safeAreaOriginY - " + layout.toDevicePixels(safeArea.origin.y) + " safeAreaHeight - " + layout.toDevicePixels(safeArea.size.height));
|
||||
newHeight = newHeight + (layout.toDevicePixels(fullscreen.size.height) - (onScreenTop + height));
|
||||
}
|
||||
|
||||
|
||||
@@ -81,21 +81,21 @@ export class StackLayout extends StackLayoutBase {
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void {
|
||||
public onLayout(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void {
|
||||
super.onLayout(left, top, right, bottom);
|
||||
if (this.orientation === "vertical") {
|
||||
this.layoutVertical(left, top, right, bottom, insetLeft, insetTop);
|
||||
this.layoutVertical(left, top, right, bottom, insets);
|
||||
}
|
||||
else {
|
||||
this.layoutHorizontal(left, top, right, bottom);
|
||||
this.layoutHorizontal(left, top, right, bottom, insets);
|
||||
}
|
||||
}
|
||||
|
||||
private layoutVertical(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void {
|
||||
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insetLeft;
|
||||
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insetTop;
|
||||
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight;
|
||||
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom;
|
||||
private layoutVertical(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void {
|
||||
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left;
|
||||
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top;
|
||||
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight + insets.right;
|
||||
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom + insets.bottom;
|
||||
|
||||
let childTop: number;
|
||||
let childLeft: number = paddingLeft;
|
||||
@@ -126,11 +126,11 @@ export class StackLayout extends StackLayoutBase {
|
||||
})
|
||||
}
|
||||
|
||||
private layoutHorizontal(left: number, top: number, right: number, bottom: number): void {
|
||||
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight;
|
||||
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom;
|
||||
private layoutHorizontal(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void {
|
||||
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left;
|
||||
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top;
|
||||
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight + insets.right;
|
||||
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom + insets.bottom;
|
||||
|
||||
let childTop: number = paddingTop;
|
||||
let childLeft: number;
|
||||
|
||||
Reference in New Issue
Block a user