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

Side by Side Diff: sky/sdk/lib/widgets/scrollable_viewport.dart

Issue 1223153004: Make the drawer, popup menus, dialogs, and settings page scrollable. (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/popup_menu.dart ('k') | sky/tests/examples/stocks-expected.txt » ('j') | 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 '../animation/scroll_behavior.dart';
6 import 'basic.dart';
7 import 'scrollable.dart';
8
9 class ScrollableViewport extends Scrollable {
10
11 ScrollableViewport({ String key, this.child }) : super(key: key);
12
13 Widget child;
14
15 void syncFields(ScrollableViewport source) {
16 child = source.child;
17 super.syncFields(source);
18 }
19
20 ScrollBehavior createScrollBehavior() => new FlingBehavior();
21 FlingBehavior get scrollBehavior => super.scrollBehavior;
22
23 double _viewportHeight = 0.0;
24 double _childHeight = 0.0;
25 void _handleViewportSizeChanged(Size newSize) {
26 setState(() {
27 _viewportHeight = newSize.height;
28 _updateScrollBehaviour();
29 });
30 }
31 void _handleChildSizeChanged(Size newSize) {
32 setState(() {
33 _childHeight = newSize.height;
34 _updateScrollBehaviour();
35 });
36 }
37 void _updateScrollBehaviour() {
38 scrollBehavior.contentsSize = _childHeight;
39 scrollBehavior.containerSize = _viewportHeight;
40 if (scrollOffset > scrollBehavior.maxScrollOffset)
41 settleScrollOffset();
42 }
43
44 Widget buildContent() {
45 return new SizeObserver(
46 callback: _handleViewportSizeChanged,
47 child: new Viewport(
48 offset: scrollOffset,
49 child: new SizeObserver(
50 callback: _handleChildSizeChanged,
51 child: child
52 )
53 )
54 );
55 }
56
57 }
58
59 class ScrollableBlock extends Component {
60
61 ScrollableBlock(this.children, { String key }) : super(key: key);
62
63 final List<Widget> children;
64
65 Widget build() {
66 return new ScrollableViewport(
67 child: new Block(children)
68 );
69 }
70
71 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/popup_menu.dart ('k') | sky/tests/examples/stocks-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698