Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: sky/sdk/lib/widgets/raised_button.dart

Issue 1179943005: Make RaisedButton support being disabled. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/theme2/colors.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(); }
);
}
« no previous file with comments | « sky/sdk/lib/theme2/colors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698