Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: sky/examples/stocks/lib/stock_row.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'package:sky/framework/components/ink_well.dart';
6 import 'package:sky/framework/fn.dart';
7 import 'package:sky/framework/layout.dart';
8 import 'package:sky/framework/theme/typography.dart' as typography;
9 import 'stock_arrow.dart';
10 import 'stock_data.dart';
11
12 class StockRow extends Component {
13 static final Style _style = new Style('''
14 align-items: center;
15 border-bottom: 1px solid #F4F4F4;
16 padding-top: 16px;
17 padding-left: 16px;
18 padding-right: 16px;
19 padding-bottom: 20px;'''
20 );
21
22 static final FlexBoxParentData _tickerFlex = new FlexBoxParentData()..flex = 1 ;
23
24 static final Style _lastSaleStyle = new Style('''
25 text-align: right;
26 padding-right: 16px;'''
27 );
28
29 static final Style _changeStyle = new Style('''
30 ${typography.black.caption};
31 text-align: right;'''
32 );
33
34 Stock stock;
35
36 StockRow({Stock stock}) : super(key: stock.symbol) {
37 this.stock = stock;
38 }
39
40 UINode build() {
41 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";
42
43 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%";
44 if (stock.percentChange > 0)
45 changeInPrice = "+" + changeInPrice;
46
47 List<UINode> children = [
48 new StockArrow(
49 percentChange: stock.percentChange
50 ),
51 new ParentDataNode(
52 new Container(
53 key: 'Ticker',
54 children: [new Text(stock.symbol)]
55 ),
56 _tickerFlex
57 ),
58 new Container(
59 key: 'LastSale',
60 style: _lastSaleStyle,
61 children: [new Text(lastSale)]
62 ),
63 new Container(
64 key: 'Change',
65 style: _changeStyle,
66 children: [new Text(changeInPrice)]
67 )
68 ];
69
70 return new StyleNode(new InkWell(children: children), _style);
71 }
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698