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

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
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:math' as math;
6
7 import '../animation/scroll_behavior.dart';
8 import 'basic.dart';
9 import 'scrollable.dart';
10
11 class ScrollableViewport extends Scrollable {
12
13 ScrollableViewport({ String key, this.child }) : super(key: key);
14
15 Widget child;
16
17 void syncFields(ScrollableViewport source) {
18 child = source.child;
19 super.syncFields(source);
20 }
21
22 ScrollBehavior createScrollBehavior() => new BoundedScrollBehavior();
23 BoundedScrollBehavior get scrollBehavior => super.scrollBehavior;
24
25 double _viewportHeight = 0.0;
26 double _childHeight = 0.0;
27 void _handleViewportSizeChanged(Size newSize) {
28 setState(() {
29 _viewportHeight = newSize.height;
30 updateScrollBehaviour();
31 });
32 }
33 void _handleChildSizeChanged(Size newSize) {
34 setState(() {
35 _childHeight = newSize.height;
36 updateScrollBehaviour();
37 });
38 }
39 void updateScrollBehaviour() {
40 scrollBehavior.maxOffset = math.max(0.0, _childHeight - _viewportHeight);
41 }
abarth-chromium 2015/07/09 23:39:35 You need to check scrollOffset to see if its out-o
42
43 Widget buildContent() {
44 return new SizeObserver(
45 callback: _handleViewportSizeChanged,
46 child: new Viewport(
47 offset: scrollOffset,
48 child: new SizeObserver(
49 callback: _handleChildSizeChanged,
50 child: child
51 )
52 )
53 );
54 }
55
56 }
OLDNEW
« sky/sdk/lib/rendering/object.dart ('K') | « sky/sdk/lib/widgets/popup_menu.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698