OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
6 | 6 |
7 import 'package:sky/framework/rendering/box.dart'; | 7 import 'package:sky/framework/rendering/box.dart'; |
| 8 import 'package:sky/framework/theme2/typography.dart' as typography; |
| 9 import 'package:sky/framework/widgets/ink_well.dart'; |
8 import 'package:sky/framework/widgets/wrappers.dart'; | 10 import 'package:sky/framework/widgets/wrappers.dart'; |
9 import 'package:sky/framework/widgets/ink_well.dart'; | |
10 | 11 |
11 import 'stock_arrow.dart'; | 12 import 'stock_arrow.dart'; |
12 import 'stock_data.dart'; | 13 import 'stock_data.dart'; |
13 | 14 |
14 class StockRow extends Component { | 15 class StockRow extends Component { |
15 | 16 |
16 StockRow({ Stock stock }) : this.stock = stock, super(key: stock.symbol); | 17 StockRow({ Stock stock }) : this.stock = stock, super(key: stock.symbol); |
17 | 18 |
18 final Stock stock; | 19 final Stock stock; |
19 | 20 |
20 static const double kHeight = 70.0; | 21 static const double kHeight = 70.0; |
21 | 22 |
22 UINode build() { | 23 UINode build() { |
23 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | 24 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; |
24 | 25 |
25 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | 26 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; |
26 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; | 27 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; |
27 | 28 |
28 List<UINode> children = [ | 29 List<UINode> children = [ |
29 new Container( | 30 new Container( |
30 child: new StockArrow(percentChange: stock.percentChange), | 31 child: new StockArrow(percentChange: stock.percentChange), |
31 margin: const EdgeDims.only(right: 5.0)), | 32 margin: const EdgeDims.only(right: 5.0)), |
32 new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"), | 33 new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"), |
33 // TODO(hansmuller): text-align: right | 34 // TODO(hansmuller): text-align: right |
34 new FlexExpandingChild(new Text(lastSale), key: "lastSale"), | 35 new FlexExpandingChild(new Text(lastSale), key: "lastSale"), |
35 // TODO(hansmuller): text-align: right, ${typography.black.caption}; | 36 // TODO(hansmuller): text-align: right, ${typography.black.caption}; |
36 new FlexExpandingChild(new Text(changeInPrice), key: "changeInPrice") | 37 new FlexExpandingChild(new Text(changeInPrice, |
| 38 style: typography.black.caption), |
| 39 key: "changeInPrice") |
37 ]; | 40 ]; |
38 | 41 |
39 // TODO(hansmuller): An explicit |height| shouldn't be needed | 42 // TODO(hansmuller): An explicit |height| shouldn't be needed |
40 return new InkWell(children: [ | 43 return new InkWell(children: [ |
41 new Container( | 44 new Container( |
42 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), | 45 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), |
43 height: kHeight, | 46 height: kHeight, |
44 decoration: const BoxDecoration( | 47 decoration: const BoxDecoration( |
45 border: const Border( | 48 border: const Border( |
46 bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))), | 49 bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))), |
47 child: new Flex(children) | 50 child: new Flex(children) |
48 ) | 51 ) |
49 ]); | 52 ]); |
50 } | 53 } |
51 } | 54 } |
OLD | NEW |