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

Unified Diff: sky/examples/stocks2/lib/stock_home.dart

Issue 1197333002: Make the checkbox in settings control the radio buttons in the drawer, to demonstrate how to link s… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « sky/examples/stocks2/lib/stock_app.dart ('k') | sky/examples/stocks2/lib/stock_settings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks2/lib/stock_home.dart
diff --git a/sky/examples/stocks2/lib/stock_home.dart b/sky/examples/stocks2/lib/stock_home.dart
index 720530b8dea709699c7c456bcf31df5f1c6be56a..7182f51f847f6d5e31504eaa75da11af2e85e3a4 100644
--- a/sky/examples/stocks2/lib/stock_home.dart
+++ b/sky/examples/stocks2/lib/stock_home.dart
@@ -23,25 +23,30 @@ import 'package:sky/widgets/widget.dart';
import 'stock_data.dart';
import 'stock_list.dart';
import 'stock_menu.dart';
+import 'stock_types.dart';
-enum StockMode { optimistic, pessimistic }
+typedef void ModeUpdater(StockMode mode);
class StockHome extends Component {
- StockHome(this.navigator, RouteBase route, this.stocks) : super(stateful: true) {
+ StockHome(this.navigator, this.stocks, this.stockMode, this.modeUpdater) : super(stateful: true) {
// if (debug)
// new Timer(new Duration(seconds: 1), dumpState);
_drawerController = new DrawerController(_handleDrawerStatusChanged);
}
+ Navigator navigator;
+ List<Stock> stocks;
+ StockMode stockMode;
+ ModeUpdater modeUpdater;
+
void syncFields(StockHome source) {
navigator = source.navigator;
stocks = source.stocks;
+ stockMode = source.stockMode;
+ modeUpdater = source.modeUpdater;
}
- Navigator navigator;
- List<Stock> stocks;
-
bool _isSearching = false;
String _searchQuery;
@@ -102,11 +107,12 @@ class StockHome extends Component {
});
}
- StockMode _stockMode = StockMode.optimistic;
void _handleStockModeChange(StockMode value) {
setState(() {
- _stockMode = value;
+ stockMode = value;
});
+ if (modeUpdater != null)
+ modeUpdater(value);
}
Drawer buildDrawer() {
@@ -127,14 +133,14 @@ class StockHome extends Component {
onPressed: () => _handleStockModeChange(StockMode.optimistic),
children: [
new Flexible(child: new Text('Optimistic')),
- new Radio(value: StockMode.optimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
+ new Radio(value: StockMode.optimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]),
new MenuItem(
icon: 'action/thumb_down',
onPressed: () => _handleStockModeChange(StockMode.pessimistic),
children: [
new Flexible(child: new Text('Pessimistic')),
- new Radio(value: StockMode.pessimistic, groupValue: _stockMode, onChanged: _handleStockModeChange)
+ new Radio(value: StockMode.pessimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]),
new MenuDivider(),
new MenuItem(
« no previous file with comments | « sky/examples/stocks2/lib/stock_app.dart ('k') | sky/examples/stocks2/lib/stock_settings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698