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

Unified Diff: sky/examples/stocks-fn/stocksapp.dart

Issue 1002453003: Make Stocks app search actually search (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « sky/examples/stocks-fn/stocklist.dart ('k') | sky/framework/components/input.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « sky/examples/stocks-fn/stocklist.dart ('k') | sky/framework/components/input.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698