Skip to content

Commit a99ecbb

Browse files
committed
fix(ios): DockLayout layout measurements
1 parent 314db03 commit a99ecbb

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

packages/core/ui/layouts/dock-layout/index.ios.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ export class DockLayout extends DockLayoutBase {
9595
this.eachLayoutChild((child, last) => {
9696
let childWidth = child.getMeasuredWidth() + child.effectiveMarginLeft + child.effectiveMarginRight;
9797
let childHeight = child.getMeasuredHeight() + child.effectiveMarginTop + child.effectiveMarginBottom;
98+
const availableWidth = remainingWidth;
99+
const availableHeight = remainingHeight;
100+
const horizontalAlignment = child.horizontalAlignment;
101+
const extendForAlignment = horizontalAlignment === 'center' || horizontalAlignment === 'right' || horizontalAlignment === 'end';
98102

99103
if (last && this.stretchLastChild) {
100104
// Last child with stretch - give it all the space and return;
101-
View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight);
105+
View.layoutChild(this, child, x, y, x + availableWidth, y + availableHeight);
102106

103107
return;
104108
}
@@ -108,23 +112,28 @@ export class DockLayout extends DockLayoutBase {
108112
case 'top':
109113
childLeft = x;
110114
childTop = y;
111-
childWidth = remainingWidth;
115+
childWidth = availableWidth;
112116
y += childHeight;
113-
remainingHeight = Math.max(0, remainingHeight - childHeight);
117+
remainingHeight = Math.max(0, availableHeight - childHeight);
114118
break;
115119

116120
case 'bottom':
117121
childLeft = x;
118122
childTop = y + remainingHeight - childHeight;
119-
childWidth = remainingWidth;
120-
remainingHeight = Math.max(0, remainingHeight - childHeight);
123+
childWidth = availableWidth;
124+
remainingHeight = Math.max(0, availableHeight - childHeight);
121125
break;
122126

123127
case 'right':
124128
childLeft = x + remainingWidth - childWidth;
125129
childTop = y;
126130
childHeight = remainingHeight;
127-
remainingWidth = Math.max(0, remainingWidth - childWidth);
131+
remainingWidth = Math.max(0, availableWidth - childWidth);
132+
if (extendForAlignment && availableWidth > childWidth) {
133+
const slotLeft = childLeft - (availableWidth - childWidth);
134+
View.layoutChild(this, child, slotLeft, childTop, slotLeft + availableWidth, childTop + childHeight);
135+
return;
136+
}
128137
break;
129138

130139
case 'left':
@@ -133,7 +142,11 @@ export class DockLayout extends DockLayoutBase {
133142
childTop = y;
134143
childHeight = remainingHeight;
135144
x += childWidth;
136-
remainingWidth = Math.max(0, remainingWidth - childWidth);
145+
remainingWidth = Math.max(0, availableWidth - childWidth);
146+
if (extendForAlignment && availableWidth > childWidth) {
147+
View.layoutChild(this, child, childLeft, childTop, childLeft + availableWidth, childTop + childHeight);
148+
return;
149+
}
137150
break;
138151
}
139152

0 commit comments

Comments
 (0)