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

Side by Side Diff: sky/sdk/lib/widgets/variable_height_scrollable.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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:collection';
6
7 import '../animation/scroll_behavior.dart';
8 import 'basic.dart';
9 import 'block_viewport.dart';
10 import 'scrollable.dart';
11 import 'widget.dart';
12
13 class VariableHeightScrollable extends Scrollable {
14 VariableHeightScrollable({
15 String key,
16 this.builder,
17 this.token
18 }) : super(key: key);
19
20 IndexedBuilder builder;
21 Object token;
22
23 void syncFields(VariableHeightScrollable source) {
24 builder = source.builder;
25 token = source.token;
26 super.syncFields(source);
27 }
28
29 ScrollBehavior createScrollBehavior() => new OverscrollBehavior();
30 OverscrollBehavior get scrollBehavior => super.scrollBehavior;
31
32 void _handleSizeChanged(Size newSize) {
33 setState(() {
34 scrollBehavior.containerHeight = newSize.height;
35 });
36 }
37
38 void _handleLayoutChanged(
39 int firstVisibleWidgetIndex,
40 int visibleWidgetCount,
41 UnmodifiableListView<double> widgetOffsets,
42 bool lastWidgetReached) {
43 assert(widgetOffsets.length > 0);
44
45 scrollBehavior.contentsHeight = lastWidgetReached ? widgetOffsets.last : nul l;
46
47 // We don't know the height of all items yet. Grow the ScrollBehavior's
Hixie 2015/07/10 22:51:38 delete comment-out code
hansmuller 2015/07/10 23:42:06 Done.
48 // contentsHeight a little, to accomodate scrolling further.
49 /*
50 if (!lastWidgetReached)
51 scrollBehavior.contentsHeight += scrollBehavior.containerHeight;
52 */
53
54 if (lastWidgetReached && scrollOffset > scrollBehavior.maxScrollOffset)
55 settleScrollOffset();
56 }
57
58 Widget buildContent() {
59 return new SizeObserver(
60 callback: _handleSizeChanged,
61 child: new BlockViewport(
62 builder: builder,
63 onLayoutChanged: _handleLayoutChanged,
64 startOffset: scrollOffset,
65 token: token
66 )
67 );
68 }
69 }
OLDNEW
« sky/sdk/lib/widgets/block_viewport.dart ('K') | « sky/sdk/lib/widgets/block_viewport.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698