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 'package:sky/framework/fn2.dart'; | |
6 import 'package:vector_math/vector_math.dart'; | |
7 import 'package:sky/framework/rendering/box.dart'; | |
8 import 'package:sky/framework/rendering/object.dart'; | |
9 import 'package:sky/framework/theme2/colors.dart' as colors; | |
10 | |
11 import 'dart:math' as math; | 5 import 'dart:math' as math; |
12 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
13 | 7 |
| 8 import 'package:sky/framework/rendering/box.dart'; |
| 9 import 'package:sky/framework/rendering/object.dart'; |
| 10 import 'package:sky/framework/theme2/colors.dart' as colors; |
| 11 import 'package:sky/framework/widgets/wrappers.dart'; |
| 12 |
14 class StockArrow extends Component { | 13 class StockArrow extends Component { |
15 | 14 |
16 StockArrow({ Object key, this.percentChange }) : super(key: key); | 15 StockArrow({ Object key, this.percentChange }) : super(key: key); |
17 | 16 |
18 final double percentChange; | 17 final double percentChange; |
19 | 18 |
20 int _colorIndexForPercentChange(double percentChange) { | 19 int _colorIndexForPercentChange(double percentChange) { |
21 double maxPercent = 10.0; | 20 double maxPercent = 10.0; |
22 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) /
maxPercent; | 21 double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) /
maxPercent; |
23 return 100 + (normalizedPercentChange * 8.0).floor() * 100; | 22 return 100 + (normalizedPercentChange * 8.0).floor() * 100; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 }); | 66 }); |
68 | 67 |
69 return new Container( | 68 return new Container( |
70 child: arrow, | 69 child: arrow, |
71 width: kSize, | 70 width: kSize, |
72 height: kSize, | 71 height: kSize, |
73 margin: const EdgeDims.symmetric(horizontal: 5.0)); | 72 margin: const EdgeDims.symmetric(horizontal: 5.0)); |
74 } | 73 } |
75 | 74 |
76 } | 75 } |
OLD | NEW |