From 358a22c9daa95ff05fc0996a63574c5b91da2d1c Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 10 Jun 2015 15:34:30 -0700 Subject: [PATCH] Rename BlockContainer, StackContainer, and FlexContainer These are now called Block, Stack, and Flex, respectively. Less verbose. R=jackson@google.com, ianh@google.com Review URL: https://codereview.chromium.org/1181533002. --- examples/fn2/container.dart | 23 +++++++++---------- examples/stocks2/lib/stock_app.dart | 2 +- examples/stocks2/lib/stock_row.dart | 2 +- sdk/lib/framework/components2/drawer.dart | 6 ++--- .../framework/components2/drawer_header.dart | 23 +++++++------------ .../components2/fixed_height_scrollable.dart | 3 +-- sdk/lib/framework/components2/ink_well.dart | 6 ++--- sdk/lib/framework/components2/input.dart | 9 +++----- sdk/lib/framework/components2/menu_item.dart | 5 +--- .../framework/components2/modal_overlay.dart | 2 +- sdk/lib/framework/components2/popup_menu.dart | 2 +- .../components2/popup_menu_item.dart | 2 +- sdk/lib/framework/components2/tool_bar.dart | 11 ++++----- sdk/lib/framework/fn2.dart | 13 +++++------ 14 files changed, 45 insertions(+), 64 deletions(-) diff --git a/examples/fn2/container.dart b/examples/fn2/container.dart index 650775af7af..f1eec6bbea4 100644 --- a/examples/fn2/container.dart +++ b/examples/fn2/container.dart @@ -20,23 +20,22 @@ class Rectangle extends RenderObjectWrapper { class ContainerApp extends App { UINode build() { return new EventListenerNode( - new BlockContainer(children: [ + new Block([ new Container( padding: new EdgeDims.all(10.0), margin: new EdgeDims.all(10.0), height: 100.0, decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00)), - child: new BlockContainer( - children: [ - new Container( - decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFF00)), - height: 20.0, - ), - new Image(src: "https://www.dartlang.org/logos/dart-logo.png", - size: new sky.Size(300.0, 300.0), - key: 1 - ), - ])), + child: new Block([ + new Container( + decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFF00)), + height: 20.0, + ), + new Image(src: "https://www.dartlang.org/logos/dart-logo.png", + size: new sky.Size(300.0, 300.0), + key: 1 + ), + ])), ]), onPointerDown: _handlePointerDown, onGestureTap: _handleGestureTap); diff --git a/examples/stocks2/lib/stock_app.dart b/examples/stocks2/lib/stock_app.dart index fd2b2f19901..c13af8c88fd 100644 --- a/examples/stocks2/lib/stock_app.dart +++ b/examples/stocks2/lib/stock_app.dart @@ -212,7 +212,7 @@ class StocksApp extends App { ), ]; addMenuToOverlays(overlays); - return new StackContainer(children: overlays); + return new Stack(overlays); } } diff --git a/examples/stocks2/lib/stock_row.dart b/examples/stocks2/lib/stock_row.dart index 46563dda93e..1ecb0684696 100644 --- a/examples/stocks2/lib/stock_row.dart +++ b/examples/stocks2/lib/stock_row.dart @@ -44,7 +44,7 @@ class StockRow extends Component { decoration: const BoxDecoration( border: const Border( bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))), - child: new FlexContainer(children: children) + child: new Flex(children) ) ]); } diff --git a/sdk/lib/framework/components2/drawer.dart b/sdk/lib/framework/components2/drawer.dart index ca5d79f4a95..8ae1cab97ac 100644 --- a/sdk/lib/framework/components2/drawer.dart +++ b/sdk/lib/framework/components2/drawer.dart @@ -150,13 +150,11 @@ class Drawer extends AnimatedComponent { boxShadow: Shadow[level]), width: _kWidth, transform: transform, - child: new BlockContainer(children: children) + child: new Block(children) ); return new EventListenerNode( - new StackContainer( - children: [ mask, content ] - ), + new Stack([ mask, content ]), onPointerDown: controller.handlePointerDown, onPointerMove: controller.handlePointerMove, onPointerUp: controller.handlePointerUp, diff --git a/sdk/lib/framework/components2/drawer_header.dart b/sdk/lib/framework/components2/drawer_header.dart index 8560cd5d49a..652596d559c 100644 --- a/sdk/lib/framework/components2/drawer_header.dart +++ b/sdk/lib/framework/components2/drawer_header.dart @@ -14,7 +14,6 @@ class DrawerHeader extends Component { UINode build() { return new Container( - key: 'drawer-header-outside', height: kStatusBarHeight + kMaterialDrawerHeight, decoration: new BoxDecoration( backgroundColor: BlueGrey[50], @@ -27,20 +26,14 @@ class DrawerHeader extends Component { ), padding: const EdgeDims.only(bottom: 7.0), margin: const EdgeDims.only(bottom: 8.0), - child: new FlexContainer( - key: 'drawer-header-inside', - direction: FlexDirection.vertical, - children: [ - new FlexExpandingChild(new Container(key: 'drawer-header-spacer')), - new Container( - key: 'drawer-header-label', - padding: const EdgeDims.symmetric(horizontal: 16.0), - child: new FlexContainer( - direction: FlexDirection.horizontal, - children: children - ) - ) - ] + child: new Flex([ + new FlexExpandingChild(new Container(key: 'drawer-header-spacer')), + new Container( + key: 'drawer-header-label', + padding: const EdgeDims.symmetric(horizontal: 16.0), + child: new Flex(children, direction: FlexDirection.horizontal) + )], + direction: FlexDirection.vertical ) ); } diff --git a/sdk/lib/framework/components2/fixed_height_scrollable.dart b/sdk/lib/framework/components2/fixed_height_scrollable.dart index 5a52010f8c4..93fba3c42c7 100644 --- a/sdk/lib/framework/components2/fixed_height_scrollable.dart +++ b/sdk/lib/framework/components2/fixed_height_scrollable.dart @@ -75,8 +75,7 @@ abstract class FixedHeightScrollable extends Scrollable { ), child: new Transform( transform: transform, - child: new BlockContainer( - children: buildItems(itemShowIndex, itemShowCount)) + child: new Block(buildItems(itemShowIndex, itemShowCount)) ) ) ) diff --git a/sdk/lib/framework/components2/ink_well.dart b/sdk/lib/framework/components2/ink_well.dart index ca7399695c0..a67a63533c3 100644 --- a/sdk/lib/framework/components2/ink_well.dart +++ b/sdk/lib/framework/components2/ink_well.dart @@ -116,10 +116,10 @@ class InkWell extends Component { UINode build() { return new InkWellWrapper( - child: new FlexContainer( + child: new Flex( + children, direction: FlexDirection.horizontal, - justifyContent: FlexJustifyContent.center, - children: children + justifyContent: FlexJustifyContent.center ) ); } diff --git a/sdk/lib/framework/components2/input.dart b/sdk/lib/framework/components2/input.dart index 6a858fd186c..0f7d4816398 100644 --- a/sdk/lib/framework/components2/input.dart +++ b/sdk/lib/framework/components2/input.dart @@ -89,12 +89,9 @@ class Input extends Component { children.add(new EditableText(value: _editableValue, focused: focused)); return new EventListenerNode( - new FlexContainer( - direction: FlexDirection.vertical, - // style: _style, - // inlineStyle: focused ? _focusedInlineStyle : null, - children: children - ), + // style: _style, + // inlineStyle: focused ? _focusedInlineStyle : null, + new Flex(children, direction: FlexDirection.vertical), onPointerDown: (sky.Event e) => keyboard.showByRequest() ); } diff --git a/sdk/lib/framework/components2/menu_item.dart b/sdk/lib/framework/components2/menu_item.dart index f2806f9bb69..4f4bd79a738 100644 --- a/sdk/lib/framework/components2/menu_item.dart +++ b/sdk/lib/framework/components2/menu_item.dart @@ -46,10 +46,7 @@ class MenuItem extends ButtonBase { ), new FlexExpandingChild( new Padding( - child: new FlexContainer( - direction: FlexDirection.horizontal, - children: children - ), + child: new Flex(children, direction: FlexDirection.horizontal), padding: const EdgeDims.symmetric(horizontal: 16.0) ), flex: 1 diff --git a/sdk/lib/framework/components2/modal_overlay.dart b/sdk/lib/framework/components2/modal_overlay.dart index 39a379b3821..84951e051f5 100644 --- a/sdk/lib/framework/components2/modal_overlay.dart +++ b/sdk/lib/framework/components2/modal_overlay.dart @@ -20,7 +20,7 @@ class ModalOverlay extends Component { UINode build() { return new EventListenerNode( - new StackContainer(children: children), + new Stack(children), onGestureTap: onDismiss); } diff --git a/sdk/lib/framework/components2/popup_menu.dart b/sdk/lib/framework/components2/popup_menu.dart index 11cb2979b41..d264f575f19 100644 --- a/sdk/lib/framework/components2/popup_menu.dart +++ b/sdk/lib/framework/components2/popup_menu.dart @@ -121,7 +121,7 @@ class PopupMenu extends AnimatedComponent { backgroundColor: Grey[50], borderRadius: 2.0, boxShadow: Shadow[level]), - child: new BlockContainer(children: children) + child: new Block(children) ) ); } diff --git a/sdk/lib/framework/components2/popup_menu_item.dart b/sdk/lib/framework/components2/popup_menu_item.dart index 5ee1ce57850..d98e9f4d07b 100644 --- a/sdk/lib/framework/components2/popup_menu_item.dart +++ b/sdk/lib/framework/components2/popup_menu_item.dart @@ -16,7 +16,7 @@ class PopupMenuItem extends Component { constraints: const BoxConstraints(minWidth: 112.0), padding: const EdgeDims.all(16.0), // TODO(abarth): opacity: opacity, - child: new FlexContainer(children: children) + child: new Flex(children) ); } } diff --git a/sdk/lib/framework/components2/tool_bar.dart b/sdk/lib/framework/components2/tool_bar.dart index 644f6163d08..ea5dec223a4 100644 --- a/sdk/lib/framework/components2/tool_bar.dart +++ b/sdk/lib/framework/components2/tool_bar.dart @@ -35,13 +35,12 @@ class ToolBar extends Component { if (right != null) children.addAll(right); - // TODO(hansmuller): use align-items:flex-end when FlexContainer supports it. - UINode bottomJustifiedChild = new FlexContainer( + // TODO(hansmuller): use align-items:flex-end when Flex supports it. + UINode bottomJustifiedChild = new Flex([ + new Container(child: new Flex(children), height: kToolBarHeight) + ], direction: FlexDirection.vertical, - justifyContent: FlexJustifyContent.flexEnd, - children: [new Container( - child: new FlexContainer(children: children), - height: kToolBarHeight)]); + justifyContent: FlexJustifyContent.flexEnd); return new Container( child: bottomJustifiedChild, diff --git a/sdk/lib/framework/fn2.dart b/sdk/lib/framework/fn2.dart index 994449538cd..41c3e1a35e0 100644 --- a/sdk/lib/framework/fn2.dart +++ b/sdk/lib/framework/fn2.dart @@ -717,9 +717,9 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper { } -class BlockContainer extends MultiChildRenderObjectWrapper { +class Block extends MultiChildRenderObjectWrapper { - BlockContainer({ Object key, List children }) + Block(List children, { Object key }) : super(key: key, children: children); RenderBlock get root { RenderBlock result = super.root; return result; } @@ -727,9 +727,9 @@ class BlockContainer extends MultiChildRenderObjectWrapper { } -class StackContainer extends MultiChildRenderObjectWrapper { +class Stack extends MultiChildRenderObjectWrapper { - StackContainer({ Object key, List children }) + Stack(List children, { Object key }) : super(key: key, children: children); RenderStack get root { RenderStack result = super.root; return result; } @@ -767,11 +767,10 @@ class Paragraph extends RenderObjectWrapper { } -class FlexContainer extends MultiChildRenderObjectWrapper { +class Flex extends MultiChildRenderObjectWrapper { - FlexContainer({ + Flex(List children, { Object key, - List children, this.direction: FlexDirection.horizontal, this.justifyContent: FlexJustifyContent.flexStart }) : super(key: key, children: children);