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

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

Issue 1190793002: Rename UINode to Widget. (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 '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
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
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 }
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