stock_row.dart 1.7 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'dart:sky' as sky;
6

7
import 'package:sky/framework/rendering/box.dart';
8 9 10
import 'package:sky/framework/widgets/wrappers.dart';
import 'package:sky/framework/widgets/ink_well.dart';

11
import 'stock_arrow.dart';
12 13 14 15
import 'stock_data.dart';

class StockRow extends Component {

16 17 18
  StockRow({ Stock stock }) : this.stock = stock, super(key: stock.symbol);

  final Stock stock;
19

20
  static const double kHeight = 70.0;
21 22

  UINode build() {
23 24 25
    String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";

    String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%";
26
    if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice;
27 28 29

    List<UINode> children = [
      new Container(
30 31 32 33 34 35 36
          child: new StockArrow(percentChange: stock.percentChange),
          margin: const EdgeDims.only(right: 5.0)),
      new FlexExpandingChild(new Text(stock.symbol), flex: 2, key: "symbol"),
      // TODO(hansmuller): text-align: right
      new FlexExpandingChild(new Text(lastSale), key: "lastSale"),
      // TODO(hansmuller): text-align: right, ${typography.black.caption};
      new FlexExpandingChild(new Text(changeInPrice), key: "changeInPrice")
37
    ];
38

39 40 41 42 43 44 45 46
    // TODO(hansmuller): An explicit |height| shouldn't be needed
    return new InkWell(children: [
      new Container(
        padding: const EdgeDims(16.0, 16.0, 20.0, 16.0),
        height: kHeight,
        decoration: const BoxDecoration(
            border: const Border(
                bottom: const BorderSide(color: const sky.Color(0xFFF4F4F4)))),
47
        child: new Flex(children)
48 49
      )
    ]);
50 51
  }
}