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

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

Issue 1148793005: Prepare StockList for use in stocks2 (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
« no previous file with comments | « sky/examples/stocks2/lib/stock_list.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:sky' as sky;
5 import 'package:sky/framework/components2/ink_well.dart'; 6 import 'package:sky/framework/components2/ink_well.dart';
6 import 'package:sky/framework/fn2.dart'; 7 import 'package:sky/framework/fn2.dart';
8 import 'package:sky/framework/rendering/box.dart';
7 import 'package:sky/framework/theme/typography.dart' as typography; 9 import 'package:sky/framework/theme/typography.dart' as typography;
8 import 'stock_arrow.dart'; 10 import 'stock_arrow.dart';
9 import 'stock_data.dart'; 11 import 'stock_data.dart';
10 12
11 class StockRow extends Component { 13 class StockRow extends Component {
12 static final Style _style = new Style(''' 14 static const double kHeight = 100.0;
13 align-items: center; 15 // static final Style _style = new Style('''
14 border-bottom: 1px solid #F4F4F4; 16 // align-items: center;
15 padding-top: 16px; 17 // border-bottom: 1px solid #F4F4F4;
16 padding-left: 16px; 18 // padding-top: 16px;
17 padding-right: 16px; 19 // padding-left: 16px;
18 padding-bottom: 20px;''' 20 // padding-right: 16px;
19 ); 21 // padding-bottom: 20px;'''
22 // );
20 23
21 static final FlexBoxParentData _tickerFlex = new FlexBoxParentData()..flex = 1 ; 24 // static final FlexBoxParentData _tickerFlex = new FlexBoxParentData()..flex = 1;
22 25
23 static final Style _lastSaleStyle = new Style(''' 26 // static final Style _lastSaleStyle = new Style('''
24 text-align: right; 27 // text-align: right;
25 padding-right: 16px;''' 28 // padding-right: 16px;'''
26 ); 29 // );
27 30
28 static final Style _changeStyle = new Style(''' 31 // static final Style _changeStyle = new Style('''
29 ${typography.black.caption}; 32 // ${typography.black.caption};
30 text-align: right;''' 33 // text-align: right;'''
31 ); 34 // );
32 35
33 Stock stock; 36 Stock stock;
34 37
35 StockRow({Stock stock}) : super(key: stock.symbol) { 38 StockRow({ Stock stock }) : super(key: stock.symbol) {
36 this.stock = stock; 39 this.stock = stock;
37 } 40 }
38 41
39 UINode build() { 42 UINode build() {
40 String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; 43 // String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";
41 44
42 String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; 45 // String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%";
43 if (stock.percentChange > 0) 46 // if (stock.percentChange > 0)
44 changeInPrice = "+" + changeInPrice; 47 // changeInPrice = "+" + changeInPrice;
45 48
46 List<UINode> children = [ 49 // List<UINode> children = [
47 new StockArrow( 50 // new StockArrow(
48 percentChange: stock.percentChange 51 // percentChange: stock.percentChange
49 ), 52 // ),
50 new ParentDataNode( 53 // new ParentDataNode(
51 new Container( 54 // new Container(
52 key: 'Ticker', 55 // key: 'Ticker',
53 children: [new Text(stock.symbol)] 56 // children: [new Text(stock.symbol)]
54 ), 57 // ),
55 _tickerFlex 58 // _tickerFlex
56 ), 59 // ),
57 new Container( 60 // new Container(
58 key: 'LastSale', 61 // key: 'LastSale',
59 style: _lastSaleStyle, 62 // style: _lastSaleStyle,
60 children: [new Text(lastSale)] 63 // children: [new Text(lastSale)]
61 ), 64 // ),
62 new Container( 65 // new Container(
63 key: 'Change', 66 // key: 'Change',
64 style: _changeStyle, 67 // style: _changeStyle,
65 children: [new Text(changeInPrice)] 68 // children: [new Text(changeInPrice)]
66 ) 69 // )
67 ]; 70 // ];
68 71
69 return new StyleNode(new InkWell(children: children), _style); 72 // return new StyleNode(new InkWell(children: children), _style);
73 return new Container(
74 desiredSize: const sky.Size.fromHeight(kHeight),
75 decoration: const BoxDecoration(
76 backgroundColor: const sky.Color(0xFFFFFFFF),
77 border: const Border(
78 bottom: const BorderSide(
79 color: const sky.Color(0xFFF4F4F4),
80 width: 1.0))));
70 } 81 }
71 } 82 }
OLDNEW
« no previous file with comments | « sky/examples/stocks2/lib/stock_list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698