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

Unified Diff: sky/examples/stocks2/lib/stock_arrow.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@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 side-by-side diff with in-line comments
Download patch
Index: sky/examples/stocks2/lib/stock_arrow.dart
diff --git a/sky/examples/stocks2/lib/stock_arrow.dart b/sky/examples/stocks2/lib/stock_arrow.dart
deleted file mode 100644
index 7207c0a0132990fa6a4d6c900a4e471ba6ca071b..0000000000000000000000000000000000000000
--- a/sky/examples/stocks2/lib/stock_arrow.dart
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:math' as math;
-import 'dart:sky' as sky;
-
-import 'package:sky/rendering/box.dart';
-import 'package:sky/rendering/object.dart';
-import 'package:sky/theme/colors.dart' as colors;
-import 'package:sky/widgets/basic.dart';
-
-class StockArrow extends Component {
-
- StockArrow({ String key, this.percentChange }) : super(key: key);
-
- final double percentChange;
-
- int _colorIndexForPercentChange(double percentChange) {
- double maxPercent = 10.0;
- double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent;
- return 100 + (normalizedPercentChange * 8.0).floor() * 100;
- }
-
- Color _colorForPercentChange(double percentChange) {
- if (percentChange > 0)
- return colors.Green[_colorIndexForPercentChange(percentChange)];
- return colors.Red[_colorIndexForPercentChange(percentChange)];
- }
-
- Widget build() {
- // TODO(jackson): This should change colors with the theme
- Color color = _colorForPercentChange(percentChange);
- const double kSize = 40.0;
- var arrow = new CustomPaint(callback: (sky.Canvas canvas, Size size) {
- Paint paint = new Paint()..color = color;
- paint.strokeWidth = 1.0;
- const double padding = 2.0;
- assert(padding > paint.strokeWidth / 2.0); // make sure the circle remains inside the box
- double r = (kSize - padding) / 2.0; // radius of the circle
- double centerX = padding + r;
- double centerY = padding + r;
-
- // Draw the arrow.
- double w = 8.0;
- double h = 5.0;
- double arrowY;
- if (percentChange < 0.0) {
- h = -h;
- arrowY = centerX + 1.0;
- } else {
- arrowY = centerX - 1.0;
- }
- Path path = new Path();
- path.moveTo(centerX, arrowY - h); // top of the arrow
- path.lineTo(centerX + w, arrowY + h);
- path.lineTo(centerX - w, arrowY + h);
- path.close();
- paint.setStyle(sky.PaintingStyle.fill);
- canvas.drawPath(path, paint);
-
- // Draw a circle that circumscribes the arrow.
- paint.setStyle(sky.PaintingStyle.stroke);
- canvas.drawCircle(centerX, centerY, r, paint);
- });
-
- return new Container(
- child: arrow,
- width: kSize,
- height: kSize,
- margin: const EdgeDims.symmetric(horizontal: 5.0)
- );
- }
-
-}

Powered by Google App Engine
This is Rietveld 408576698