| OLD | NEW |
| (Empty) |
| 1 part of stocksapp; | |
| 2 | |
| 3 class StockRow extends Component { | |
| 4 | |
| 5 Stock stock; | |
| 6 | |
| 7 static Style _style = new Style(''' | |
| 8 transform: translateX(0); | |
| 9 display: flex; | |
| 10 align-items: center; | |
| 11 border-bottom: 1px solid #F4F4F4; | |
| 12 padding-top: 16px; | |
| 13 padding-left: 16px; | |
| 14 padding-right: 16px; | |
| 15 padding-bottom: 20px;''' | |
| 16 ); | |
| 17 | |
| 18 static Style _tickerStyle = new Style(''' | |
| 19 flex: 1;''' | |
| 20 ); | |
| 21 | |
| 22 static Style _lastSaleStyle = new Style(''' | |
| 23 text-align: right; | |
| 24 padding-right: 16px;''' | |
| 25 ); | |
| 26 | |
| 27 static Style _changeStyle = new Style(''' | |
| 28 ${typography.black.caption}; | |
| 29 text-align: right;''' | |
| 30 ); | |
| 31 | |
| 32 StockRow({Stock stock}) : super(key: stock.symbol) { | |
| 33 this.stock = stock; | |
| 34 } | |
| 35 | |
| 36 Node build() { | |
| 37 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | |
| 38 | |
| 39 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | |
| 40 if (stock.percentChange > 0) | |
| 41 changeInPrice = "+" + changeInPrice; | |
| 42 | |
| 43 List<Node> children = [ | |
| 44 new StockArrow( | |
| 45 percentChange: stock.percentChange | |
| 46 ), | |
| 47 new Container( | |
| 48 key: 'Ticker', | |
| 49 style: _tickerStyle, | |
| 50 children: [new Text(stock.symbol)] | |
| 51 ), | |
| 52 new Container( | |
| 53 key: 'LastSale', | |
| 54 style: _lastSaleStyle, | |
| 55 children: [new Text(lastSale)] | |
| 56 ), | |
| 57 new Container( | |
| 58 key: 'Change', | |
| 59 style: _changeStyle, | |
| 60 children: [new Text(changeInPrice)] | |
| 61 ) | |
| 62 ]; | |
| 63 | |
| 64 return new Material( | |
| 65 style: _style, | |
| 66 children: children | |
| 67 ); | |
| 68 } | |
| 69 } | |
| OLD | NEW |