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

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

Issue 974903005: attempt at making menuitems react (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rationalise my local client and upload the result 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/drawer.dart ('k') | sky/examples/fn/widgets/menuitem.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 render() {
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 onScrollStart: _cancelSplashes,
30 onWheel: _cancelSplashes,
31 onPointerDown: _startSplash,
32 children: children,
33 key: _splashesKey
34 );
35 }
36
37 sky.ClientRect _getBoundingRect() => getRoot().getBoundingClientRect();
38
39 void _startSplash(sky.Event event) {
40 setState(() {
41 if (_splashes == null) {
42 _splashes = new LinkedHashSet<SplashAnimation>();
43 }
44
45 var splash;
46 splash = new SplashAnimation(_getBoundingRect(), event.x, event.y,
47 onDone: () { _splashDone(splash); });
48
49 _splashes.add(splash);
50 });
51 }
52
53 void _cancelSplashes(sky.Event event) {
54 if (_splashes == null) {
55 return;
56 }
57
58 setState(() {
59 var splashes = _splashes;
60 _splashes = null;
61 splashes.forEach((s) { s.cancel(); });
62 });
63 }
64
65 void willUnmount() {
66 _cancelSplashes(null);
67 }
68
69 void _splashDone(SplashAnimation splash) {
70 if (_splashes == null) {
71 return;
72 }
73
74 setState(() {
75 _splashes.remove(splash);
76 if (_splashes.length == 0) {
77 _splashes = null;
78 }
79 });
80 }
81 }
OLDNEW
« no previous file with comments | « sky/examples/fn/widgets/drawer.dart ('k') | sky/examples/fn/widgets/menuitem.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698