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

Side by Side Diff: sky/sdk/lib/widgets/fixed_height_scrollable.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/drawer.dart ('k') | sky/sdk/lib/widgets/popup_menu.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 6
7 import 'package:vector_math/vector_math.dart';
8
9 import '../animation/scroll_behavior.dart'; 7 import '../animation/scroll_behavior.dart';
10 import 'basic.dart'; 8 import 'basic.dart';
11 import 'scrollable.dart'; 9 import 'scrollable.dart';
12 10
13 abstract class FixedHeightScrollable extends Scrollable { 11 abstract class FixedHeightScrollable extends Scrollable {
14 12
15 FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, th is.padding }) 13 FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, th is.padding })
16 : super(key: key, backgroundColor: backgroundColor) { 14 : super(key: key, backgroundColor: backgroundColor) {
17 assert(itemHeight != null); 15 assert(itemHeight != null);
18 } 16 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 settleScrollOffset(); 52 settleScrollOffset();
55 } 53 }
56 54
57 Widget buildContent() { 55 Widget buildContent() {
58 if (itemCount != _previousItemCount) { 56 if (itemCount != _previousItemCount) {
59 _previousItemCount = itemCount; 57 _previousItemCount = itemCount;
60 _updateContentsHeight(); 58 _updateContentsHeight();
61 _updateScrollOffset(); 59 _updateScrollOffset();
62 } 60 }
63 61
64 var itemShowIndex = 0; 62 int itemShowIndex = 0;
65 var itemShowCount = 0; 63 int itemShowCount = 0;
66 Matrix4 transform = new Matrix4.identity(); 64
65 double offsetY = 0.0;
67 66
68 if (_height != null && _height > 0.0) { 67 if (_height != null && _height > 0.0) {
69 if (scrollOffset < 0.0) { 68 if (scrollOffset < 0.0) {
70 double visibleHeight = _height + scrollOffset; 69 double visibleHeight = _height + scrollOffset;
71 itemShowCount = (visibleHeight / itemHeight).round() + 1; 70 itemShowCount = (visibleHeight / itemHeight).round() + 1;
72 transform.translate(0.0, -scrollOffset); 71 offsetY = scrollOffset;
73 } else { 72 } else {
74 itemShowCount = (_height / itemHeight).ceil() + 1; 73 itemShowCount = (_height / itemHeight).ceil() + 1;
75 double alignmentDelta = -scrollOffset % itemHeight; 74 double alignmentDelta = -scrollOffset % itemHeight;
76 if (alignmentDelta != 0.0) 75 if (alignmentDelta != 0.0)
77 alignmentDelta -= itemHeight; 76 alignmentDelta -= itemHeight;
78 77
79 double drawStart = scrollOffset + alignmentDelta; 78 double drawStart = scrollOffset + alignmentDelta;
80 itemShowIndex = math.max(0, (drawStart / itemHeight).floor()); 79 itemShowIndex = math.max(0, (drawStart / itemHeight).floor());
81 80
82 transform.translate(0.0, alignmentDelta); 81 offsetY = -alignmentDelta;
83 } 82 }
84 } 83 }
85 84
86 List<Widget> items = buildItems(itemShowIndex, itemShowCount); 85 List<Widget> items = buildItems(itemShowIndex, itemShowCount);
87 assert(items.every((item) => item.key != null)); 86 assert(items.every((item) => item.key != null));
88 87
89 return new SizeObserver( 88 return new SizeObserver(
90 callback: _handleSizeChanged, 89 callback: _handleSizeChanged,
91 child: new ClipRect( 90 child: new Viewport(
92 child: new Transform( 91 offset: offsetY,
93 transform: transform, 92 child: new Container(
94 child: new Container( 93 padding: padding,
95 padding: padding, 94 child: new Block(items)
96 child: new Block(items)
97 )
98 ) 95 )
99 ) 96 )
100 ); 97 );
101 } 98 }
102 99
103 List<Widget> buildItems(int start, int count); 100 List<Widget> buildItems(int start, int count);
104 101
105 } 102 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/drawer.dart ('k') | sky/sdk/lib/widgets/popup_menu.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698