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'; | 11 import 'package:sky/framework/rendering/paragraph.dart'; |
10 | 12 |
11 import 'stock_arrow.dart'; | 13 import 'stock_arrow.dart'; |
12 import 'stock_data.dart'; | 14 import 'stock_data.dart'; |
13 | 15 |
14 class StockRow extends Component { | 16 class StockRow extends Component { |
15 | 17 |
16 StockRow({ Stock stock }) : this.stock = stock, super(key: stock.symbol); | 18 StockRow({ Stock stock }) : this.stock = stock, super(key: stock.symbol); |
17 | 19 |
18 final Stock stock; | 20 final Stock stock; |
19 | 21 |
20 static const double kHeight = 70.0; | 22 static const double kHeight = 70.0; |
21 | 23 |
22 UINode build() { | 24 UINode build() { |
23 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | 25 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; |
24 | 26 |
25 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | 27 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; |
26 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; | 28 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; |
27 | 29 |
28 List<UINode> children = [ | 30 List<UINode> children = [ |
29 new Container( | 31 new Container( |
30 child: new StockArrow(percentChange: stock.percentChange), | 32 child: new StockArrow(percentChange: stock.percentChange), |
31 margin: const EdgeDims.only(right: 5.0)), | 33 margin: const EdgeDims.only(right: 5.0)), |
32 new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"), | 34 new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"), |
33 // TODO(hansmuller): text-align: right | 35 // TODO(hansmuller): text-align: right |
34 new FlexExpandingChild(new Text(lastSale), key: "lastSale"), | 36 new FlexExpandingChild(new Text(lastSale, |
35 // TODO(hansmuller): text-align: right, ${typography.black.caption}; | 37 style: const TextStyle(textAlign: TextAlign.right)), |
36 new FlexExpandingChild(new Text(changeInPrice), key: "changeInPrice") | 38 key: "lastSale"), |
| 39 new FlexExpandingChild(new Text(changeInPrice, |
| 40 style: typography.black.caption.copyWith(textAlign: TextAlign.right)), |
| 41 key: "changeInPrice") |
37 ]; | 42 ]; |
38 | 43 |
39 // TODO(hansmuller): An explicit |height| shouldn't be needed | 44 // TODO(hansmuller): An explicit |height| shouldn't be needed |
40 return new InkWell(children: [ | 45 return new InkWell(children: [ |
41 new Container( | 46 new Container( |
42 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), | 47 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), |
43 height: kHeight, | 48 height: kHeight, |
44 decoration: const BoxDecoration( | 49 decoration: const BoxDecoration( |
45 border: const Border( | 50 border: const Border( |
46 bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))), | 51 bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))), |
47 child: new Flex(children) | 52 child: new Flex(children) |
48 ) | 53 ) |
49 ]); | 54 ]); |
50 } | 55 } |
51 } | 56 } |
OLD | NEW |