| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 import 'package:sky/framework/components/action_bar.dart'; | 5 import 'package:sky/framework/components/action_bar.dart'; | 
| 6 import 'package:sky/framework/components/drawer.dart'; | 6 import 'package:sky/framework/components/drawer.dart'; | 
| 7 import 'package:sky/framework/components/drawer_header.dart'; | 7 import 'package:sky/framework/components/drawer_header.dart'; | 
| 8 import 'package:sky/framework/components/floating_action_button.dart'; | 8 import 'package:sky/framework/components/floating_action_button.dart'; | 
| 9 import 'package:sky/framework/components/icon.dart'; | 9 import 'package:sky/framework/components/icon.dart'; | 
| 10 import 'package:sky/framework/components/icon_button.dart'; | 10 import 'package:sky/framework/components/icon_button.dart'; | 
| 11 import 'package:sky/framework/components/input.dart'; | 11 import 'package:sky/framework/components/input.dart'; | 
| 12 import 'package:sky/framework/components/menu_divider.dart'; | 12 import 'package:sky/framework/components/menu_divider.dart'; | 
| 13 import 'package:sky/framework/components/menu_item.dart'; | 13 import 'package:sky/framework/components/menu_item.dart'; | 
| 14 import 'package:sky/framework/components/modal_overlay.dart'; | 14 import 'package:sky/framework/components/modal_overlay.dart'; | 
| 15 import 'package:sky/framework/components/popup_menu.dart'; | 15 import 'package:sky/framework/components/popup_menu.dart'; | 
| 16 import 'package:sky/framework/components/scaffold.dart'; | 16 import 'package:sky/framework/components/scaffold.dart'; | 
| 17 import 'package:sky/framework/fn.dart'; | 17 import 'package:sky/framework/fn.dart'; | 
| 18 import 'package:sky/framework/theme/typography.dart' as typography; | 18 import 'package:sky/framework/theme/typography.dart' as typography; | 
| 19 import 'package:sky/framework/theme/colors.dart'; | 19 import 'package:sky/framework/theme/colors.dart'; | 
| 20 import 'stock_data.dart'; | 20 import 'stock_data.dart'; | 
| 21 import 'stock_list.dart'; | 21 import 'stock_list.dart'; | 
| 22 import 'stock_menu.dart'; | 22 import 'stock_menu.dart'; | 
| 23 | 23 | 
| 24 import 'dart:async'; | 24 import 'dart:async'; | 
| 25 import 'package:sky/framework/layout.dart'; | 25 import 'package:sky/framework/layout.dart'; | 
| 26 | 26 | 
| 27 const bool debug = false; // set to true to dump the DOM for debugging purposes | 27 const bool debug = false; // set to true to dump the DOM for debugging purposes | 
| 28 | 28 | 
| 29 class StocksApp extends App { | 29 class StocksApp extends App { | 
| 30   DrawerController _drawerController = new DrawerController(); |  | 
| 31   PopupMenuController _menuController; |  | 
| 32 | 30 | 
| 33   static final Style _actionBarStyle = new Style(''' | 31   static final Style _actionBarStyle = new Style(''' | 
| 34     background-color: ${Purple[500]};'''); | 32     background-color: ${Purple[500]};'''); | 
| 35 | 33 | 
| 36   static final Style _searchBarStyle = new Style(''' | 34   static final Style _searchBarStyle = new Style(''' | 
| 37     background-color: ${Grey[50]};'''); | 35     background-color: ${Grey[50]};'''); | 
| 38 | 36 | 
| 39   static final Style _titleStyle = new Style(''' | 37   static final Style _titleStyle = new Style(''' | 
| 40     ${typography.white.title};'''); | 38     ${typography.white.title};'''); | 
| 41 | 39 | 
| 42   List<Stock> _stocks = []; | 40   List<Stock> _stocks = []; | 
| 43   bool _isSearching = false; |  | 
| 44   String _searchQuery; |  | 
| 45 | 41 | 
| 46   StocksApp() : super() { | 42   StocksApp() : super() { | 
| 47     if (debug) | 43     if (debug) | 
| 48       new Timer(new Duration(seconds: 1), dumpState); | 44       new Timer(new Duration(seconds: 1), dumpState); | 
| 49     new StockDataFetcher((StockData data) { | 45     new StockDataFetcher((StockData data) { | 
| 50       setState(() { | 46       setState(() { | 
| 51         data.appendTo(_stocks); | 47         data.appendTo(_stocks); | 
| 52       }); | 48       }); | 
| 53     }); | 49     }); | 
|  | 50     _drawerController = new DrawerController(_handleDrawerStatusChanged); | 
| 54   } | 51   } | 
| 55 | 52 | 
|  | 53   bool _isSearching = false; | 
|  | 54   String _searchQuery; | 
|  | 55 | 
| 56   void _handleSearchBegin(_) { | 56   void _handleSearchBegin(_) { | 
| 57     setState(() { | 57     setState(() { | 
| 58       _isSearching = true; | 58       _isSearching = true; | 
| 59     }); | 59     }); | 
| 60   } | 60   } | 
| 61 | 61 | 
| 62   void _handleSearchEnd(_) { | 62   void _handleSearchEnd(_) { | 
| 63     setState(() { | 63     setState(() { | 
| 64       _isSearching = false; | 64       _isSearching = false; | 
| 65       _searchQuery = null; | 65       _searchQuery = null; | 
| 66     }); | 66     }); | 
| 67   } | 67   } | 
| 68 | 68 | 
| 69   void _handleSearchQueryChanged(String query) { | 69   void _handleSearchQueryChanged(String query) { | 
| 70     setState(() { | 70     setState(() { | 
| 71       _searchQuery = query; | 71       _searchQuery = query; | 
| 72     }); | 72     }); | 
| 73   } | 73   } | 
| 74 | 74 | 
|  | 75   DrawerController _drawerController; | 
|  | 76   bool _drawerShowing = false; | 
|  | 77 | 
|  | 78   void _handleDrawerStatusChanged(bool showing) { | 
|  | 79     setState(() { | 
|  | 80       _drawerShowing = showing; | 
|  | 81     }); | 
|  | 82   } | 
|  | 83 | 
|  | 84   PopupMenuController _menuController; | 
|  | 85 | 
| 75   void _handleMenuShow(_) { | 86   void _handleMenuShow(_) { | 
| 76     setState(() { | 87     setState(() { | 
| 77       _menuController = new PopupMenuController(); | 88       _menuController = new PopupMenuController(); | 
| 78       _menuController.open(); | 89       _menuController.open(); | 
| 79     }); | 90     }); | 
| 80   } | 91   } | 
| 81 | 92 | 
| 82   void _handleMenuHide(_) { | 93   void _handleMenuHide(_) { | 
| 83     setState(() { | 94     setState(() { | 
| 84       _menuController.close().then((_) { | 95       _menuController.close().then((_) { | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160 | 171 | 
| 161   UINode build() { | 172   UINode build() { | 
| 162     List<UINode> overlays = []; | 173     List<UINode> overlays = []; | 
| 163     addMenuToOverlays(overlays); | 174     addMenuToOverlays(overlays); | 
| 164 | 175 | 
| 165     return new Scaffold( | 176     return new Scaffold( | 
| 166       header: _isSearching ? buildSearchBar() : buildActionBar(), | 177       header: _isSearching ? buildSearchBar() : buildActionBar(), | 
| 167       content: new Stocklist(stocks: _stocks, query: _searchQuery), | 178       content: new Stocklist(stocks: _stocks, query: _searchQuery), | 
| 168       fab: new FloatingActionButton( | 179       fab: new FloatingActionButton( | 
| 169         content: new Icon(type: 'content/add_white', size: 24), level: 3), | 180         content: new Icon(type: 'content/add_white', size: 24), level: 3), | 
| 170       drawer: buildDrawer(), | 181       drawer: _drawerShowing ? buildDrawer() : null, | 
| 171       overlays: overlays | 182       overlays: overlays | 
| 172     ); | 183     ); | 
| 173   } | 184   } | 
| 174 } | 185 } | 
| OLD | NEW | 
|---|