Commit 2be9ca10 authored by Hixie's avatar Hixie

[Effen] Make the stock app use the radio button widget so that it's being tested.

Changes:
- adds a couple of radio buttons to the drawer menu list.
- makes menu items support being tapped and reporting the tap.
- hooks up the checkbox to actually support being checked.
- changes the drawer menu items to make more sense in a stock app.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1137373004
parent 15617976
...@@ -13,6 +13,7 @@ import 'package:sky/framework/components/menu_divider.dart'; ...@@ -13,6 +13,7 @@ import 'package:sky/framework/components/menu_divider.dart';
import 'package:sky/framework/components/menu_item.dart'; import 'package:sky/framework/components/menu_item.dart';
import 'package:sky/framework/components/modal_overlay.dart'; import 'package:sky/framework/components/modal_overlay.dart';
import 'package:sky/framework/components/popup_menu.dart'; import 'package:sky/framework/components/popup_menu.dart';
import 'package:sky/framework/components/radio.dart';
import 'package:sky/framework/components/scaffold.dart'; import 'package:sky/framework/components/scaffold.dart';
import 'package:sky/framework/fn.dart'; import 'package:sky/framework/fn.dart';
import 'package:sky/framework/theme/typography.dart' as typography; import 'package:sky/framework/theme/typography.dart' as typography;
...@@ -26,6 +27,8 @@ import 'package:sky/framework/layout.dart'; ...@@ -26,6 +27,8 @@ import 'package:sky/framework/layout.dart';
const bool debug = false; // set to true to dump the DOM for debugging purposes const bool debug = false; // set to true to dump the DOM for debugging purposes
enum StockMode { Optimistic, Pessimistic }
class StocksApp extends App { class StocksApp extends App {
static final Style _actionBarStyle = new Style(''' static final Style _actionBarStyle = new Style('''
...@@ -100,6 +103,22 @@ class StocksApp extends App { ...@@ -100,6 +103,22 @@ class StocksApp extends App {
}); });
} }
bool _autorefresh = false;
void _handleAutorefreshChanged(bool value) {
setState(() {
_autorefresh = value;
});
}
StockMode _stockMode = StockMode.Optimistic;
void _handleStockModeChange(StockMode value) {
setState(() {
_stockMode = value;
});
}
static FlexBoxParentData _flex1 = new FlexBoxParentData()..flex = 1;
Drawer buildDrawer() { Drawer buildDrawer() {
return new Drawer( return new Drawer(
controller: _drawerController, controller: _drawerController,
...@@ -107,14 +126,31 @@ class StocksApp extends App { ...@@ -107,14 +126,31 @@ class StocksApp extends App {
children: [ children: [
new DrawerHeader(children: [new Text('Stocks')]), new DrawerHeader(children: [new Text('Stocks')]),
new MenuItem( new MenuItem(
key: 'Inbox', key: 'Stock list',
icon: 'content/inbox', icon: 'action/assessment',
children: [new Text('Inbox')]), children: [new Text('Stock List')]),
new MenuDivider(), new MenuItem(
key: 'Account Balance',
icon: 'action/account_balance',
children: [new Text('Account Balance')]),
new MenuDivider(key: 'div1'),
new MenuItem(
key: 'Optimistic Menu Item',
icon: 'action/thumb_up',
onGestureTap: (event) => _handleStockModeChange(StockMode.Optimistic),
children: [
new ParentDataNode(new Text('Optimistic'), _flex1),
new Radio(key: 'optimistic-radio', value: StockMode.Optimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
]),
new MenuItem( new MenuItem(
key: 'Drafts', key: 'Pessimistic Menu Item',
icon: 'content/drafts', icon: 'action/thumb_down',
children: [new Text('Drafts')]), onGestureTap: (event) => _handleStockModeChange(StockMode.Pessimistic),
children: [
new ParentDataNode(new Text('Pessimistic'), _flex1),
new Radio(key: 'pessimistic-radio', value: StockMode.Pessimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
]),
new MenuDivider(key: 'div2'),
new MenuItem( new MenuItem(
key: 'Settings', key: 'Settings',
icon: 'action/settings', icon: 'action/settings',
...@@ -165,7 +201,11 @@ class StocksApp extends App { ...@@ -165,7 +201,11 @@ class StocksApp extends App {
if (_menuController == null) if (_menuController == null)
return; return;
overlays.add(new ModalOverlay( overlays.add(new ModalOverlay(
children: [new StockMenu(controller: _menuController)], children: [new StockMenu(
controller: _menuController,
autorefresh: _autorefresh,
onAutorefreshChanged: _handleAutorefreshChanged
)],
onDismiss: _handleMenuHide)); onDismiss: _handleMenuHide));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment