Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: sky/examples/stocks/lib/stock_app.dart

Issue 1137373004: [Effen] Make the stock app use the radio button widget so that it's being tested. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/framework/components/menu_item.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks/lib/stock_app.dart
diff --git a/sky/examples/stocks/lib/stock_app.dart b/sky/examples/stocks/lib/stock_app.dart
index 2c63f6a073e6ccb94fe2462108ee9a2d5f2f36fa..3b6ad62e8f5434ffdf15be0696865ab550e2bfe1 100644
--- a/sky/examples/stocks/lib/stock_app.dart
+++ b/sky/examples/stocks/lib/stock_app.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/modal_overlay.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/fn.dart';
import 'package:sky/framework/theme/typography.dart' as typography;
@@ -26,6 +27,8 @@ import 'package:sky/framework/layout.dart';
const bool debug = false; // set to true to dump the DOM for debugging purposes
+enum StockMode { Optimistic, Pessimistic }
+
class StocksApp extends App {
static final Style _actionBarStyle = new Style('''
@@ -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() {
return new Drawer(
controller: _drawerController,
@@ -107,14 +126,31 @@ class StocksApp extends App {
children: [
new DrawerHeader(children: [new Text('Stocks')]),
new MenuItem(
- key: 'Inbox',
- icon: 'content/inbox',
- children: [new Text('Inbox')]),
- new MenuDivider(),
+ key: 'Stock list',
+ icon: 'action/assessment',
+ children: [new Text('Stock List')]),
+ 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(
- key: 'Drafts',
- icon: 'content/drafts',
- children: [new Text('Drafts')]),
+ key: 'Pessimistic Menu Item',
+ icon: 'action/thumb_down',
+ 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(
key: 'Settings',
icon: 'action/settings',
@@ -165,7 +201,11 @@ class StocksApp extends App {
if (_menuController == null)
return;
overlays.add(new ModalOverlay(
- children: [new StockMenu(controller: _menuController)],
+ children: [new StockMenu(
+ controller: _menuController,
+ autorefresh: _autorefresh,
+ onAutorefreshChanged: _handleAutorefreshChanged
+ )],
onDismiss: _handleMenuHide));
}
« no previous file with comments | « no previous file | sky/framework/components/menu_item.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698