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

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

Issue 1191153002: Make back button control drawer in stocks app (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: abarth feedback 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 | « no previous file | sky/examples/stocks2/lib/stock_home.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks2/lib/stock_app.dart
diff --git a/sky/examples/stocks2/lib/stock_app.dart b/sky/examples/stocks2/lib/stock_app.dart
index 6ed6dd4a1ce35036045b0117d843ae011136b1ac..2398238cd43c3faa709257f87b66a984c1822215 100644
--- a/sky/examples/stocks2/lib/stock_app.dart
+++ b/sky/examples/stocks2/lib/stock_app.dart
@@ -7,29 +7,45 @@ import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/widget.dart';
+import 'stock_data.dart';
import 'stock_home.dart';
import 'stock_settings.dart';
class StocksApp extends App {
- NavigationState _navState = new NavigationState([
- new Route(name: '/', builder: (navigator) => new StockHome(navigator)),
- new Route(name: '/settings', builder: (navigator) => new StockSettings(navigator)),
- ]);
+ StocksApp() {
+ _navigationState = new NavigationState([
+ new Route(
+ name: '/',
+ builder: (navigator, route) => new StockHome(navigator, route, _stocks)
+ ),
+ new Route(
+ name: '/settings',
+ builder: (navigator, route) => new StockSettings(navigator)
+ ),
+ ]);
+ }
- void onBack() {
- if (_navState.hasPrevious()) {
+ void didMount() {
+ new StockDataFetcher((StockData data) {
setState(() {
- _navState.pop();
+ data.appendTo(_stocks);
});
- return;
- }
- print ("Should exit app here");
+ });
+ }
+
+ final List<Stock> _stocks = [];
+ NavigationState _navigationState;
+
+ void onBack() {
+ setState(() {
+ _navigationState.pop();
+ });
// TODO(jackson): Need a way to invoke default back behavior here
}
Widget build() {
- return new Navigator(_navState);
+ return new Navigator(_navigationState);
}
}
« no previous file with comments | « no previous file | sky/examples/stocks2/lib/stock_home.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698