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 'package:sky/framework/theme2/colors.dart' as colors; | 5 import 'package:sky/framework/theme2/colors.dart' as colors; |
6 | 6 |
7 import '../fn2.dart'; | 7 import '../fn2.dart'; |
8 import '../rendering/object.dart'; | 8 import '../rendering/object.dart'; |
9 import 'button_base.dart'; | 9 import 'button_base.dart'; |
10 import 'ink_well.dart'; | 10 import 'ink_well.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 void syncFields(Radio source) { | 28 void syncFields(Radio source) { |
29 value = source.value; | 29 value = source.value; |
30 groupValue = source.groupValue; | 30 groupValue = source.groupValue; |
31 onChanged = source.onChanged; | 31 onChanged = source.onChanged; |
32 super.syncFields(source); | 32 super.syncFields(source); |
33 } | 33 } |
34 | 34 |
35 UINode buildContent() { | 35 UINode buildContent() { |
36 // TODO(jackson): This should change colors with the theme | 36 // TODO(jackson): This should change colors with the theme |
37 Color color = highlight ? colors.Purple[500] : const Color(0x8A000000); | 37 Color color = highlight ? colors.Purple[500] : const Color(0x8A000000); |
38 const double diameter = 16.0; | 38 const double kDiameter = 16.0; |
39 const double outerRadius = diameter / 2; | 39 const double kOuterRadius = kDiameter / 2; |
40 const double innerRadius = 5.0; | 40 const double kInnerRadius = 5.0; |
41 return new EventListenerNode( | 41 return new EventListenerNode( |
42 new Container( | 42 new Container( |
43 margin: const EdgeDims.symmetric(horizontal: 5.0), | 43 margin: const EdgeDims.symmetric(horizontal: 5.0), |
44 width: diameter, | 44 width: kDiameter, |
45 height: diameter, | 45 height: kDiameter, |
46 child: new CustomPaint( | 46 child: new CustomPaint( |
47 callback: (sky.Canvas canvas) { | 47 callback: (sky.Canvas canvas, Size size) { |
48 | 48 |
49 Paint paint = new Paint()..color = color; | 49 Paint paint = new Paint()..color = color; |
50 | 50 |
51 // Draw the outer circle | 51 // Draw the outer circle |
52 paint.setStyle(sky.PaintingStyle.stroke); | 52 paint.setStyle(sky.PaintingStyle.stroke); |
53 paint.strokeWidth = 2.0; | 53 paint.strokeWidth = 2.0; |
54 canvas.drawCircle(outerRadius, outerRadius, outerRadius, paint); | 54 canvas.drawCircle(kOuterRadius, kOuterRadius, kOuterRadius, paint); |
55 | 55 |
56 // Draw the inner circle | 56 // Draw the inner circle |
57 if (value == groupValue) { | 57 if (value == groupValue) { |
58 paint.setStyle(sky.PaintingStyle.fill); | 58 paint.setStyle(sky.PaintingStyle.fill); |
59 canvas.drawCircle(outerRadius, outerRadius, innerRadius, paint); | 59 canvas.drawCircle(kOuterRadius, kOuterRadius, kInnerRadius, paint)
; |
60 } | 60 } |
61 } | 61 } |
62 ) | 62 ) |
63 ), | 63 ), |
64 onGestureTap: _handleClick | 64 onGestureTap: _handleClick |
65 ); | 65 ); |
66 } | 66 } |
67 | 67 |
68 void _handleClick(_) { | 68 void _handleClick(_) { |
69 onChanged(value); | 69 onChanged(value); |
70 } | 70 } |
71 | 71 |
72 } | 72 } |
OLD | NEW |