| 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 'icon.dart'; |
| 7 import 'ink_well.dart'; | 8 import 'ink_well.dart'; |
| 8 import 'material.dart'; | 9 import 'material.dart'; |
| 9 import 'theme.dart'; | 10 import 'theme.dart'; |
| 10 | 11 |
| 11 // TODO(eseidel): This needs to change based on device size? | 12 // 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 | 13 // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylin
es-keylines-spacing |
| 13 const double _kSize = 56.0; | 14 const double _kSize = 56.0; |
| 14 | 15 |
| 15 class FloatingActionButton extends ButtonBase { | 16 class FloatingActionButton extends ButtonBase { |
| 16 | 17 |
| 17 FloatingActionButton({ | 18 FloatingActionButton({ |
| 18 String key, | 19 String key, |
| 19 this.child, | 20 this.child, |
| 21 this.backgroundColor, |
| 20 this.onPressed | 22 this.onPressed |
| 21 }) : super(key: key); | 23 }) : super(key: key); |
| 22 | 24 |
| 23 Widget child; | 25 Widget child; |
| 26 Color backgroundColor; |
| 24 Function onPressed; | 27 Function onPressed; |
| 25 | 28 |
| 26 void syncFields(FloatingActionButton source) { | 29 void syncFields(FloatingActionButton source) { |
| 27 super.syncFields(source); | 30 super.syncFields(source); |
| 28 child = source.child; | 31 child = source.child; |
| 32 backgroundColor = source.backgroundColor; |
| 29 onPressed = source.onPressed; | 33 onPressed = source.onPressed; |
| 30 } | 34 } |
| 31 | 35 |
| 32 Widget buildContent() { | 36 Widget buildContent() { |
| 37 IconThemeColor iconThemeColor = IconThemeColor.white; |
| 38 Color materialColor = backgroundColor; |
| 39 if (materialColor == null) { |
| 40 ThemeData themeData = Theme.of(this); |
| 41 materialColor = themeData.accentColor; |
| 42 iconThemeColor = themeData.accentColorBrightness == ThemeBrightness.dark ?
IconThemeColor.white : IconThemeColor.black; |
| 43 } |
| 44 |
| 33 return new Material( | 45 return new Material( |
| 34 color: Theme.of(this).floatingActionButtonColor, | 46 color: materialColor, |
| 35 type: MaterialType.circle, | 47 type: MaterialType.circle, |
| 36 level: highlight ? 3 : 2, | 48 level: highlight ? 3 : 2, |
| 37 child: new ClipOval( | 49 child: new ClipOval( |
| 38 child: new Listener( | 50 child: new Listener( |
| 39 onGestureTap: (_) { | 51 onGestureTap: (_) { |
| 40 if (onPressed != null) | 52 if (onPressed != null) |
| 41 onPressed(); | 53 onPressed(); |
| 42 }, | 54 }, |
| 43 child: new Container( | 55 child: new Container( |
| 44 width: _kSize, | 56 width: _kSize, |
| 45 height: _kSize, | 57 height: _kSize, |
| 46 child: new InkWell(child: new Center(child: child)) | 58 child: new InkWell( |
| 59 child: new Center( |
| 60 child: new IconTheme( |
| 61 data: new IconThemeData(color: iconThemeColor), |
| 62 child: child |
| 63 ) |
| 64 ) |
| 65 ) |
| 47 ) | 66 ) |
| 48 ) | 67 ) |
| 49 ) | 68 ) |
| 50 ); | 69 ); |
| 51 } | 70 } |
| 52 | 71 |
| 53 } | 72 } |
| OLD | NEW |