Chromium Code Reviews| Index: sky/sdk/lib/widgets/raised_button.dart |
| diff --git a/sky/sdk/lib/widgets/raised_button.dart b/sky/sdk/lib/widgets/raised_button.dart |
| index 9489d7bd793a03186e0971f9191bd717ff9bb573..ab5ae0716f7c4e0472a4e87940976f84190f9bd1 100644 |
| --- a/sky/sdk/lib/widgets/raised_button.dart |
| +++ b/sky/sdk/lib/widgets/raised_button.dart |
| @@ -13,21 +13,32 @@ enum RaisedButtonTheme { light, dark } |
| class RaisedButton extends ButtonBase { |
| - RaisedButton({ Object key, this.child, this.onPressed, this.theme: RaisedButtonTheme.light }) : super(key: key); |
| + RaisedButton({ |
| + Object key, |
| + this.child, |
| + this.enabled: true, |
| + this.onPressed, |
| + this.theme: RaisedButtonTheme.light |
| + }) : super(key: key); |
| UINode child; |
| - int level; |
| + bool enabled; |
| Function onPressed; |
| RaisedButtonTheme theme; |
| void syncFields(RaisedButton source) { |
| child = source.child; |
| - level = source.level; |
| + enabled = source.enabled; |
| onPressed = source.onPressed; |
| + theme = source.theme; |
| super.syncFields(source); |
| } |
| UINode buildContent() { |
| + UINode contents = new Container( |
| + padding: new EdgeDims.symmetric(horizontal: 8.0), |
| + child: new Center(child: child) // TODO(ianh): figure out a way to compell the child to have gray text when disabled... |
| + ); |
| return new EventListenerNode( |
| new Container( |
| height: 36.0, |
| @@ -35,19 +46,14 @@ class RaisedButton extends ButtonBase { |
| margin: new EdgeDims.all(4.0), |
| child: new Material( |
| edge: MaterialEdge.card, |
| - child: new InkWell( |
| - child: new Container( |
| - padding: new EdgeDims.symmetric(horizontal: 8.0), |
| - child: new Center(child: child) |
| - ) |
| - ), |
| - level: highlight ? 2 : 1, |
| + child: enabled ? new InkWell(child: contents) : contents, |
| + level: enabled ? (highlight ? 2 : 1) : 0, |
| color: theme == RaisedButtonTheme.light |
|
jackson
2015/06/16 00:16:01
might want to work this out ahead of time for read
|
| - ? (highlight ? Grey[350] : Grey[300]) |
| - : (highlight ? Blue[700] : Blue[600]) |
| + ? (enabled ? (highlight ? Grey[350] : Grey[300]) : (Grey[350])) |
| + : (enabled ? (highlight ? Blue[700] : Blue[600]) : (Grey[350])) |
| ) |
| ), |
| - onGestureTap: (_) { if (onPressed != null) onPressed(); } |
| + onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } |
| ); |
| } |