| OLD | NEW |
| 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 '../fn.dart'; | 5 import '../fn.dart'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:sky' as sky; | 7 import 'dart:sky' as sky; |
| 8 import 'ink_splash.dart'; | 8 import 'ink_splash.dart'; |
| 9 | 9 |
| 10 class InkWell extends Component { | 10 class InkWell extends Component { |
| 11 static final Style _containmentStyleHack = new Style(''' |
| 12 transform: translateX(0);'''); |
| 13 |
| 11 LinkedHashSet<SplashController> _splashes; | 14 LinkedHashSet<SplashController> _splashes; |
| 12 | 15 |
| 13 Style style; | |
| 14 String inlineStyle; | 16 String inlineStyle; |
| 15 List<Node> children; | 17 List<Node> children; |
| 16 | 18 |
| 17 InkWell({ Object key, this.style, this.inlineStyle, this.children }) | 19 InkWell({ Object key, this.inlineStyle, this.children }) |
| 18 : super(key: key) { | 20 : super(key: key) { |
| 19 onDidUnmount(() { | 21 onDidUnmount(() { |
| 20 _cancelSplashes(null); | 22 _cancelSplashes(null); |
| 21 }); | 23 }); |
| 22 } | 24 } |
| 23 | 25 |
| 24 Node build() { | 26 Node build() { |
| 25 List<Node> childrenIncludingSplashes = []; | 27 List<Node> childrenIncludingSplashes = []; |
| 26 | 28 |
| 27 if (_splashes != null) { | 29 if (_splashes != null) { |
| 28 childrenIncludingSplashes.addAll( | 30 childrenIncludingSplashes.addAll( |
| 29 _splashes.map((s) => new InkSplash(s.onStyleChanged))); | 31 _splashes.map((s) => new InkSplash(s.onStyleChanged))); |
| 30 } | 32 } |
| 31 | 33 |
| 32 if (children != null) | 34 if (children != null) |
| 33 childrenIncludingSplashes.addAll(children); | 35 childrenIncludingSplashes.addAll(children); |
| 34 | 36 |
| 35 return new EventTarget( | 37 return new EventTarget( |
| 36 new Container( | 38 new Container( |
| 37 style: style, | 39 style: _containmentStyleHack, |
| 38 inlineStyle: inlineStyle, | 40 inlineStyle: inlineStyle, |
| 39 children: childrenIncludingSplashes), | 41 children: childrenIncludingSplashes), |
| 40 onGestureTapDown: _startSplash, | 42 onGestureTapDown: _startSplash, |
| 41 onGestureTap: _confirmSplash | 43 onGestureTap: _confirmSplash |
| 42 ); | 44 ); |
| 43 } | 45 } |
| 44 | 46 |
| 45 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli
entRect(); | 47 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli
entRect(); |
| 46 | 48 |
| 47 void _startSplash(sky.GestureEvent event) { | 49 void _startSplash(sky.GestureEvent event) { |
| 48 setState(() { | 50 setState(() { |
| 49 if (_splashes == null) | 51 if (_splashes == null) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 76 void _splashDone(SplashController splash) { | 78 void _splashDone(SplashController splash) { |
| 77 if (_splashes == null) | 79 if (_splashes == null) |
| 78 return; | 80 return; |
| 79 setState(() { | 81 setState(() { |
| 80 _splashes.remove(splash); | 82 _splashes.remove(splash); |
| 81 if (_splashes.length == 0) | 83 if (_splashes.length == 0) |
| 82 _splashes = null; | 84 _splashes = null; |
| 83 }); | 85 }); |
| 84 } | 86 } |
| 85 } | 87 } |
| OLD | NEW |