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

Side by Side Diff: sky/sdk/lib/widgets/material_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/flat_button.dart ('k') | sky/sdk/lib/widgets/raised_button.dart » ('j') | 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';
6 import '../theme2/edges.dart';
7 import 'basic.dart'; 5 import 'basic.dart';
8 import 'button_base.dart'; 6 import 'button_base.dart';
9 import 'ink_well.dart'; 7 import 'ink_well.dart';
10 import 'material.dart'; 8 import 'material.dart';
11 9
12 enum RaisedButtonTheme { light, dark } 10 // Rather than using this class directly, please use FlatButton or RaisedButton.
11 abstract class MaterialButton extends ButtonBase {
13 12
14 class RaisedButton extends ButtonBase { 13 MaterialButton({
15
16 RaisedButton({
17 String key, 14 String key,
18 this.child, 15 this.child,
19 this.enabled: true, 16 this.enabled: true,
20 this.onPressed, 17 this.onPressed
21 this.theme: RaisedButtonTheme.light
22 }) : super(key: key); 18 }) : super(key: key);
23 19
24 Widget child; 20 Widget child;
25 bool enabled; 21 bool enabled;
26 Function onPressed; 22 Function onPressed;
27 RaisedButtonTheme theme;
28 23
29 void syncFields(RaisedButton source) { 24 void syncFields(MaterialButton source) {
30 child = source.child; 25 child = source.child;
31 enabled = source.enabled; 26 enabled = source.enabled;
32 onPressed = source.onPressed; 27 onPressed = source.onPressed;
33 theme = source.theme;
34 super.syncFields(source); 28 super.syncFields(source);
35 } 29 }
36 30
31 Color get color;
32 int get level;
33
37 Widget buildContent() { 34 Widget buildContent() {
38 Widget contents = new Container( 35 Widget contents = new Container(
39 padding: new EdgeDims.symmetric(horizontal: 8.0), 36 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... 37 child: new Center(child: child) // TODO(ianh): figure out a way to compell the child to have gray text when disabled...
41 ); 38 );
42 Color color;
43 if (enabled) {
44 switch (theme) {
45 case RaisedButtonTheme.light:
46 if (highlight)
47 color = Grey[350];
48 else
49 color = Grey[300];
50 break;
51 case RaisedButtonTheme.dark:
52 if (highlight)
53 color = Blue[700];
54 else
55 color = Blue[600];
56 break;
57 }
58 } else {
59 color = Grey[350];
60 }
61 return new EventListenerNode( 39 return new EventListenerNode(
62 new Container( 40 new Container(
63 height: 36.0, 41 height: 36.0,
64 constraints: new BoxConstraints(minWidth: 88.0), 42 constraints: new BoxConstraints(minWidth: 88.0,
65 margin: new EdgeDims.all(4.0), 43 minHeight: 36.0,
44 maxHeight: 36.0),
45 margin: new EdgeDims.all(8.0),
66 child: new Material( 46 child: new Material(
67 edge: MaterialEdge.card,
68 child: enabled ? new InkWell(child: contents) : contents, 47 child: enabled ? new InkWell(child: contents) : contents,
69 level: enabled ? (highlight ? 2 : 1) : 0, 48 level: level,
70 color: color 49 color: color
71 ) 50 )
72 ), 51 ),
73 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); } 52 onGestureTap: (_) { if (onPressed != null && enabled) onPressed(); }
74 ); 53 );
75 } 54 }
76 55
77 } 56 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/flat_button.dart ('k') | sky/sdk/lib/widgets/raised_button.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698