| 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 | 9 |
| 10 // Rather than using this class directly, please use FlatButton or RaisedButton. | 10 // Rather than using this class directly, please use FlatButton or RaisedButton. |
| 11 abstract class MaterialButton extends ButtonBase { | 11 abstract class MaterialButton extends ButtonBase { |
| 12 | 12 |
| 13 MaterialButton({ | 13 MaterialButton({ |
| 14 String key, | 14 String key, |
| 15 this.child, | 15 this.child, |
| 16 this.enabled: true, | 16 this.enabled: true, |
| 17 this.onPressed | 17 this.onPressed |
| 18 }) : super(key: key); | 18 }) : super(key: key); |
| 19 | 19 |
| 20 Widget child; | 20 Widget child; |
| 21 bool enabled; | 21 bool enabled; |
| 22 Function onPressed; | 22 Function onPressed; |
| 23 | 23 |
| 24 @override |
| 24 void syncFields(MaterialButton source) { | 25 void syncFields(MaterialButton source) { |
| 25 child = source.child; | 26 child = source.child; |
| 26 enabled = source.enabled; | 27 enabled = source.enabled; |
| 27 onPressed = source.onPressed; | 28 onPressed = source.onPressed; |
| 28 super.syncFields(source); | 29 super.syncFields(source); |
| 29 } | 30 } |
| 30 | 31 |
| 31 Color get color; | 32 Color get color; |
| 32 int get level; | 33 int get level; |
| 33 | 34 |
| 35 @override |
| 34 Widget buildContent() { | 36 Widget buildContent() { |
| 35 Widget contents = new Container( | 37 Widget contents = new Container( |
| 36 padding: new EdgeDims.symmetric(horizontal: 8.0), | 38 padding: new EdgeDims.symmetric(horizontal: 8.0), |
| 37 child: new Center(child: child) // TODO(ianh): figure out a way to compell
the child to have gray text when disabled... | 39 child: new Center(child: child) // TODO(ianh): figure out a way to compell
the child to have gray text when disabled... |
| 38 ); | 40 ); |
| 39 return new Listener( | 41 return new Listener( |
| 40 child: new Container( | 42 child: new Container( |
| 41 height: 36.0, | 43 height: 36.0, |
| 42 constraints: new BoxConstraints(minWidth: 88.0), | 44 constraints: new BoxConstraints(minWidth: 88.0), |
| 43 margin: new EdgeDims.all(8.0), | 45 margin: new EdgeDims.all(8.0), |
| 44 child: new Material( | 46 child: new Material( |
| 45 type: MaterialType.button, | 47 type: MaterialType.button, |
| 46 child: enabled ? new InkWell(child: contents) : contents, | 48 child: enabled ? new InkWell(child: contents) : contents, |
| 47 level: level, | 49 level: level, |
| 48 color: color | 50 color: color |
| 49 ) | 51 ) |
| 50 ), | 52 ), |
| 51 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } | 53 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } |
| 52 ); | 54 ); |
| 53 } | 55 } |
| 54 | 56 |
| 55 } | 57 } |
| OLD | NEW |