stock_symbol_viewer.dart 1.56 KB
Newer Older
Hixie's avatar
Hixie committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
// 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.

part of stocks;

class StockSymbolViewer extends StatefulComponent {
  StockSymbolViewer(this.navigator, this.stock);

  final NavigatorState navigator;
  final Stock stock;

  StockSymbolViewerState createState() => new StockSymbolViewerState();
}

class StockSymbolViewerState extends State<StockSymbolViewer> {

  Widget build(BuildContext context) {

    String lastSale = "\$${config.stock.lastSale.toStringAsFixed(2)}";

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

    TextStyle headings = Theme.of(context).text.body2;

    return new Scaffold(
Adam Barth's avatar
Adam Barth committed
28
      toolBar: new ToolBar(
Hixie's avatar
Hixie committed
29 30 31 32 33 34
        left: new IconButton(
          icon: 'navigation/arrow_back',
          onPressed: config.navigator.pop
        ),
        center: new Text('${config.stock.name} (${config.stock.symbol})')
      ),
35 36 37 38 39 40 41 42 43 44 45 46 47
      body: new Block(<Widget>[
        new Container(
          padding: new EdgeDims.all(20.0),
          child: new Column(<Widget>[
              new Text('Last Sale', style: headings),
              new Text('$lastSale ($changeInPrice)'),
              new Container(
                height: 8.0
              ),
              new Text('Market Cap', style: headings),
              new Text('${config.stock.marketCap}'),
            ],
            alignItems: FlexAlignItems.stretch
Hixie's avatar
Hixie committed
48
          )
49 50
        )
      ])
Hixie's avatar
Hixie committed
51 52 53 54
    );
  }

}