| OLD | NEW |
| 1 part of stocksapp; | 1 part of stocksapp; |
| 2 | 2 |
| 3 class StockRow extends Component { | 3 class StockRow extends MaterialComponent { |
| 4 | 4 |
| 5 Stock stock; | 5 Stock stock; |
| 6 LinkedHashSet<SplashAnimation> _splashes; | |
| 7 | 6 |
| 8 static Style _style = new Style(''' | 7 static Style _style = new Style(''' |
| 9 transform: translateX(0); | 8 transform: translateX(0); |
| 10 max-height: 48px; | 9 max-height: 48px; |
| 11 display: flex; | 10 display: flex; |
| 12 align-items: center; | 11 align-items: center; |
| 13 border-bottom: 1px solid #F4F4F4; | 12 border-bottom: 1px solid #F4F4F4; |
| 14 padding-top: 16px; | 13 padding-top: 16px; |
| 15 padding-left: 16px; | 14 padding-left: 16px; |
| 16 padding-right: 16px; | 15 padding-right: 16px; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 style: _lastSaleStyle, | 56 style: _lastSaleStyle, |
| 58 children: [new Text(lastSale)] | 57 children: [new Text(lastSale)] |
| 59 ), | 58 ), |
| 60 new Container( | 59 new Container( |
| 61 key: 'Change', | 60 key: 'Change', |
| 62 style: _changeStyle, | 61 style: _changeStyle, |
| 63 children: [new Text(changeInPrice)] | 62 children: [new Text(changeInPrice)] |
| 64 ) | 63 ) |
| 65 ]; | 64 ]; |
| 66 | 65 |
| 67 if (_splashes != null) { | 66 children.add(super.render()); |
| 68 children.addAll(_splashes.map((s) => new InkSplash(s.onStyleChanged))); | |
| 69 } | |
| 70 | 67 |
| 71 return new Container( | 68 return new Container( |
| 72 style: _style, | 69 style: _style, |
| 73 onScrollStart: _cancelSplashes, | |
| 74 onWheel: _cancelSplashes, | |
| 75 onPointerDown: _handlePointerDown, | |
| 76 children: children | 70 children: children |
| 77 ); | 71 ); |
| 78 } | 72 } |
| 79 | |
| 80 sky.ClientRect _getBoundingRect() => getRoot().getBoundingClientRect(); | |
| 81 | |
| 82 void _handlePointerDown(sky.Event event) { | |
| 83 setState(() { | |
| 84 if (_splashes == null) { | |
| 85 _splashes = new LinkedHashSet<SplashAnimation>(); | |
| 86 } | |
| 87 | |
| 88 var splash; | |
| 89 splash = new SplashAnimation(_getBoundingRect(), event.x, event.y, | |
| 90 onDone: () { _splashDone(splash); }); | |
| 91 | |
| 92 _splashes.add(splash); | |
| 93 }); | |
| 94 } | |
| 95 | |
| 96 void _cancelSplashes(sky.Event event) { | |
| 97 if (_splashes == null) { | |
| 98 return; | |
| 99 } | |
| 100 | |
| 101 setState(() { | |
| 102 var splashes = _splashes; | |
| 103 _splashes = null; | |
| 104 splashes.forEach((s) { s.cancel(); }); | |
| 105 }); | |
| 106 } | |
| 107 | |
| 108 void willUnmount() { | |
| 109 _cancelSplashes(null); | |
| 110 } | |
| 111 | |
| 112 void _splashDone(SplashAnimation splash) { | |
| 113 if (_splashes == null) { | |
| 114 return; | |
| 115 } | |
| 116 | |
| 117 setState(() { | |
| 118 _splashes.remove(splash); | |
| 119 if (_splashes.length == 0) { | |
| 120 _splashes = null; | |
| 121 } | |
| 122 }); | |
| 123 } | |
| 124 } | 73 } |
| OLD | NEW |