OLD | NEW |
1 library stocksapp; | 1 library stocksapp; |
2 | 2 |
3 import '../../framework/fn.dart'; | 3 import '../../framework/fn.dart'; |
4 import '../../framework/components/drawer.dart'; | 4 import '../../framework/components/drawer.dart'; |
5 import '../../framework/components/drawer_header.dart'; | 5 import '../../framework/components/drawer_header.dart'; |
6 import '../../framework/components/fixed_height_scrollable.dart'; | 6 import '../../framework/components/fixed_height_scrollable.dart'; |
7 import '../../framework/components/floating_action_button.dart'; | 7 import '../../framework/components/floating_action_button.dart'; |
8 import '../../framework/components/icon.dart'; | 8 import '../../framework/components/icon.dart'; |
| 9 import '../../framework/components/input.dart'; |
9 import '../../framework/components/material.dart'; | 10 import '../../framework/components/material.dart'; |
10 import '../../framework/components/menu_divider.dart'; | 11 import '../../framework/components/menu_divider.dart'; |
11 import '../../framework/components/menu_item.dart'; | 12 import '../../framework/components/menu_item.dart'; |
12 import '../../framework/components/toolbar.dart'; | 13 import '../../framework/components/toolbar.dart'; |
13 import '../data/stocks.dart'; | 14 import '../data/stocks.dart'; |
14 import 'dart:math'; | 15 import 'dart:math'; |
15 | 16 |
16 part 'stockarrow.dart'; | 17 part 'stockarrow.dart'; |
17 part 'stocklist.dart'; | 18 part 'stocklist.dart'; |
18 part 'stockrow.dart'; | 19 part 'stockrow.dart'; |
(...skipping 14 matching lines...) Expand all Loading... |
33 padding: 8px; | 34 padding: 8px; |
34 margin: 0 4px;''' | 35 margin: 0 4px;''' |
35 ); | 36 ); |
36 | 37 |
37 static Style _titleStyle = new Style(''' | 38 static Style _titleStyle = new Style(''' |
38 flex: 1; | 39 flex: 1; |
39 margin: 0 4px;''' | 40 margin: 0 4px;''' |
40 ); | 41 ); |
41 | 42 |
42 List<Stock> _sortedStocks; | 43 List<Stock> _sortedStocks; |
| 44 bool _isSearching = false; |
43 | 45 |
44 StocksApp() : super() { | 46 StocksApp() : super() { |
45 _sortedStocks = oracle.stocks; | 47 _sortedStocks = oracle.stocks; |
46 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); | 48 _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); |
47 } | 49 } |
48 | 50 |
| 51 void _handleSearchClick(_) { |
| 52 setState(() { |
| 53 _isSearching = !_isSearching; |
| 54 }); |
| 55 } |
| 56 |
49 Node build() { | 57 Node build() { |
50 var drawer = new Drawer( | 58 var drawer = new Drawer( |
51 animation: _drawerAnimation, | 59 animation: _drawerAnimation, |
52 children: [ | 60 children: [ |
53 new DrawerHeader( | 61 new DrawerHeader( |
54 children: [new Text('Stocks')] | 62 children: [new Text('Stocks')] |
55 ), | 63 ), |
56 new MenuItem( | 64 new MenuItem( |
57 key: 'Inbox', | 65 key: 'Inbox', |
58 icon: 'content/inbox', | 66 icon: 'content/inbox', |
(...skipping 12 matching lines...) Expand all Loading... |
71 children: [new Text('Settings')] | 79 children: [new Text('Settings')] |
72 ), | 80 ), |
73 new MenuItem( | 81 new MenuItem( |
74 key: 'Help & Feedback', | 82 key: 'Help & Feedback', |
75 icon: 'action/help', | 83 icon: 'action/help', |
76 children: [new Text('Help & Feedback')] | 84 children: [new Text('Help & Feedback')] |
77 ) | 85 ) |
78 ] | 86 ] |
79 ); | 87 ); |
80 | 88 |
| 89 Node title = _isSearching ? |
| 90 new Input(focused: true) : new Text('I am a stocks app'); |
| 91 |
81 var toolbar = new Toolbar( | 92 var toolbar = new Toolbar( |
82 children: [ | 93 children: [ |
83 new Icon(key: 'menu', style: _iconStyle, | 94 new Icon(key: 'menu', style: _iconStyle, |
84 size: 24, | 95 size: 24, |
85 type: 'navigation/menu_white') | 96 type: 'navigation/menu_white') |
86 ..events.listen('click', _drawerAnimation.toggle), | 97 ..events.listen('click', _drawerAnimation.toggle), |
87 new Container( | 98 new Container( |
88 style: _titleStyle, | 99 style: _titleStyle, |
89 children: [new Text('I am a stocks app')] | 100 children: [title] |
90 ), | 101 ), |
91 new Icon(key: 'search', style: _iconStyle, | 102 new Icon(key: 'search', style: _iconStyle, |
92 size: 24, | 103 size: 24, |
93 type: 'action/search_white'), | 104 type: 'action/search_white') |
| 105 ..events.listen('click', _handleSearchClick), |
94 new Icon(key: 'more_white', style: _iconStyle, | 106 new Icon(key: 'more_white', style: _iconStyle, |
95 size: 24, | 107 size: 24, |
96 type: 'navigation/more_vert_white') | 108 type: 'navigation/more_vert_white') |
97 ] | 109 ] |
98 ); | 110 ); |
99 | 111 |
100 var fab = new FloatingActionButton(content: new Icon( | 112 var fab = new FloatingActionButton(content: new Icon( |
101 type: 'content/add_white', size: 24)); | 113 type: 'content/add_white', size: 24)); |
102 | 114 |
103 return new Container( | 115 return new Container( |
104 key: 'StocksApp', | 116 key: 'StocksApp', |
105 children: [ | 117 children: [ |
106 new Container( | 118 new Container( |
107 key: 'Content', | 119 key: 'Content', |
108 style: _style, | 120 style: _style, |
109 children: [toolbar, new Stocklist(stocks: _sortedStocks)] | 121 children: [toolbar, new Stocklist(stocks: _sortedStocks)] |
110 ), | 122 ), |
111 fab, | 123 fab, |
112 drawer, | 124 drawer, |
113 ] | 125 ] |
114 ); | 126 ); |
115 } | 127 } |
116 } | 128 } |
OLD | NEW |