OLD | NEW |
1 part of stocksapp; | 1 part of stocksapp; |
2 | 2 |
3 class StockArrow extends Component { | 3 class StockArrow extends Component { |
4 | 4 |
5 double percentChange; | 5 double percentChange; |
6 | 6 |
7 static Style _style = new Style(''' | 7 static Style _style = new Style(''' |
8 width: 40px; | 8 width: 40px; |
9 height: 40px; | 9 height: 40px; |
10 display: flex; | 10 display: flex; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 double maxPercent = 10.0; | 60 double maxPercent = 10.0; |
61 return max(0, ((percentChange.abs() / maxPercent) * _kGreenColors.length).fl
oor()); | 61 return max(0, ((percentChange.abs() / maxPercent) * _kGreenColors.length).fl
oor()); |
62 } | 62 } |
63 | 63 |
64 String _colorForPercentChange(double percentChange) { | 64 String _colorForPercentChange(double percentChange) { |
65 if (percentChange > 0) | 65 if (percentChange > 0) |
66 return _kGreenColors[_colorIndexForPercentChange(percentChange)]; | 66 return _kGreenColors[_colorIndexForPercentChange(percentChange)]; |
67 return _kRedColors[_colorIndexForPercentChange(percentChange)]; | 67 return _kRedColors[_colorIndexForPercentChange(percentChange)]; |
68 } | 68 } |
69 | 69 |
70 Node render() { | 70 Node build() { |
71 String border = _colorForPercentChange(percentChange).toString(); | 71 String border = _colorForPercentChange(percentChange).toString(); |
72 bool up = percentChange > 0; | 72 bool up = percentChange > 0; |
73 String type = up ? 'bottom' : 'top'; | 73 String type = up ? 'bottom' : 'top'; |
74 | 74 |
75 return new Container( | 75 return new Container( |
76 inlineStyle: 'border-color: $border', | 76 inlineStyle: 'border-color: $border', |
77 style: _style, | 77 style: _style, |
78 children: [ | 78 children: [ |
79 new Container( | 79 new Container( |
80 inlineStyle: 'border-$type-color: $border', | 80 inlineStyle: 'border-$type-color: $border', |
81 style: up ? _upStyle : _downStyle | 81 style: up ? _upStyle : _downStyle |
82 ) | 82 ) |
83 ] | 83 ] |
84 ); | 84 ); |
85 } | 85 } |
86 } | 86 } |
OLD | NEW |