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

Side by Side Diff: sky/sdk/example/stocks/lib/stock_list.dart

Issue 1223863003: Factor ScrollableList out of StockList (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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/widgets/fixed_height_scrollable.dart'; 5 import 'package:sky/widgets/scrollable_list.dart';
6 import 'package:sky/widgets/basic.dart'; 6 import 'package:sky/widgets/basic.dart';
7 7
8 import 'stock_data.dart'; 8 import 'stock_data.dart';
9 import 'stock_row.dart'; 9 import 'stock_row.dart';
10 10
11 class Stocklist extends FixedHeightScrollable { 11 class Stocklist extends Component {
12 Stocklist({ String key, this.stocks }) : super(key: key);
12 13
13 Stocklist({ String key, this.stocks }) 14 final List<Stock> stocks;
14 : super(itemHeight: StockRow.kHeight, key: key);
15 15
16 List<Stock> stocks; 16 Widget build() {
17 17 return new ScrollableList<Stock>(
18 int get itemCount => stocks.length; 18 items: stocks,
19 19 itemHeight: StockRow.kHeight,
20 void syncFields(Stocklist source) { 20 itemBuilder: (stock) => new StockRow(stock: stock)
21 stocks = source.stocks; 21 );
22 super.syncFields(source);
23 }
24
25 List<Widget> buildItems(int start, int count) {
26 return stocks
27 .skip(start)
28 .take(count)
29 .map((stock) => new StockRow(stock: stock))
30 .toList(growable: false);
31 } 22 }
32 } 23 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698