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

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

Issue 1217093005: Refactor stateful parts of Component into StatefulComponent (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase 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/navigator.dart ('k') | sky/sdk/lib/widgets/widget.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:sky' as sky; 5 import 'dart:sky' as sky;
6 6
7 import '../animation/generators.dart'; 7 import '../animation/generators.dart';
8 import '../animation/mechanics.dart'; 8 import '../animation/mechanics.dart';
9 import '../animation/scroll_behavior.dart'; 9 import '../animation/scroll_behavior.dart';
10 import '../theme/view_configuration.dart' as config; 10 import '../theme/view_configuration.dart' as config;
11 import 'basic.dart'; 11 import 'basic.dart';
12 import 'material.dart'; 12 import 'material.dart';
13 13
14 const double _kMillisecondsPerSecond = 1000.0; 14 const double _kMillisecondsPerSecond = 1000.0;
15 15
16 double _velocityForFlingGesture(double eventVelocity) { 16 double _velocityForFlingGesture(double eventVelocity) {
17 return eventVelocity.clamp(-config.kMaxFlingVelocity, config.kMaxFlingVelocity ) / 17 return eventVelocity.clamp(-config.kMaxFlingVelocity, config.kMaxFlingVelocity ) /
18 _kMillisecondsPerSecond; 18 _kMillisecondsPerSecond;
19 } 19 }
20 20
21 abstract class ScrollClient { 21 abstract class ScrollClient {
22 bool ancestorScrolled(Scrollable ancestor); 22 bool ancestorScrolled(Scrollable ancestor);
23 } 23 }
24 24
25 enum ScrollDirection { vertical, horizontal } 25 enum ScrollDirection { vertical, horizontal }
26 26
27 abstract class Scrollable extends Component { 27 abstract class Scrollable extends StatefulComponent {
28 28
29 Scrollable({ 29 Scrollable({
30 String key, 30 String key,
31 this.backgroundColor, 31 this.backgroundColor,
32 this.direction: ScrollDirection.vertical 32 this.direction: ScrollDirection.vertical
33 }) : super(key: key, stateful: true); 33 }) : super(key: key);
34 34
35 Color backgroundColor; 35 Color backgroundColor;
36 ScrollDirection direction; 36 ScrollDirection direction;
37 37
38 void syncFields(Scrollable source) { 38 void syncFields(Scrollable source) {
39 backgroundColor = source.backgroundColor; 39 backgroundColor = source.backgroundColor;
40 direction == source.direction; 40 direction == source.direction;
41 } 41 }
42 42
43 double _scrollOffset = 0.0; 43 double _scrollOffset = 0.0;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 void _handleFlingCancel(sky.GestureEvent event) { 164 void _handleFlingCancel(sky.GestureEvent event) {
165 _startSimulation(_createParticle()); 165 _startSimulation(_createParticle());
166 } 166 }
167 167
168 void _handleWheel(sky.WheelEvent event) { 168 void _handleWheel(sky.WheelEvent event) {
169 scrollBy(-event.offsetY); 169 scrollBy(-event.offsetY);
170 } 170 }
171 171
172 } 172 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/navigator.dart ('k') | sky/sdk/lib/widgets/widget.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698