Commit 2c44ed0f authored by Hixie's avatar Hixie

Implement 'stretch' for flexible items.

parent 3784201b
...@@ -341,17 +341,34 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -341,17 +341,34 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
if (flex > 0) { if (flex > 0) {
double spaceForChild = spacePerFlex * flex; double spaceForChild = spacePerFlex * flex;
BoxConstraints innerConstraints; BoxConstraints innerConstraints;
switch (_direction) { if (alignItems == FlexAlignItems.stretch) {
case FlexDirection.horizontal: switch (_direction) {
innerConstraints = new BoxConstraints(maxHeight: constraints.maxHeight, case FlexDirection.horizontal:
minWidth: spaceForChild, innerConstraints = new BoxConstraints(minWidth: constraints.maxWidth,
maxWidth: spaceForChild); maxWidth: constraints.maxWidth,
break; minHeight: constraints.minHeight,
case FlexDirection.vertical: maxHeight: constraints.maxHeight);
innerConstraints = new BoxConstraints(minHeight: spaceForChild, break;
maxHeight: spaceForChild, case FlexDirection.vertical:
maxWidth: constraints.maxWidth); innerConstraints = new BoxConstraints(minWidth: constraints.minWidth,
break; maxWidth: constraints.maxWidth,
minHeight: constraints.maxHeight,
maxHeight: constraints.maxHeight);
break;
}
} else {
switch (_direction) {
case FlexDirection.horizontal:
innerConstraints = new BoxConstraints(maxHeight: constraints.maxHeight,
minWidth: spaceForChild,
maxWidth: spaceForChild);
break;
case FlexDirection.vertical:
innerConstraints = new BoxConstraints(minHeight: spaceForChild,
maxHeight: spaceForChild,
maxWidth: constraints.maxWidth);
break;
}
} }
child.layout(innerConstraints, parentUsesSize: true); child.layout(innerConstraints, parentUsesSize: true);
usedSpace += _getMainSize(child); usedSpace += _getMainSize(child);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment