| 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 LinkedHashSet<SplashController> _splashes; | 11 LinkedHashSet<SplashController> _splashes; |
| 12 | 12 |
| 13 Style style; | 13 Style style; |
| 14 String inlineStyle; | 14 String inlineStyle; |
| 15 List<Node> children; | 15 List<Node> children; |
| 16 | 16 |
| 17 InkWell({ Object key, this.style, this.inlineStyle, this.children }) | 17 InkWell({ Object key, this.style, this.inlineStyle, this.children }) |
| 18 : super(key: key); | 18 : super(key: key) { |
| 19 onDidUnmount(() { |
| 20 _cancelSplashes(null); |
| 21 }); |
| 22 } |
| 19 | 23 |
| 20 Node build() { | 24 Node build() { |
| 21 List<Node> childrenIncludingSplashes = []; | 25 List<Node> childrenIncludingSplashes = []; |
| 22 | 26 |
| 23 if (_splashes != null) { | 27 if (_splashes != null) { |
| 24 childrenIncludingSplashes.addAll( | 28 childrenIncludingSplashes.addAll( |
| 25 _splashes.map((s) => new InkSplash(s.onStyleChanged))); | 29 _splashes.map((s) => new InkSplash(s.onStyleChanged))); |
| 26 } | 30 } |
| 27 | 31 |
| 28 if (children != null) | 32 if (children != null) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 void _cancelSplashes(sky.Event event) { | 66 void _cancelSplashes(sky.Event event) { |
| 63 if (_splashes == null) | 67 if (_splashes == null) |
| 64 return; | 68 return; |
| 65 setState(() { | 69 setState(() { |
| 66 var splashes = _splashes; | 70 var splashes = _splashes; |
| 67 _splashes = null; | 71 _splashes = null; |
| 68 splashes.forEach((s) { s.cancel(); }); | 72 splashes.forEach((s) { s.cancel(); }); |
| 69 }); | 73 }); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void didUnmount() { | |
| 73 _cancelSplashes(null); | |
| 74 } | |
| 75 | |
| 76 void _splashDone(SplashController splash) { | 76 void _splashDone(SplashController splash) { |
| 77 if (_splashes == null) | 77 if (_splashes == null) |
| 78 return; | 78 return; |
| 79 setState(() { | 79 setState(() { |
| 80 _splashes.remove(splash); | 80 _splashes.remove(splash); |
| 81 if (_splashes.length == 0) | 81 if (_splashes.length == 0) |
| 82 _splashes = null; | 82 _splashes = null; |
| 83 }); | 83 }); |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |