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

Unified Diff: sky/sdk/lib/widgets/block_viewport.dart

Issue 1227823012: Move VariableHeightScrollable to sdk/lib/widgets (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
Index: sky/sdk/lib/widgets/block_viewport.dart
diff --git a/sky/sdk/lib/widgets/block_viewport.dart b/sky/sdk/lib/widgets/block_viewport.dart
index 8aa0f0c3756dd5379739ca19977e2cf0cc7417af..c3d7ddc2417292dfbb6d5765d9ff13859f479b94 100644
--- a/sky/sdk/lib/widgets/block_viewport.dart
+++ b/sky/sdk/lib/widgets/block_viewport.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'dart:collection';
+
import '../rendering/block.dart';
import '../rendering/box.dart';
import '../rendering/object.dart';
@@ -10,6 +12,11 @@ import 'widget.dart';
// return null if index is greater than index of last entry
typedef Widget IndexedBuilder(int index);
+typedef void LayoutChangedCallback(
+ int firstVisibleItemIndex,
+ int visibleItemCount,
+ UnmodifiableListView<double> itemOffsets);
+
class _Key {
const _Key(this.type, this.key);
factory _Key.fromWidget(Widget widget) => new _Key(widget.runtimeType, widget.key);
@@ -20,12 +27,13 @@ class _Key {
}
class BlockViewport extends RenderObjectWrapper {
- BlockViewport({ this.builder, this.startOffset, this.token, String key })
+ BlockViewport({ this.builder, this.startOffset, this.token, this.onLayoutChanged, String key })
: super(key: key);
IndexedBuilder builder;
double startOffset;
Object token;
+ LayoutChangedCallback onLayoutChanged;
RenderBlockViewport get root => super.root;
RenderBlockViewport createNode() => new RenderBlockViewport();
@@ -287,6 +295,9 @@ class BlockViewport extends RenderObjectWrapper {
_childrenByKey = newChildren;
_currentStartIndex = startIndex;
_currentChildCount = _childrenByKey.length;
+
+ if (onLayoutChanged != null)
+ onLayoutChanged(_currentStartIndex, _currentChildCount, new UnmodifiableListView<double>(_offsets));
}
}

Powered by Google App Engine
This is Rietveld 408576698