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

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

Issue 993033003: Move example fn widgets into sky/framework/components (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « sky/examples/fn/widgets/inksplash.dart ('k') | sky/examples/fn/widgets/menudivider.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 part of widgets;
2
3 abstract class MaterialComponent extends Component {
4
5 static const _splashesKey = const Object();
6
7 static Style _style = new Style('''
8 transform: translateX(0);
9 position: absolute;
10 top: 0;
11 left: 0;
12 right: 0;
13 bottom: 0'''
14 );
15
16 LinkedHashSet<SplashAnimation> _splashes;
17
18 MaterialComponent({ Object key }) : super(key: key);
19
20 Node build() {
21 List<Node> children = [];
22
23 if (_splashes != null) {
24 children.addAll(_splashes.map((s) => new InkSplash(s.onStyleChanged)));
25 }
26
27 return new Container(
28 style: _style,
29 children: children,
30 key: _splashesKey
31 )..events.listen('gesturescrollstart', _cancelSplashes)
32 ..events.listen('wheel', _cancelSplashes)
33 ..events.listen('pointerdown', _startSplash);
34 }
35
36 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli entRect();
37
38 void _startSplash(sky.PointerEvent event) {
39 setState(() {
40 if (_splashes == null) {
41 _splashes = new LinkedHashSet<SplashAnimation>();
42 }
43
44 var splash;
45 splash = new SplashAnimation(_getBoundingRect(), event.x, event.y,
46 onDone: () { _splashDone(splash); });
47
48 _splashes.add(splash);
49 });
50 }
51
52 void _cancelSplashes(sky.Event event) {
53 if (_splashes == null) {
54 return;
55 }
56
57 setState(() {
58 var splashes = _splashes;
59 _splashes = null;
60 splashes.forEach((s) { s.cancel(); });
61 });
62 }
63
64 void didUnmount() {
65 _cancelSplashes(null);
66 }
67
68 void _splashDone(SplashAnimation splash) {
69 if (_splashes == null) {
70 return;
71 }
72
73 setState(() {
74 _splashes.remove(splash);
75 if (_splashes.length == 0) {
76 _splashes = null;
77 }
78 });
79 }
80 }
OLDNEW
« no previous file with comments | « sky/examples/fn/widgets/inksplash.dart ('k') | sky/examples/fn/widgets/menudivider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698