| Index: sky/sdk/lib/framework/rendering/flex.dart
|
| diff --git a/sky/sdk/lib/framework/rendering/flex.dart b/sky/sdk/lib/framework/rendering/flex.dart
|
| index 4def9d2d094b03771cf28998d2003b74052f7593..dc08cd73dc01882c1ed2a5ea42b92f1037d72251 100644
|
| --- a/sky/sdk/lib/framework/rendering/flex.dart
|
| +++ b/sky/sdk/lib/framework/rendering/flex.dart
|
| @@ -19,6 +19,7 @@ class FlexBoxParentData extends BoxParentData with ContainerParentDataMixin<Rend
|
| }
|
|
|
| enum FlexDirection { horizontal, vertical }
|
| +
|
| enum FlexJustifyContent {
|
| flexStart,
|
| flexEnd,
|
| @@ -27,6 +28,12 @@ enum FlexJustifyContent {
|
| spaceAround,
|
| }
|
|
|
| +enum FlexAlignItems {
|
| + flexStart,
|
| + flexEnd,
|
| + center,
|
| +}
|
| +
|
| typedef double _ChildSizingFunction(RenderBox child, BoxConstraints constraints);
|
|
|
| class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, FlexBoxParentData>,
|
| @@ -35,8 +42,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|
|
| RenderFlex({
|
| FlexDirection direction: FlexDirection.horizontal,
|
| - FlexJustifyContent justifyContent: FlexJustifyContent.flexStart
|
| - }) : _direction = direction, _justifyContent = justifyContent;
|
| + FlexJustifyContent justifyContent: FlexJustifyContent.flexStart,
|
| + FlexAlignItems alignItems: FlexAlignItems.center
|
| + }) : _direction = direction, _justifyContent = justifyContent, _alignItems = alignItems;
|
|
|
| FlexDirection _direction;
|
| FlexDirection get direction => _direction;
|
| @@ -56,6 +64,15 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
| }
|
| }
|
|
|
| + FlexAlignItems _alignItems;
|
| + FlexAlignItems get alignItems => _alignItems;
|
| + void set alignItems (FlexAlignItems value) {
|
| + if (_alignItems != value) {
|
| + _alignItems = value;
|
| + markNeedsLayout();
|
| + }
|
| + }
|
| +
|
| void setParentData(RenderBox child) {
|
| if (child.parentData is! FlexBoxParentData)
|
| child.parentData = new FlexBoxParentData();
|
| @@ -334,7 +351,18 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
| double childMainPosition = leadingSpace;
|
| child = firstChild;
|
| while (child != null) {
|
| - double childCrossPosition = crossSize / 2.0 - _getCrossSize(child) / 2.0;
|
| + double childCrossPosition;
|
| + switch (_alignItems) {
|
| + case FlexAlignItems.flexStart:
|
| + childCrossPosition = 0.0;
|
| + break;
|
| + case FlexAlignItems.flexEnd:
|
| + childCrossPosition = crossSize - _getCrossSize(child);
|
| + break;
|
| + case FlexAlignItems.center:
|
| + childCrossPosition = crossSize / 2.0 - _getCrossSize(child) / 2.0;
|
| + break;
|
| + }
|
| switch (_direction) {
|
| case FlexDirection.horizontal:
|
| child.parentData.position = new Point(childMainPosition, childCrossPosition);
|
|
|