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