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

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

Issue 1187563006: StockRow height, background color updates (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Plumb background color Created 5 years, 6 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 // 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 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import '../framework/animation/generators.dart'; 8 import '../framework/animation/generators.dart';
9 import '../framework/animation/mechanics.dart'; 9 import '../framework/animation/mechanics.dart';
10 import '../framework/animation/scroll_behavior.dart'; 10 import '../framework/animation/scroll_behavior.dart';
11 import '../theme2/edges.dart'; 11 import '../theme2/edges.dart';
12 import '../theme2/view_configuration.dart' as config; 12 import '../theme2/view_configuration.dart' as config;
13 import 'basic.dart'; 13 import 'basic.dart';
14 import 'material.dart'; 14 import 'material.dart';
15 15
16 const double _kMillisecondsPerSecond = 1000.0; 16 const double _kMillisecondsPerSecond = 1000.0;
17 17
18 double _velocityForFlingGesture(sky.GestureEvent event) { 18 double _velocityForFlingGesture(sky.GestureEvent event) {
19 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, 19 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity,
20 -event.velocityY)) / _kMillisecondsPerSecond; 20 -event.velocityY)) / _kMillisecondsPerSecond;
21 } 21 }
22 22
23 abstract class ScrollClient { 23 abstract class ScrollClient {
24 bool ancestorScrolled(Scrollable ancestor); 24 bool ancestorScrolled(Scrollable ancestor);
25 } 25 }
26 26
27 abstract class Scrollable extends Component { 27 abstract class Scrollable extends Component {
28 28
29 Scrollable({Object key}) : super(key: key, stateful: true); 29 Scrollable({ Object key, Color this.backgroundColor }) : super(key: key, state ful: true);
30 30
31 void syncFields(Scrollable source) { } 31 void syncFields(Scrollable source) { }
Hixie 2015/06/15 17:54:39 You need to sync the background color.
hansmuller 2015/06/15 18:29:08 Done.
32 32
33 Color backgroundColor;
Hixie 2015/06/15 17:54:39 This should go immediately below the constructor.
hansmuller 2015/06/15 18:29:08 Done.
34
33 double _scrollOffset = 0.0; 35 double _scrollOffset = 0.0;
34 double get scrollOffset => _scrollOffset; 36 double get scrollOffset => _scrollOffset;
35 37
36 ScrollBehavior _scrollBehavior; 38 ScrollBehavior _scrollBehavior;
37 ScrollBehavior createScrollBehavior(); 39 ScrollBehavior createScrollBehavior();
38 ScrollBehavior get scrollBehavior { 40 ScrollBehavior get scrollBehavior {
39 if (_scrollBehavior == null) 41 if (_scrollBehavior == null)
40 _scrollBehavior = createScrollBehavior(); 42 _scrollBehavior = createScrollBehavior();
41 return _scrollBehavior; 43 return _scrollBehavior;
42 } 44 }
43 45
44 Simulation _simulation; 46 Simulation _simulation;
45 47
46 UINode buildContent(); 48 UINode buildContent();
47 49
48 UINode build() { 50 UINode build() {
49 return new EventListenerNode( 51 return new EventListenerNode(
50 new Material( 52 new Material(
51 child: buildContent(), 53 child: buildContent(),
52 edge: MaterialEdge.canvas 54 edge: MaterialEdge.canvas,
55 color: backgroundColor
53 ), 56 ),
54 onPointerDown: _handlePointerDown, 57 onPointerDown: _handlePointerDown,
55 onPointerUp: _handlePointerUpOrCancel, 58 onPointerUp: _handlePointerUpOrCancel,
56 onPointerCancel: _handlePointerUpOrCancel, 59 onPointerCancel: _handlePointerUpOrCancel,
57 onGestureFlingStart: _handleFlingStart, 60 onGestureFlingStart: _handleFlingStart,
58 onGestureFlingCancel: _handleFlingCancel, 61 onGestureFlingCancel: _handleFlingCancel,
59 onGestureScrollUpdate: _handleScrollUpdate, 62 onGestureScrollUpdate: _handleScrollUpdate,
60 onWheel: _handleWheel 63 onWheel: _handleWheel
61 ); 64 );
62 } 65 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 152
150 void _handleFlingCancel(sky.GestureEvent event) { 153 void _handleFlingCancel(sky.GestureEvent event) {
151 _startSimulation(_createParticle()); 154 _startSimulation(_createParticle());
152 } 155 }
153 156
154 void _handleWheel(sky.WheelEvent event) { 157 void _handleWheel(sky.WheelEvent event) {
155 scrollBy(-event.offsetY); 158 scrollBy(-event.offsetY);
156 } 159 }
157 160
158 } 161 }
OLDNEW
« sky/examples/stocks2/lib/stock_row.dart ('K') | « sky/sdk/lib/widgets/fixed_height_scrollable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698