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 '../fn2.dart'; | 5 import '../fn2.dart'; |
6 import '../rendering/box.dart'; | 6 import '../rendering/box.dart'; |
7 import '../painting/shadows.dart'; | 7 import '../painting/shadows.dart'; |
8 import '../theme2/colors.dart'; | 8 import '../theme2/colors.dart'; |
9 import 'dart:sky' as sky; | 9 import 'dart:sky' as sky; |
10 import 'ink_well.dart'; | 10 import 'ink_well.dart'; |
11 import 'material.dart'; | 11 import 'material.dart'; |
12 | 12 |
13 const double _kSize = 56.0; | 13 const double _kSize = 56.0; |
14 | 14 |
15 class FloatingActionButton extends Component { | 15 class FloatingActionButton extends Component { |
16 | 16 |
17 FloatingActionButton({ Object key, this.content, this.level: 0 }) | 17 FloatingActionButton({ Object key, this.content, this.level: 0 }) |
18 : super(key: key); | 18 : super(key: key); |
19 | 19 |
20 UINode content; | 20 UINode content; |
21 int level; | 21 int level; |
22 | 22 |
| 23 void syncFields(FloatingActionButton source) { |
| 24 content = source.content; |
| 25 level = source.level; |
| 26 super.syncFields(source); |
| 27 } |
| 28 |
23 UINode build() { | 29 UINode build() { |
24 List<UINode> children = []; | 30 List<UINode> children = []; |
25 | 31 |
26 if (content != null) | 32 if (content != null) |
27 children.add(content); | 33 children.add(content); |
28 | 34 |
29 return new Material( | 35 return new Material( |
30 content: new CustomPaint( | 36 content: new CustomPaint( |
31 callback: (sky.Canvas canvas) { | 37 callback: (sky.Canvas canvas) { |
32 const double radius = _kSize / 2.0; | 38 const double radius = _kSize / 2.0; |
33 sky.Paint paint = new sky.Paint()..color = Red[500]; | 39 sky.Paint paint = new sky.Paint()..color = Red[500]; |
34 var builder = new ShadowDrawLooperBuilder() | 40 var builder = new ShadowDrawLooperBuilder() |
35 ..addShadow(const sky.Size(0.0, 5.0), | 41 ..addShadow(const sky.Size(0.0, 5.0), |
36 const sky.Color(0x77000000), | 42 const sky.Color(0x77000000), |
37 5.0); | 43 5.0); |
38 paint.setDrawLooper(builder.build()); | 44 paint.setDrawLooper(builder.build()); |
39 canvas.drawCircle(radius, radius, radius, paint); | 45 canvas.drawCircle(radius, radius, radius, paint); |
40 }, | 46 }, |
41 child: new Container( | 47 child: new Container( |
42 width: _kSize, | 48 width: _kSize, |
43 height: _kSize, | 49 height: _kSize, |
44 child: new InkWell(children: children))), | 50 child: new InkWell(children: children))), |
45 level: level); | 51 level: level); |
46 } | 52 } |
47 | 53 |
48 } | 54 } |
OLD | NEW |