| 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/painting/text_style.dart'; | 5 import 'package:sky/painting/text_style.dart'; |
| 6 import 'package:sky/rendering/box.dart'; | 6 import 'package:sky/rendering/box.dart'; |
| 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/widgets/theme.dart'; | 9 import 'package:sky/widgets/theme.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 Color get dividerColor { |
| 23 switch(Theme.of(this).brightness) { |
| 24 case ThemeBrightness.light: |
| 25 return const Color.fromARGB(31, 0, 0, 0); |
| 26 case ThemeBrightness.dark: |
| 27 return const Color.fromARGB(31, 255, 255, 255); |
| 28 } |
| 29 } |
| 30 |
| 22 Widget build() { | 31 Widget build() { |
| 23 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; | 32 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; |
| 24 | 33 |
| 25 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; | 34 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; |
| 26 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; | 35 if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; |
| 27 | 36 |
| 28 List<Widget> children = [ | 37 List<Widget> children = [ |
| 29 new Container( | 38 new Container( |
| 30 child: new StockArrow(percentChange: stock.percentChange), | 39 child: new StockArrow(percentChange: stock.percentChange), |
| 31 margin: const EdgeDims.only(right: 5.0) | 40 margin: const EdgeDims.only(right: 5.0) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 style: Theme.of(this).text.caption.copyWith(textAlign: TextAlign.right
) | 55 style: Theme.of(this).text.caption.copyWith(textAlign: TextAlign.right
) |
| 47 ) | 56 ) |
| 48 ) | 57 ) |
| 49 ]; | 58 ]; |
| 50 | 59 |
| 51 // TODO(hansmuller): An explicit |height| shouldn't be needed | 60 // TODO(hansmuller): An explicit |height| shouldn't be needed |
| 52 return new InkWell( | 61 return new InkWell( |
| 53 child: new Container( | 62 child: new Container( |
| 54 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), | 63 padding: const EdgeDims(16.0, 16.0, 20.0, 16.0), |
| 55 height: kHeight, | 64 height: kHeight, |
| 56 decoration: const BoxDecoration( | 65 decoration: new BoxDecoration( |
| 57 border: const Border( | 66 border: new Border( |
| 58 bottom: const BorderSide(color: const Color(0xFFF4F4F4)) | 67 bottom: new BorderSide(color: dividerColor) |
| 59 ) | 68 ) |
| 60 ), | 69 ), |
| 61 child: new Flex(children) | 70 child: new Flex(children) |
| 62 ) | 71 ) |
| 63 ); | 72 ); |
| 64 } | 73 } |
| 65 } | 74 } |
| OLD | NEW |