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

Side by Side Diff: sky/examples/fn/widgets/fixedheightscrollable.dart

Issue 992033002: Change the name of Component.render to Component.build in Effen (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: README Created 5 years, 9 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
1 part of widgets; 1 part of widgets;
2 2
3 abstract class FixedHeightScrollable extends Component { 3 abstract class FixedHeightScrollable extends Component {
4 4
5 // TODO(rafaelw): This component really shouldn't have an opinion 5 // TODO(rafaelw): This component really shouldn't have an opinion
6 // about how it is sized. The owning component should decide whether 6 // about how it is sized. The owning component should decide whether
7 // it's explicitly sized or flexible or whatever... 7 // it's explicitly sized or flexible or whatever...
8 static Style _style = new Style(''' 8 static Style _style = new Style('''
9 overflow: hidden; 9 overflow: hidden;
10 position: relative; 10 position: relative;
(...skipping 14 matching lines...) Expand all
25 int _flingAnimationId; 25 int _flingAnimationId;
26 double _height = 0.0; 26 double _height = 0.0;
27 double _itemHeight; 27 double _itemHeight;
28 28
29 FixedHeightScrollable({ 29 FixedHeightScrollable({
30 Object key, 30 Object key,
31 this.minOffset, 31 this.minOffset,
32 this.maxOffset 32 this.maxOffset
33 }) : super(key: key) {} 33 }) : super(key: key) {}
34 34
35 List<Node> renderItems(int start, int count); 35 List<Node> buildItems(int start, int count);
36 36
37 void didMount() { 37 void didMount() {
38 var root = getRoot(); 38 var root = getRoot();
39 var item = root.firstChild.firstChild; 39 var item = root.firstChild.firstChild;
40 sky.ClientRect scrollRect = root.getBoundingClientRect(); 40 sky.ClientRect scrollRect = root.getBoundingClientRect();
41 sky.ClientRect itemRect = item.getBoundingClientRect(); 41 sky.ClientRect itemRect = item.getBoundingClientRect();
42 assert(scrollRect.height > 0); 42 assert(scrollRect.height > 0);
43 assert(itemRect.height > 0); 43 assert(itemRect.height > 0);
44 44
45 setState(() { 45 setState(() {
46 _height = scrollRect.height; 46 _height = scrollRect.height;
47 _itemHeight = itemRect.height; 47 _itemHeight = itemRect.height;
48 }); 48 });
49 } 49 }
50 50
51 Node render() { 51 Node build() {
52 var itemNumber = 0; 52 var itemNumber = 0;
53 var drawCount = 1; 53 var drawCount = 1;
54 var transformStyle = ''; 54 var transformStyle = '';
55 55
56 if (_height > 0.0) { 56 if (_height > 0.0) {
57 drawCount = (_height / _itemHeight).round() + 1; 57 drawCount = (_height / _itemHeight).round() + 1;
58 double alignmentDelta = -_scrollOffset % _itemHeight; 58 double alignmentDelta = -_scrollOffset % _itemHeight;
59 if (alignmentDelta != 0.0) { 59 if (alignmentDelta != 0.0) {
60 alignmentDelta -= _itemHeight; 60 alignmentDelta -= _itemHeight;
61 } 61 }
62 62
63 double drawStart = _scrollOffset + alignmentDelta; 63 double drawStart = _scrollOffset + alignmentDelta;
64 itemNumber = (drawStart / _itemHeight).floor(); 64 itemNumber = (drawStart / _itemHeight).floor();
65 65
66 transformStyle = 66 transformStyle =
67 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)'; 67 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)';
68 } 68 }
69 69
70 return new Container( 70 return new Container(
71 style: _style, 71 style: _style,
72 children: [ 72 children: [
73 new Container( 73 new Container(
74 style: _scrollAreaStyle, 74 style: _scrollAreaStyle,
75 inlineStyle: transformStyle, 75 inlineStyle: transformStyle,
76 children: renderItems(itemNumber, drawCount) 76 children: buildItems(itemNumber, drawCount)
77 ) 77 )
78 ] 78 ]
79 ) 79 )
80 ..events.listen('gestureflingstart', _handleFlingStart) 80 ..events.listen('gestureflingstart', _handleFlingStart)
81 ..events.listen('gestureflingcancel', _handleFlingCancel) 81 ..events.listen('gestureflingcancel', _handleFlingCancel)
82 ..events.listen('gesturescrollupdate', _handleScrollUpdate) 82 ..events.listen('gesturescrollupdate', _handleScrollUpdate)
83 ..events.listen('wheel', _handleWheel); 83 ..events.listen('wheel', _handleWheel);
84 } 84 }
85 85
86 void didUnmount() { 86 void didUnmount() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 void _handleFlingCancel(sky.GestureEvent event) { 139 void _handleFlingCancel(sky.GestureEvent event) {
140 _stopFling(); 140 _stopFling();
141 } 141 }
142 142
143 void _handleWheel(sky.WheelEvent event) { 143 void _handleWheel(sky.WheelEvent event) {
144 _scrollBy(-event.offsetY); 144 _scrollBy(-event.offsetY);
145 } 145 }
146 } 146 }
OLDNEW
« no previous file with comments | « sky/examples/fn/widgets/drawerheader.dart ('k') | sky/examples/fn/widgets/floating_action_button.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698