feat: apply insets to dock layout

This commit is contained in:
Vasil Chimev
2018-08-23 13:23:25 +03:00
committed by Martin Yankov
parent d7dcc737f6
commit 12a9c5181e
4 changed files with 26 additions and 5 deletions

View File

@@ -17,6 +17,10 @@ Page {
background-color: LightGreen;
}
.dock {
background-color: HoneyDew;
}
.grid {
background-color: LightBlue;
}

View File

@@ -0,0 +1,15 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<ActionBar>
<Label text="DockLayout Examples"></Label>
</ActionBar>
<DockLayout stretchLastChild="true" class="dock">
<Button dock="Left" text="left" backgroundColor="red" />
<Button dock="Top" text="top" backgroundColor="green" />
<Button dock="Right" text="right" backgroundColor="blue" />
<Button dock="Bottom" text="bottom" backgroundColor="yellow" />
<Button text="Fill"/>
</DockLayout>
</Page>

View File

@@ -7,6 +7,7 @@
<ScrollView>
<StackLayout>
<Button text="Component Examples" tap="onNavigate" route="component/component-page"></Button>
<Button text="DockLayout Examples" tap="onNavigate" route="docklayout/docklayout-page"></Button>
<Button text="GridLayout Examples" tap="onNavigate" route="gridlayout/gridlayout-page"></Button>
<Button text="ListView Examples" tap="onNavigate" route="listview/listview-page" />
<Button text="ScrollView Examples" tap="onNavigate" route="scrollview/scrollview-page"></Button>

View File

@@ -22,7 +22,7 @@ export class DockLayout extends DockLayoutBase {
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
let remainingWidth = widthMode === layout.UNSPECIFIED ? Number.MAX_VALUE : width - horizontalPaddingsAndMargins;
let remainingHeight = heightMode === layout.UNSPECIFIED ? Number.MAX_VALUE : height - verticalPaddingsAndMargins;
@@ -79,11 +79,12 @@ export class DockLayout extends DockLayoutBase {
public onLayout(left: number, top: number, right: number, bottom: number): void {
super.onLayout(left, top, right, bottom);
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
const insets = this.getSafeAreaInsets();
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth + insets.left + insets.right;
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth + insets.top + insets.bottom;
let childLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
let childTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
let childLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left;
let childTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top;
let x = childLeft;
let y = childTop;