OLD | NEW |
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:math' as math; | 5 import 'dart:math' as math; |
6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
7 | 7 |
8 import 'package:sky/rendering/box.dart'; | 8 import 'package:sky/rendering/box.dart'; |
9 import 'package:sky/rendering/object.dart'; | 9 import 'package:sky/rendering/object.dart'; |
10 import 'package:sky/theme2/colors.dart' as colors; | 10 import 'package:sky/theme2/colors.dart' as colors; |
(...skipping 10 matching lines...) Expand all Loading... |
21 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) /
maxPercent; | 21 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) /
maxPercent; |
22 return 100 + (normalizedPercentChange * 8.0).floor() * 100; | 22 return 100 + (normalizedPercentChange * 8.0).floor() * 100; |
23 } | 23 } |
24 | 24 |
25 Color _colorForPercentChange(double percentChange) { | 25 Color _colorForPercentChange(double percentChange) { |
26 if (percentChange > 0) | 26 if (percentChange > 0) |
27 return colors.Green[_colorIndexForPercentChange(percentChange)]; | 27 return colors.Green[_colorIndexForPercentChange(percentChange)]; |
28 return colors.Red[_colorIndexForPercentChange(percentChange)]; | 28 return colors.Red[_colorIndexForPercentChange(percentChange)]; |
29 } | 29 } |
30 | 30 |
31 UINode build() { | 31 Widget build() { |
32 // TODO(jackson): This should change colors with the theme | 32 // TODO(jackson): This should change colors with the theme |
33 Color color = _colorForPercentChange(percentChange); | 33 Color color = _colorForPercentChange(percentChange); |
34 const double kSize = 40.0; | 34 const double kSize = 40.0; |
35 var arrow = new CustomPaint(callback: (sky.Canvas canvas, Size size) { | 35 var arrow = new CustomPaint(callback: (sky.Canvas canvas, Size size) { |
36 Paint paint = new Paint()..color = color; | 36 Paint paint = new Paint()..color = color; |
37 paint.strokeWidth = 1.0; | 37 paint.strokeWidth = 1.0; |
38 var padding = paint.strokeWidth * 3.0; | 38 var padding = paint.strokeWidth * 3.0; |
39 var r = kSize / 2.0 - padding; | 39 var r = kSize / 2.0 - padding; |
40 canvas.save(); | 40 canvas.save(); |
41 canvas.translate(padding, padding); | 41 canvas.translate(padding, padding); |
(...skipping 24 matching lines...) Expand all Loading... |
66 }); | 66 }); |
67 | 67 |
68 return new Container( | 68 return new Container( |
69 child: arrow, | 69 child: arrow, |
70 width: kSize, | 70 width: kSize, |
71 height: kSize, | 71 height: kSize, |
72 margin: const EdgeDims.symmetric(horizontal: 5.0)); | 72 margin: const EdgeDims.symmetric(horizontal: 5.0)); |
73 } | 73 } |
74 | 74 |
75 } | 75 } |
OLD | NEW |