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

Unified Diff: sky/sdk/example/stocks/lib/stock_home.dart

Issue 1219933004: Make it harder to forget itemCount for FixedHeightScrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address ian's comments Created 5 years, 5 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/sdk/example/demo_launcher/lib/main.dart ('k') | sky/sdk/example/stocks/lib/stock_list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/stocks/lib/stock_home.dart
diff --git a/sky/sdk/example/stocks/lib/stock_home.dart b/sky/sdk/example/stocks/lib/stock_home.dart
index b26e392780a12c3679733448bdf13b034d2e1eb4..7adb18f314a383d8aecb2d861aa9ee5437fcefbb 100644
--- a/sky/sdk/example/stocks/lib/stock_home.dart
+++ b/sky/sdk/example/stocks/lib/stock_home.dart
@@ -164,7 +164,7 @@ class StockHome extends StatefulComponent {
_drawerController.close();
});
}
-
+
Widget buildToolBar() {
return new ToolBar(
left: new IconButton(
@@ -185,18 +185,30 @@ class StockHome extends StatefulComponent {
int selectedTabIndex = 0;
List<String> portfolioSymbols = ["AAPL","FIZZ", "FIVE", "FLAT", "ZINC", "ZNGA"];
+ Iterable<Stock> _filterByPortfolio(Iterable<Stock> stocks) {
+ return stocks.where((stock) => portfolioSymbols.contains(stock.symbol));
+ }
+
+ Iterable<Stock> _filterBySearchQuery(Iterable<Stock> stocks) {
+ if (_searchQuery == null)
+ return stocks;
+ RegExp regexp = new RegExp(_searchQuery, caseSensitive: false);
+ return stocks.where((stock) => stock.symbol.contains(regexp));
+ }
+
+ Widget buildMarketStockList() {
+ return new Stocklist(stocks: _filterBySearchQuery(stocks).toList());
+ }
+
Widget buildPortfolioStocklist() {
- return new Stocklist(
- stocks: stocks.where((s) => portfolioSymbols.contains(s.symbol)).toList(),
- query: _searchQuery
- );
+ return new Stocklist(stocks: _filterBySearchQuery(_filterByPortfolio(stocks)).toList());
}
Widget buildTabNavigator() {
List<TabNavigatorView> views = <TabNavigatorView>[
new TabNavigatorView(
label: const TabLabel(text: 'MARKET'),
- builder: () => new Stocklist(stocks: stocks, query: _searchQuery)
+ builder: buildMarketStockList
),
new TabNavigatorView(
label: const TabLabel(text: 'PORTFOLIO'),
« no previous file with comments | « sky/sdk/example/demo_launcher/lib/main.dart ('k') | sky/sdk/example/stocks/lib/stock_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698