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

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

Issue 1174023003: Remove one more use of mirrors: Components now have to explicitly sync their fields. (Closed) Base URL: https://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_app.dart ('k') | sky/examples/stocks2/lib/stock_list.dart » ('j') | 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 'package:sky/framework/fn2.dart'; 5 import 'package:sky/framework/fn2.dart';
6 import 'package:vector_math/vector_math.dart'; 6 import 'package:vector_math/vector_math.dart';
7 import 'package:sky/framework/rendering/box.dart'; 7 import 'package:sky/framework/rendering/box.dart';
8 import 'package:sky/framework/rendering/object.dart'; 8 import 'package:sky/framework/rendering/object.dart';
9 import 'package:sky/framework/theme2/colors.dart' as colors; 9 import 'package:sky/framework/theme2/colors.dart' as colors;
10 10
11 import 'dart:math' as math; 11 import 'dart:math' as math;
12 import 'dart:sky' as sky; 12 import 'dart:sky' as sky;
13 13
14 class StockArrow extends Component { 14 class StockArrow extends Component {
15 double percentChange;
16 15
17 StockArrow({ Object key, this.percentChange }) : super(key: key); 16 StockArrow({ Object key, this.percentChange }) : super(key: key);
18 17
18 final double percentChange;
19
19 int _colorIndexForPercentChange(double percentChange) { 20 int _colorIndexForPercentChange(double percentChange) {
20 double maxPercent = 10.0; 21 double maxPercent = 10.0;
21 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent; 22 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent;
22 return 100 + (normalizedPercentChange * 8.0).floor() * 100; 23 return 100 + (normalizedPercentChange * 8.0).floor() * 100;
23 } 24 }
24 25
25 Color _colorForPercentChange(double percentChange) { 26 Color _colorForPercentChange(double percentChange) {
26 if (percentChange > 0) 27 if (percentChange > 0)
27 return colors.Green[_colorIndexForPercentChange(percentChange)]; 28 return colors.Green[_colorIndexForPercentChange(percentChange)];
28 return colors.Red[_colorIndexForPercentChange(percentChange)]; 29 return colors.Red[_colorIndexForPercentChange(percentChange)];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 65
65 canvas.restore(); 66 canvas.restore();
66 }); 67 });
67 68
68 return new Container( 69 return new Container(
69 child: arrow, 70 child: arrow,
70 width: size, 71 width: size,
71 height: size, 72 height: size,
72 margin: const EdgeDims.symmetric(horizontal: 5.0)); 73 margin: const EdgeDims.symmetric(horizontal: 5.0));
73 } 74 }
75
74 } 76 }
OLDNEW
« no previous file with comments | « sky/examples/stocks2/lib/stock_app.dart ('k') | sky/examples/stocks2/lib/stock_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698