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

Unified Diff: sky/sdk/lib/widgets/fixed_height_scrollable.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/stocks/lib/stock_list.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/fixed_height_scrollable.dart
diff --git a/sky/sdk/lib/widgets/fixed_height_scrollable.dart b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
index 1a0997cf7f1ce1e7f1971e643ce2fda49c1b65f9..81cdb20cc9b8c82926eb107271572e3f1eeee935 100644
--- a/sky/sdk/lib/widgets/fixed_height_scrollable.dart
+++ b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
@@ -12,16 +12,20 @@ import 'scrollable.dart';
abstract class FixedHeightScrollable extends Scrollable {
- final EdgeDims padding;
-
FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, this.padding })
: super(key: key, backgroundColor: backgroundColor) {
assert(itemHeight != null);
}
+ EdgeDims padding;
double itemHeight;
+ /// Subclasses must implement `get itemCount` to tell FixedHeightScrollable
+ /// how many items there are in the list.
+ int get itemCount;
+
void syncFields(FixedHeightScrollable source) {
+ padding = source.padding;
itemHeight = source.itemHeight;
super.syncFields(source);
}
@@ -29,18 +33,6 @@ abstract class FixedHeightScrollable extends Scrollable {
ScrollBehavior createScrollBehavior() => new OverscrollBehavior();
OverscrollBehavior get scrollBehavior => super.scrollBehavior;
- int _itemCount = 0;
- int get itemCount => _itemCount;
- void set itemCount (int value) {
- if (_itemCount != value) {
- _itemCount = value;
- double contentsHeight = itemHeight * _itemCount;
- if (padding != null)
- contentsHeight += padding.top + padding.bottom;
- scrollBehavior.contentsHeight = contentsHeight;
- }
- }
-
double _height;
void _handleSizeChanged(Size newSize) {
setState(() {
@@ -57,10 +49,18 @@ abstract class FixedHeightScrollable extends Scrollable {
return super.scrollTo(newScrollOffset);
}
+ void _updateContentsHeight() {
+ double contentsHeight = itemHeight * itemCount;
+ if (padding != null)
+ contentsHeight += padding.top + padding.bottom;
+ scrollBehavior.contentsHeight = contentsHeight;
+ }
+
Widget buildContent() {
+ _updateContentsHeight();
+
var itemShowIndex = 0;
var itemShowCount = 0;
-
Matrix4 transform = new Matrix4.identity();
if (_height != null && _height > 0.0) {
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698