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