Give ParentDataNodes snappier names

FlexExpandingChild -> Flexible
StackPositionedChild -> Positioned

Also, name the child argument |child| for consistency.

TBR=ianh@google.com

Review URL: https://codereview.chromium.org/1179763009.
This commit is contained in:
Adam Barth 2015-06-15 21:03:28 -07:00
parent 883f673a6b
commit 71c7be5ebc
9 changed files with 33 additions and 23 deletions

View File

@ -127,7 +127,7 @@ class StocksApp extends App {
icon: 'action/thumb_up',
onGestureTap: (event) => _handleStockModeChange(StockMode.optimistic),
children: [
new FlexExpandingChild(new Text('Optimistic'), flex: 1),
new Flexible(child: new Text('Optimistic')),
new Radio(key: 'optimistic-radio', value: StockMode.optimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
]),
new MenuItem(
@ -135,7 +135,7 @@ class StocksApp extends App {
icon: 'action/thumb_down',
onGestureTap: (event) => _handleStockModeChange(StockMode.pessimistic),
children: [
new FlexExpandingChild(new Text('Pessimistic'), flex: 1),
new Flexible(child: new Text('Pessimistic')),
new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
]),
new MenuDivider(key: 'div2'),

View File

@ -26,13 +26,13 @@ class StockMenu extends Component {
onChanged: this.onAutorefreshChanged
);
return new StackPositionedChild(
new PopupMenu(
return new Positioned(
child: new PopupMenu(
controller: controller,
items: [
[new Text('Add stock')],
[new Text('Remove stock')],
[new FlexExpandingChild(new Text('Autorefresh')), checkbox],
[new Flexible(child: new Text('Autorefresh')), checkbox],
],
level: 4
),

View File

@ -29,12 +29,12 @@ class StockRow extends Component {
new Container(
child: new StockArrow(percentChange: stock.percentChange),
margin: const EdgeDims.only(right: 5.0)),
new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"),
new Flexible(child: new Text(stock.symbol), flex: 2, key: "symbol"),
// TODO(hansmuller): text-align: right
new FlexExpandingChild(new Text(lastSale,
new Flexible(child: new Text(lastSale,
style: const TextStyle(textAlign: TextAlign.right)),
key: "lastSale"),
new FlexExpandingChild(new Text(changeInPrice,
new Flexible(child: new Text(changeInPrice,
style: typography.black.caption.copyWith(textAlign: TextAlign.right)),
key: "changeInPrice")
];

View File

@ -38,8 +38,8 @@ class ContainerApp extends App {
)
])
),
new FlexExpandingChild(
new Container(
new Flexible(
child: new Container(
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FFFF))
)
),

View File

@ -27,8 +27,8 @@ class Rectangle extends Component {
Rectangle(this.color, { Object key }) : super(key: key);
final Color color;
UINode build() {
return new FlexExpandingChild(
new Container(
return new Flexible(
child: new Container(
decoration: new BoxDecoration(backgroundColor: color)
)
);

View File

@ -306,9 +306,13 @@ class Stack extends MultiChildRenderObjectWrapper {
}
class StackPositionedChild extends ParentDataNode {
StackPositionedChild(UINode content, {
double top, double right, double bottom, double left
class Positioned extends ParentDataNode {
Positioned({
UINode child,
double top,
double right,
double bottom,
double left
}) : super(content, new StackParentData()..top = top
..right = right
..bottom = bottom
@ -340,9 +344,9 @@ class Flex extends MultiChildRenderObjectWrapper {
}
class FlexExpandingChild extends ParentDataNode {
FlexExpandingChild(UINode content, { int flex: 1, Object key })
: super(content, new FlexBoxParentData()..flex = flex, key: key);
class Flexible extends ParentDataNode {
Flexible({ UINode child, int flex: 1, Object key })
: super(child, new FlexBoxParentData()..flex = flex, key: key);
}
class Paragraph extends RenderObjectWrapper {

View File

@ -27,7 +27,7 @@ class DrawerHeader extends Component {
padding: const EdgeDims.only(bottom: 7.0),
margin: const EdgeDims.only(bottom: 8.0),
child: new Flex([
new FlexExpandingChild(new Container(key: 'drawer-header-spacer')),
new Flexible(child: new Container(key: 'drawer-header-spacer')),
new Container(
key: 'drawer-header-label',
padding: const EdgeDims.symmetric(horizontal: 16.0),

View File

@ -45,8 +45,8 @@ class MenuItem extends ButtonBase {
child: new Icon(type: "${icon}_grey600", size: 24),
padding: const EdgeDims.symmetric(horizontal: 16.0)
),
new FlexExpandingChild(
new Padding(
new Flexible(
child: new Padding(
child: new Flex(children, direction: FlexDirection.horizontal),
padding: const EdgeDims.symmetric(horizontal: 16.0)
),

View File

@ -28,8 +28,14 @@ class ToolBar extends Component {
children.add(left);
if (center != null) {
children.add(new FlexExpandingChild(
new Padding(child: center, padding: new EdgeDims.only(left: 24.0))));
children.add(
new Flexible(
child: new Padding(
child: center,
padding: new EdgeDims.only(left: 24.0)
)
)
);
}
if (right != null)