OLD | NEW |
1 part of stocksapp; | 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 import 'package:sky/framework/components/material.dart'; |
| 6 import 'package:sky/framework/fn.dart'; |
| 7 import 'package:sky/framework/theme/typography.dart' as typography; |
| 8 import 'stock_arrow.dart'; |
| 9 import 'stock_data.dart'; |
2 | 10 |
3 class StockRow extends Component { | 11 class StockRow extends Component { |
4 | 12 static final Style _style = new Style(''' |
5 Stock stock; | |
6 | |
7 static Style _style = new Style(''' | |
8 transform: translateX(0); | 13 transform: translateX(0); |
9 display: flex; | 14 display: flex; |
10 align-items: center; | 15 align-items: center; |
11 border-bottom: 1px solid #F4F4F4; | 16 border-bottom: 1px solid #F4F4F4; |
12 padding-top: 16px; | 17 padding-top: 16px; |
13 padding-left: 16px; | 18 padding-left: 16px; |
14 padding-right: 16px; | 19 padding-right: 16px; |
15 padding-bottom: 20px;''' | 20 padding-bottom: 20px;''' |
16 ); | 21 ); |
17 | 22 |
18 static Style _tickerStyle = new Style(''' | 23 static final Style _tickerStyle = new Style(''' |
19 flex: 1;''' | 24 flex: 1;''' |
20 ); | 25 ); |
21 | 26 |
22 static Style _lastSaleStyle = new Style(''' | 27 static final Style _lastSaleStyle = new Style(''' |
23 text-align: right; | 28 text-align: right; |
24 padding-right: 16px;''' | 29 padding-right: 16px;''' |
25 ); | 30 ); |
26 | 31 |
27 static Style _changeStyle = new Style(''' | 32 static final Style _changeStyle = new Style(''' |
28 ${typography.black.caption}; | 33 ${typography.black.caption}; |
29 text-align: right;''' | 34 text-align: right;''' |
30 ); | 35 ); |
31 | 36 |
| 37 Stock stock; |
| 38 |
32 StockRow({Stock stock}) : super(key: stock.symbol) { | 39 StockRow({Stock stock}) : super(key: stock.symbol) { |
33 this.stock = stock; | 40 this.stock = stock; |
34 } | 41 } |
35 | 42 |
36 Node build() { | 43 Node build() { |
37 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | 44 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; |
38 | 45 |
39 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | 46 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; |
40 if (stock.percentChange > 0) | 47 if (stock.percentChange > 0) |
41 changeInPrice = "+" + changeInPrice; | 48 changeInPrice = "+" + changeInPrice; |
(...skipping 18 matching lines...) Expand all Loading... |
60 children: [new Text(changeInPrice)] | 67 children: [new Text(changeInPrice)] |
61 ) | 68 ) |
62 ]; | 69 ]; |
63 | 70 |
64 return new Material( | 71 return new Material( |
65 style: _style, | 72 style: _style, |
66 children: children | 73 children: children |
67 ); | 74 ); |
68 } | 75 } |
69 } | 76 } |
OLD | NEW |