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 '../theme/colors.dart'; | 5 import '../theme/colors.dart'; |
6 import '../theme/edges.dart'; | 6 import '../theme/edges.dart'; |
7 import 'basic.dart'; | 7 import 'basic.dart'; |
8 import 'button_base.dart'; | 8 import 'button_base.dart'; |
9 import 'ink_well.dart'; | 9 import 'ink_well.dart'; |
10 import 'material.dart'; | 10 import 'material.dart'; |
| 11 import 'theme.dart'; |
11 | 12 |
12 // TODO(eseidel): This needs to change based on device size? | 13 // TODO(eseidel): This needs to change based on device size? |
13 // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylin
es-keylines-spacing | 14 // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylin
es-keylines-spacing |
14 const double _kSize = 56.0; | 15 const double _kSize = 56.0; |
15 | 16 |
16 class FloatingActionButton extends ButtonBase { | 17 class FloatingActionButton extends ButtonBase { |
17 | 18 |
18 FloatingActionButton({ | 19 FloatingActionButton({ |
19 String key, | 20 String key, |
20 this.child, | 21 this.child, |
21 Function onPressed | 22 Function onPressed |
22 }) : super(key: key); | 23 }) : super(key: key); |
23 | 24 |
24 Widget child; | 25 Widget child; |
25 Function onPressed; | 26 Function onPressed; |
26 | 27 |
27 void syncFields(FloatingActionButton source) { | 28 void syncFields(FloatingActionButton source) { |
28 super.syncFields(source); | 29 super.syncFields(source); |
29 child = source.child; | 30 child = source.child; |
30 onPressed = source.onPressed; | 31 onPressed = source.onPressed; |
31 } | 32 } |
32 | 33 |
33 Widget buildContent() { | 34 Widget buildContent() { |
34 return new Material( | 35 return new Material( |
35 color: Red[500], | 36 color: Theme.of(this).accent[200], |
36 edge: MaterialEdge.circle, | 37 edge: MaterialEdge.circle, |
37 level: highlight ? 3 : 2, | 38 level: highlight ? 3 : 2, |
38 child: new ClipOval( | 39 child: new ClipOval( |
39 child: new Listener( | 40 child: new Listener( |
40 onGestureTap: (_) { | 41 onGestureTap: (_) { |
41 if (onPressed != null) | 42 if (onPressed != null) |
42 onPressed(); | 43 onPressed(); |
43 }, | 44 }, |
44 child: new Container( | 45 child: new Container( |
45 width: _kSize, | 46 width: _kSize, |
46 height: _kSize, | 47 height: _kSize, |
47 child: new InkWell(child: new Center(child: child)) | 48 child: new InkWell(child: new Center(child: child)) |
48 ) | 49 ) |
49 ) | 50 ) |
50 ) | 51 ) |
51 ); | 52 ); |
52 } | 53 } |
53 | 54 |
54 } | 55 } |
OLD | NEW |