OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 import 'package:sky/rendering/sky_binding.dart'; | |
6 import 'package:sky/theme/colors.dart' as colors; | |
7 import 'package:sky/theme/theme_data.dart'; | |
8 import 'package:sky/widgets/basic.dart'; | |
9 import 'package:sky/widgets/navigator.dart'; | |
10 import 'package:sky/widgets/theme.dart'; | |
11 import 'package:sky/widgets/widget.dart'; | |
12 | |
13 import 'stock_data.dart'; | |
14 import 'stock_home.dart'; | |
15 import 'stock_settings.dart'; | |
16 import 'stock_types.dart'; | |
17 | |
18 class StocksApp extends App { | |
19 | |
20 NavigationState _navigationState; | |
21 StocksApp() { | |
22 _navigationState = new NavigationState([ | |
23 new Route( | |
24 name: '/', | |
25 builder: (navigator, route) => new StockHome(navigator, _stocks, stockMo
de, modeUpdater) | |
26 ), | |
27 new Route( | |
28 name: '/settings', | |
29 builder: (navigator, route) => new StockSettings(navigator, stockMode, s
ettingsUpdater) | |
30 ), | |
31 ]); | |
32 } | |
33 | |
34 void onBack() { | |
35 setState(() { | |
36 _navigationState.pop(); | |
37 }); | |
38 // TODO(jackson): Need a way to invoke default back behavior here | |
39 } | |
40 | |
41 StockMode stockMode = StockMode.optimistic; | |
42 void modeUpdater(StockMode value) { | |
43 setState(() { | |
44 stockMode = value; | |
45 }); | |
46 } | |
47 void settingsUpdater({StockMode mode}) { | |
48 setState(() { | |
49 if (mode != null) | |
50 stockMode = mode; | |
51 }); | |
52 } | |
53 | |
54 final List<Stock> _stocks = []; | |
55 void didMount() { | |
56 super.didMount(); | |
57 new StockDataFetcher((StockData data) { | |
58 setState(() { | |
59 data.appendTo(_stocks); | |
60 }); | |
61 }); | |
62 } | |
63 | |
64 Widget build() { | |
65 return new Theme( | |
66 data: new ThemeData.light( | |
67 primary: colors.Purple, | |
68 accent: colors.RedAccent, | |
69 darkToolbar: true), | |
70 child: new Navigator(_navigationState) | |
71 ); | |
72 } | |
73 } | |
74 | |
75 void main() { | |
76 print("starting stocks app!"); | |
77 runApp(new StocksApp()); | |
78 SkyBinding.instance.onFrame = () { | |
79 // uncomment this for debugging: | |
80 // SkyBinding.instance.debugDumpRenderTree(); | |
81 }; | |
82 } | |
OLD | NEW |