| OLD | NEW |
| (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 } | |
| OLD | NEW |