From 09183a7fd18bc6cf699d77501816df024012b783 Mon Sep 17 00:00:00 2001 From: Hixie Date: Tue, 12 May 2015 14:39:43 -0700 Subject: [PATCH] [Effen] Use the checkbox widget in the stocks app. - add a checkbox to the stock app, so that we're testing the checkbox widget (it's not currently wired up to anything, that can come later) - make InkSplash use FlexContainer so that we can use flex in the popup menu items - make effen's Text be more similar to Image and Container, so that it can be styled - make layout.dart's RenderCSSText correctly support being styled - also fixes a bug with the stock list where we were rendering one too few a row when scrolling - check in the code to dump the DOM so I don't have to keep remembering how to do this R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1134163003 --- examples/stocks/lib/stock_app.dart | 7 +++++++ examples/stocks/lib/stock_menu.dart | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/stocks/lib/stock_app.dart b/examples/stocks/lib/stock_app.dart index f78dadda157..aa35a5dd4a7 100644 --- a/examples/stocks/lib/stock_app.dart +++ b/examples/stocks/lib/stock_app.dart @@ -21,6 +21,11 @@ import 'stock_data.dart'; import 'stock_list.dart'; import 'stock_menu.dart'; +import 'dart:async'; +import 'package:sky/framework/layout.dart'; + +const bool debug = false; // set to true to dump the DOM for debugging purposes + class StocksApp extends App { DrawerController _drawerController = new DrawerController(); PopupMenuController _menuController; @@ -39,6 +44,8 @@ class StocksApp extends App { String _searchQuery; StocksApp() : super() { + if (debug) + new Timer(new Duration(seconds: 1), dumpState); new StockDataFetcher((StockData data) { setState(() { data.appendTo(_stocks); diff --git a/examples/stocks/lib/stock_menu.dart b/examples/stocks/lib/stock_menu.dart index 03b09983d11..33d19831685 100644 --- a/examples/stocks/lib/stock_menu.dart +++ b/examples/stocks/lib/stock_menu.dart @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:sky/framework/components/popup_menu.dart'; import 'package:sky/framework/fn.dart'; +import 'package:sky/framework/layout.dart'; +import 'package:sky/framework/components/popup_menu.dart'; +import 'package:sky/framework/components/checkbox.dart'; import 'package:sky/framework/theme/view_configuration.dart'; class StockMenu extends Component { @@ -14,16 +16,26 @@ class StockMenu extends Component { PopupMenuController controller; - StockMenu({Object key, this.controller}) : super(key: key); + StockMenu({Object key, this.controller, this.autorefresh: false, this.onAutorefreshChanged}) : super(key: key); + + final bool autorefresh; + final ValueChanged onAutorefreshChanged; + + static FlexBoxParentData _flex1 = new FlexBoxParentData()..flex = 1; UINode build() { + var checkbox = new Checkbox( + checked: this.autorefresh, + onChanged: this.onAutorefreshChanged + ); + return new StyleNode( new PopupMenu( controller: controller, items: [ [new Text('Add stock')], [new Text('Remove stock')], - [new Text('Help & feedback')], + [new ParentDataNode(new Text('Autorefresh'), _flex1), checkbox], ], level: 4), _style