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 '../theme/colors.dart'; | 6 import '../rendering/box.dart'; |
| 7 import '../theme2/colors.dart'; |
| 8 import 'dart:sky' as sky; |
7 import 'ink_well.dart'; | 9 import 'ink_well.dart'; |
8 import 'material.dart'; | 10 import 'material.dart'; |
9 | 11 |
| 12 const double _kSize = 56.0; |
| 13 |
10 class FloatingActionButton extends Component { | 14 class FloatingActionButton extends Component { |
11 // TODO(abarth): We need a better way to become a container for absolutely | |
12 // positioned elements. | |
13 static final Style _style = new Style(''' | |
14 width: 56px; | |
15 height: 56px; | |
16 background-color: ${Red[500]}; | |
17 border-radius: 28px;''' | |
18 ); | |
19 static final Style _clipStyle = new Style(''' | |
20 position: absolute; | |
21 justify-content: center; | |
22 align-items: center; | |
23 top: 0; | |
24 left: 0; | |
25 right: 0; | |
26 bottom: 0; | |
27 -webkit-clip-path: circle(28px at center);'''); | |
28 | |
29 UINode content; | 15 UINode content; |
30 int level; | 16 int level; |
31 | 17 |
32 FloatingActionButton({ Object key, this.content, this.level: 0 }) | 18 FloatingActionButton({ Object key, this.content, this.level: 0 }) |
33 : super(key: key); | 19 : super(key: key); |
34 | 20 |
35 UINode build() { | 21 UINode build() { |
36 List<UINode> children = []; | 22 List<UINode> children = []; |
37 | 23 |
38 if (content != null) | 24 if (content != null) |
39 children.add(content); | 25 children.add(content); |
40 | 26 |
41 return new Material( | 27 return new Material( |
42 content: new Container( | 28 content: new CustomPaint( |
43 style: _style, | 29 callback: (sky.Canvas canvas) { |
44 children: [new StyleNode(new InkWell(children: children), _clipStyle)]), | 30 const double radius = _kSize / 2.0; |
| 31 canvas.drawCircle(radius, radius, radius, new sky.Paint()..color = Red
[500]); |
| 32 }, |
| 33 child: new Container( |
| 34 desiredSize: const sky.Size(_kSize, _kSize), |
| 35 child: new InkWell(children: children))), |
45 level: level); | 36 level: level); |
46 } | 37 } |
47 } | 38 } |
OLD | NEW |