OLD | NEW |
1 part of stocksapp; | 1 part of stocksapp; |
2 | 2 |
3 class StockRow extends MaterialComponent { | 3 class StockRow extends MaterialComponent { |
4 | 4 |
5 Stock stock; | 5 Stock stock; |
6 | 6 |
7 static Style _style = new Style(''' | 7 static Style _style = new Style(''' |
8 transform: translateX(0); | 8 transform: translateX(0); |
9 display: flex; | 9 display: flex; |
10 align-items: center; | 10 align-items: center; |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 static Style _changeStyle = new Style(''' | 28 static Style _changeStyle = new Style(''' |
29 color: #8A8A8A; | 29 color: #8A8A8A; |
30 text-align: right;''' | 30 text-align: right;''' |
31 ); | 31 ); |
32 | 32 |
33 StockRow({Stock stock}) : super(key: stock.symbol) { | 33 StockRow({Stock stock}) : super(key: stock.symbol) { |
34 this.stock = stock; | 34 this.stock = stock; |
35 } | 35 } |
36 | 36 |
37 Node render() { | 37 Node build() { |
38 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | 38 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; |
39 | 39 |
40 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | 40 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; |
41 if (stock.percentChange > 0) | 41 if (stock.percentChange > 0) |
42 changeInPrice = "+" + changeInPrice; | 42 changeInPrice = "+" + changeInPrice; |
43 | 43 |
44 List<Node> children = [ | 44 List<Node> children = [ |
45 new StockArrow( | 45 new StockArrow( |
46 percentChange: stock.percentChange | 46 percentChange: stock.percentChange |
47 ), | 47 ), |
48 new Container( | 48 new Container( |
49 key: 'Ticker', | 49 key: 'Ticker', |
50 style: _tickerStyle, | 50 style: _tickerStyle, |
51 children: [new Text(stock.symbol)] | 51 children: [new Text(stock.symbol)] |
52 ), | 52 ), |
53 new Container( | 53 new Container( |
54 key: 'LastSale', | 54 key: 'LastSale', |
55 style: _lastSaleStyle, | 55 style: _lastSaleStyle, |
56 children: [new Text(lastSale)] | 56 children: [new Text(lastSale)] |
57 ), | 57 ), |
58 new Container( | 58 new Container( |
59 key: 'Change', | 59 key: 'Change', |
60 style: _changeStyle, | 60 style: _changeStyle, |
61 children: [new Text(changeInPrice)] | 61 children: [new Text(changeInPrice)] |
62 ) | 62 ) |
63 ]; | 63 ]; |
64 | 64 |
65 children.add(super.render()); | 65 children.add(super.build()); |
66 | 66 |
67 return new Container( | 67 return new Container( |
68 style: _style, | 68 style: _style, |
69 children: children | 69 children: children |
70 ); | 70 ); |
71 } | 71 } |
72 } | 72 } |
OLD | NEW |