| 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 19 matching lines...) Expand all Loading... |
| 30 /// Constructs a checkbox | 30 /// Constructs a checkbox |
| 31 /// | 31 /// |
| 32 /// * `value` determines whether the checkbox is checked. | 32 /// * `value` determines whether the checkbox is checked. |
| 33 /// * `onChanged` is called whenever the state of the checkbox should change. | 33 /// * `onChanged` is called whenever the state of the checkbox should change. |
| 34 Checkbox({ | 34 Checkbox({ |
| 35 String key, | 35 String key, |
| 36 bool value, | 36 bool value, |
| 37 ValueChanged onChanged | 37 ValueChanged onChanged |
| 38 }) : super(key: key, value: value, onChanged: onChanged); | 38 }) : super(key: key, value: value, onChanged: onChanged); |
| 39 | 39 |
| 40 @override |
| 40 Size get size => const Size(_kEdgeSize + 2.0, _kEdgeSize + 2.0); | 41 Size get size => const Size(_kEdgeSize + 2.0, _kEdgeSize + 2.0); |
| 41 | 42 |
| 43 @override |
| 42 void customPaintCallback(sky.Canvas canvas, Size size) { | 44 void customPaintCallback(sky.Canvas canvas, Size size) { |
| 43 ThemeData themeData = Theme.of(this); | 45 ThemeData themeData = Theme.of(this); |
| 44 Color uncheckedColor = themeData.brightness == ThemeBrightness.light ? _kLig
htUncheckedColor : _kDarkUncheckedColor; | 46 Color uncheckedColor = themeData.brightness == ThemeBrightness.light ? _kLig
htUncheckedColor : _kDarkUncheckedColor; |
| 45 | 47 |
| 46 // Choose a color between grey and the theme color | 48 // Choose a color between grey and the theme color |
| 47 sky.Paint paint = new sky.Paint()..strokeWidth = 2.0 | 49 sky.Paint paint = new sky.Paint()..strokeWidth = 2.0 |
| 48 ..color = uncheckedColor; | 50 ..color = uncheckedColor; |
| 49 | 51 |
| 50 // The rrect contracts slightly during the animation | 52 // The rrect contracts slightly during the animation |
| 51 double inset = 2.0 - (toggleAnimation.value - _kMidpoint).abs() * 2.0; | 53 double inset = 2.0 - (toggleAnimation.value - _kMidpoint).abs() * 2.0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 => new Point(p1.x * (1.0 - t) + p2.x * t, p1.y * (1.0 - t) + p2.y * t); | 93 => new Point(p1.x * (1.0 - t) + p2.x * t, p1.y * (1.0 - t) + p2.y * t); |
| 92 sky.Point drawStart = lerp(start, mid, 1.0 - t); | 94 sky.Point drawStart = lerp(start, mid, 1.0 - t); |
| 93 sky.Point drawEnd = lerp(mid, end, t); | 95 sky.Point drawEnd = lerp(mid, end, t); |
| 94 path.moveTo(drawStart.x, drawStart.y); | 96 path.moveTo(drawStart.x, drawStart.y); |
| 95 path.lineTo(mid.x, mid.y); | 97 path.lineTo(mid.x, mid.y); |
| 96 path.lineTo(drawEnd.x, drawEnd.y); | 98 path.lineTo(drawEnd.x, drawEnd.y); |
| 97 canvas.drawPath(path, paint); | 99 canvas.drawPath(path, paint); |
| 98 } | 100 } |
| 99 } | 101 } |
| 100 } | 102 } |
| OLD | NEW |