| 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:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 | 6 |
| 7 import 'package:sky/widgets/theme.dart'; | 7 import 'package:sky/widgets/theme.dart'; |
| 8 | 8 |
| 9 import 'basic.dart'; | 9 import 'basic.dart'; |
| 10 import 'toggleable.dart'; | 10 import 'toggleable.dart'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 ) | 50 ) |
| 51 ); | 51 ); |
| 52 canvas.drawRRect(rrect, paint); | 52 canvas.drawRRect(rrect, paint); |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (toggleAnimation.value > _kMidpoint) { | 55 if (toggleAnimation.value > _kMidpoint) { |
| 56 double t = (toggleAnimation.value - _kMidpoint) / (1.0 - _kMidpoint); | 56 double t = (toggleAnimation.value - _kMidpoint) / (1.0 - _kMidpoint); |
| 57 | 57 |
| 58 // Solid filled rrect | 58 // Solid filled rrect |
| 59 paint.setStyle(sky.PaintingStyle.strokeAndFill); | 59 paint.setStyle(sky.PaintingStyle.strokeAndFill); |
| 60 Color themeColor = Theme.of(this).color[500]; | 60 Color themeColor = Theme.of(this).primary[500]; |
| 61 paint.color = new Color.fromARGB((t * 255).floor(), | 61 paint.color = new Color.fromARGB((t * 255).floor(), |
| 62 themeColor.red, | 62 themeColor.red, |
| 63 themeColor.green, | 63 themeColor.green, |
| 64 themeColor.blue); | 64 themeColor.blue); |
| 65 canvas.drawRRect(rrect, paint); | 65 canvas.drawRRect(rrect, paint); |
| 66 | 66 |
| 67 // White inner check | 67 // White inner check |
| 68 paint.color = const sky.Color(0xFFFFFFFF); | 68 paint.color = const sky.Color(0xFFFFFFFF); |
| 69 paint.setStyle(sky.PaintingStyle.stroke); | 69 paint.setStyle(sky.PaintingStyle.stroke); |
| 70 sky.Path path = new sky.Path(); | 70 sky.Path path = new sky.Path(); |
| 71 sky.Point start = new sky.Point(_kEdgeSize * 0.2, _kEdgeSize * 0.5); | 71 sky.Point start = new sky.Point(_kEdgeSize * 0.2, _kEdgeSize * 0.5); |
| 72 sky.Point mid = new sky.Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7); | 72 sky.Point mid = new sky.Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7); |
| 73 sky.Point end = new sky.Point(_kEdgeSize * 0.8, _kEdgeSize * 0.3); | 73 sky.Point end = new sky.Point(_kEdgeSize * 0.8, _kEdgeSize * 0.3); |
| 74 Point lerp(Point p1, Point p2, double t) | 74 Point lerp(Point p1, Point p2, double t) |
| 75 => new Point(p1.x * (1.0 - t) + p2.x * t, p1.y * (1.0 - t) + p2.y * t); | 75 => new Point(p1.x * (1.0 - t) + p2.x * t, p1.y * (1.0 - t) + p2.y * t); |
| 76 sky.Point drawStart = lerp(start, mid, 1.0 - t); | 76 sky.Point drawStart = lerp(start, mid, 1.0 - t); |
| 77 sky.Point drawEnd = lerp(mid, end, t); | 77 sky.Point drawEnd = lerp(mid, end, t); |
| 78 path.moveTo(drawStart.x, drawStart.y); | 78 path.moveTo(drawStart.x, drawStart.y); |
| 79 path.lineTo(mid.x, mid.y); | 79 path.lineTo(mid.x, mid.y); |
| 80 path.lineTo(drawEnd.x, drawEnd.y); | 80 path.lineTo(drawEnd.x, drawEnd.y); |
| 81 canvas.drawPath(path, paint); | 81 canvas.drawPath(path, paint); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| OLD | NEW |