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

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
« no previous file with comments | « sky/sdk/lib/widgets/block_viewport.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.containerSize = newSize.height;
35 });
36 }
37
38 void _handleLayoutChanged(
39 int firstVisibleChildIndex,
40 int visibleChildCount,
41 UnmodifiableListView<double> childOffsets,
42 bool didReachLastChild) {
43 assert(childOffsets.length > 0);
44 scrollBehavior.contentsSize = didReachLastChild ? childOffsets.last : double .INFINITY;
45 if (didReachLastChild && scrollOffset > scrollBehavior.maxScrollOffset)
46 settleScrollOffset();
47 }
48
49 Widget buildContent() {
50 return new SizeObserver(
51 callback: _handleSizeChanged,
52 child: new BlockViewport(
53 builder: builder,
54 onLayoutChanged: _handleLayoutChanged,
55 startOffset: scrollOffset,
56 token: token
57 )
58 );
59 }
60 }
OLDNEW
« no previous file with comments | « 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