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