Index: sky/examples/stocks-fn/stocksapp.dart |
diff --git a/sky/examples/stocks-fn/stocksapp.dart b/sky/examples/stocks-fn/stocksapp.dart |
index 16333e06267b2a29d1d4ad335f2820cd5d0c5f45..77cb6ef4e6c7cd9617ca359d9937172e78c0dc97 100644 |
--- a/sky/examples/stocks-fn/stocksapp.dart |
+++ b/sky/examples/stocks-fn/stocksapp.dart |
@@ -42,6 +42,7 @@ class StocksApp extends App { |
List<Stock> _sortedStocks; |
bool _isSearching = false; |
+ String _searchQuery; |
StocksApp() : super() { |
_sortedStocks = oracle.stocks; |
@@ -54,6 +55,12 @@ class StocksApp extends App { |
}); |
} |
+ void _handleSearchQueryChanged(query) { |
+ setState(() { |
+ _searchQuery = query; |
+ }); |
+ } |
+ |
Node build() { |
var drawer = new Drawer( |
animation: _drawerAnimation, |
@@ -86,9 +93,13 @@ class StocksApp extends App { |
] |
); |
- Node title = _isSearching |
- ? new Input(focused: true, placeholder: 'Search stocks') |
- : new Text('I am a stocks app'); |
+ Node title; |
+ if (_isSearching) { |
+ title = new Input(focused: true, placeholder: 'Search stocks', |
+ onChanged: _handleSearchQueryChanged); |
+ } else { |
+ title = new Text('I am a stocks app'); |
+ } |
var toolbar = new Toolbar( |
children: [ |
@@ -110,6 +121,8 @@ class StocksApp extends App { |
] |
); |
+ var list = new Stocklist(stocks: _sortedStocks, query: _searchQuery); |
+ |
var fab = new FloatingActionButton(content: new Icon( |
type: 'content/add_white', size: 24)); |
@@ -119,7 +132,7 @@ class StocksApp extends App { |
new Container( |
key: 'Content', |
style: _style, |
- children: [toolbar, new Stocklist(stocks: _sortedStocks)] |
+ children: [toolbar, list] |
), |
fab, |
drawer, |