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

Side by Side Diff: sky/sdk/lib/widgets/raised_button.dart

Issue 1187773008: Add FlatButton (Closed) Base URL: git@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 unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/widgets/material_button.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'material_button.dart';
9 import 'ink_well.dart';
10 import 'material.dart';
11 9
12 enum RaisedButtonTheme { light, dark } 10 enum RaisedButtonTheme { light, dark }
13 11
14 class RaisedButton extends ButtonBase { 12 class RaisedButton extends MaterialButton {
15 13
16 RaisedButton({ 14 RaisedButton({
17 String key, 15 String key,
18 this.child, 16 Widget child,
19 this.enabled: true, 17 bool enabled: true,
20 this.onPressed, 18 Function onPressed,
21 this.theme: RaisedButtonTheme.light 19 this.theme: RaisedButtonTheme.light
22 }) : super(key: key); 20 }) : super(key: key, child: child, enabled: enabled, onPressed: onPressed);
23 21
24 Widget child;
25 bool enabled;
26 Function onPressed;
27 RaisedButtonTheme theme; 22 RaisedButtonTheme theme;
28 23
29 void syncFields(RaisedButton source) { 24 void syncFields(RaisedButton source) {
30 child = source.child;
31 enabled = source.enabled;
32 onPressed = source.onPressed;
33 theme = source.theme; 25 theme = source.theme;
34 super.syncFields(source); 26 super.syncFields(source);
35 } 27 }
36 28
37 Widget buildContent() { 29 Color get color {
38 Widget contents = new Container(
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...
41 );
42 Color color;
43 if (enabled) { 30 if (enabled) {
44 switch (theme) { 31 switch (theme) {
45 case RaisedButtonTheme.light: 32 case RaisedButtonTheme.light:
46 if (highlight) 33 if (highlight)
47 color = Grey[350]; 34 return Grey[350];
48 else 35 else
49 color = Grey[300]; 36 return Grey[300];
50 break; 37 break;
51 case RaisedButtonTheme.dark: 38 case RaisedButtonTheme.dark:
52 if (highlight) 39 if (highlight)
53 color = Blue[700]; 40 return Blue[700];
54 else 41 else
55 color = Blue[600]; 42 return Blue[600];
56 break; 43 break;
57 } 44 }
58 } else { 45 } else {
59 color = Grey[350]; 46 return Grey[350];
60 } 47 }
61 return new EventListenerNode(
62 new Container(
63 height: 36.0,
64 constraints: new BoxConstraints(minWidth: 88.0),
65 margin: new EdgeDims.all(4.0),
66 child: new Material(
67 edge: MaterialEdge.card,
68 child: enabled ? new InkWell(child: contents) : contents,
69 level: enabled ? (highlight ? 2 : 1) : 0,
70 color: color
71 )
72 ),
73 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); }
74 );
75 } 48 }
76 49
50 int get level => enabled ? (highlight ? 2 : 1) : 0;
77 } 51 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/material_button.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698