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

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

Issue 1175353002: Make the popup menu animation correct (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: style guide update 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 | « no previous file | sky/sdk/lib/framework/components2/checkbox.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
(...skipping 14 matching lines...) Expand all
25 25
26 Color _colorForPercentChange(double percentChange) { 26 Color _colorForPercentChange(double percentChange) {
27 if (percentChange > 0) 27 if (percentChange > 0)
28 return colors.Green[_colorIndexForPercentChange(percentChange)]; 28 return colors.Green[_colorIndexForPercentChange(percentChange)];
29 return colors.Red[_colorIndexForPercentChange(percentChange)]; 29 return colors.Red[_colorIndexForPercentChange(percentChange)];
30 } 30 }
31 31
32 UINode build() { 32 UINode build() {
33 // TODO(jackson): This should change colors with the theme 33 // TODO(jackson): This should change colors with the theme
34 Color color = _colorForPercentChange(percentChange); 34 Color color = _colorForPercentChange(percentChange);
35 const double size = 40.0; 35 const double kSize = 40.0;
36 var arrow = new CustomPaint(callback: (sky.Canvas canvas) { 36 var arrow = new CustomPaint(callback: (sky.Canvas canvas, Size size) {
37 Paint paint = new Paint()..color = color; 37 Paint paint = new Paint()..color = color;
38 paint.strokeWidth = 1.0; 38 paint.strokeWidth = 1.0;
39 var padding = paint.strokeWidth * 3.0; 39 var padding = paint.strokeWidth * 3.0;
40 var r = size / 2.0 - padding; 40 var r = kSize / 2.0 - padding;
41 canvas.save(); 41 canvas.save();
42 canvas.translate(padding, padding); 42 canvas.translate(padding, padding);
43 43
44 // The arrow (below) is drawn upwards by default. 44 // The arrow (below) is drawn upwards by default.
45 if (percentChange < 0.0) { 45 if (percentChange < 0.0) {
46 canvas.translate(r, r); 46 canvas.translate(r, r);
47 canvas.rotate(math.PI); 47 canvas.rotate(math.PI);
48 canvas.translate(-r, -r); 48 canvas.translate(-r, -r);
49 } 49 }
50 50
(...skipping 10 matching lines...) Expand all
61 61
62 // Draw a circle that circumscribes the arrow. 62 // Draw a circle that circumscribes the arrow.
63 paint.setStyle(sky.PaintingStyle.stroke); 63 paint.setStyle(sky.PaintingStyle.stroke);
64 canvas.drawCircle(r, r, r + 2.0, paint); 64 canvas.drawCircle(r, r, r + 2.0, paint);
65 65
66 canvas.restore(); 66 canvas.restore();
67 }); 67 });
68 68
69 return new Container( 69 return new Container(
70 child: arrow, 70 child: arrow,
71 width: size, 71 width: kSize,
72 height: size, 72 height: kSize,
73 margin: const EdgeDims.symmetric(horizontal: 5.0)); 73 margin: const EdgeDims.symmetric(horizontal: 5.0));
74 } 74 }
75 75
76 } 76 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/framework/components2/checkbox.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698