| 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 '../theme2/colors.dart'; | 5 import '../theme2/colors.dart'; |
| 6 import '../theme2/edges.dart'; | 6 import '../theme2/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 | 11 |
| 12 enum RaisedButtonTheme { light, dark } | 12 enum RaisedButtonTheme { light, dark } |
| 13 | 13 |
| 14 class RaisedButton extends ButtonBase { | 14 class RaisedButton extends ButtonBase { |
| 15 | 15 |
| 16 RaisedButton({ | 16 RaisedButton({ |
| 17 String key, | 17 String key, |
| 18 this.child, | 18 this.child, |
| 19 this.enabled: true, | 19 this.enabled: true, |
| 20 this.onPressed, | 20 this.onPressed, |
| 21 this.theme: RaisedButtonTheme.light | 21 this.theme: RaisedButtonTheme.light |
| 22 }) : super(key: key); | 22 }) : super(key: key); |
| 23 | 23 |
| 24 UINode child; | 24 Widget child; |
| 25 bool enabled; | 25 bool enabled; |
| 26 Function onPressed; | 26 Function onPressed; |
| 27 RaisedButtonTheme theme; | 27 RaisedButtonTheme theme; |
| 28 | 28 |
| 29 void syncFields(RaisedButton source) { | 29 void syncFields(RaisedButton source) { |
| 30 child = source.child; | 30 child = source.child; |
| 31 enabled = source.enabled; | 31 enabled = source.enabled; |
| 32 onPressed = source.onPressed; | 32 onPressed = source.onPressed; |
| 33 theme = source.theme; | 33 theme = source.theme; |
| 34 super.syncFields(source); | 34 super.syncFields(source); |
| 35 } | 35 } |
| 36 | 36 |
| 37 UINode buildContent() { | 37 Widget buildContent() { |
| 38 UINode contents = new Container( | 38 Widget contents = new Container( |
| 39 padding: new EdgeDims.symmetric(horizontal: 8.0), | 39 padding: new EdgeDims.symmetric(horizontal: 8.0), |
| 40 child: new Center(child: child) // TODO(ianh): figure out a way to compell
the child to have gray text when disabled... | 40 child: new Center(child: child) // TODO(ianh): figure out a way to compell
the child to have gray text when disabled... |
| 41 ); | 41 ); |
| 42 Color color; | 42 Color color; |
| 43 if (enabled) { | 43 if (enabled) { |
| 44 switch (theme) { | 44 switch (theme) { |
| 45 case RaisedButtonTheme.light: | 45 case RaisedButtonTheme.light: |
| 46 if (highlight) | 46 if (highlight) |
| 47 color = Grey[350]; | 47 color = Grey[350]; |
| 48 else | 48 else |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 child: enabled ? new InkWell(child: contents) : contents, | 68 child: enabled ? new InkWell(child: contents) : contents, |
| 69 level: enabled ? (highlight ? 2 : 1) : 0, | 69 level: enabled ? (highlight ? 2 : 1) : 0, |
| 70 color: color | 70 color: color |
| 71 ) | 71 ) |
| 72 ), | 72 ), |
| 73 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } | 73 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } |
| 74 ); | 74 ); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } | 77 } |
| OLD | NEW |