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