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