Chromium Code Reviews| 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 '../theme/colors.dart' as colors; | 5 import '../theme/colors.dart' as colors; |
| 6 import 'basic.dart'; | 6 import 'basic.dart'; |
| 7 import 'default_text_style.dart'; | 7 import 'default_text_style.dart'; |
| 8 import 'material.dart'; | 8 import 'material.dart'; |
| 9 import "theme.dart"; | 9 import "theme.dart"; |
| 10 | 10 |
| 11 /// A material design dialog | |
| 12 /// | |
| 13 /// <https://www.google.com/design/spec/components/dialogs.html> | |
| 11 class Dialog extends Component { | 14 class Dialog extends Component { |
| 12 Dialog({ | 15 Dialog({ |
| 13 String key, | 16 String key, |
| 14 this.title, | 17 this.title, |
| 15 this.content, | 18 this.content, |
| 16 this.actions, | 19 this.actions, |
| 17 this.onDismiss | 20 this.onDismiss |
| 18 }) : super(key: key); | 21 }) : super(key: key); |
| 19 | 22 |
| 23 /// The (optional) title of the dialog is displayed in a large font at the top | |
|
Hixie
2015/07/08 15:10:57
This is an interesting convention (putting the doc
abarth-chromium
2015/07/08 15:29:29
I was just experimenting with different approaches
| |
| 24 /// of the dialog. | |
| 20 final Widget title; | 25 final Widget title; |
| 26 | |
| 27 /// The (optional) content of the dialog is displayed in the center of the | |
| 28 /// dialog in a lighter font. | |
| 21 final Widget content; | 29 final Widget content; |
| 30 | |
| 31 /// The (optional) set of actions that are displayed at the bottom of the | |
| 32 /// dialog. | |
| 22 final List<Widget> actions; | 33 final List<Widget> actions; |
| 34 | |
| 35 /// An (optional) callback that is called when the dialog is dismissed. | |
| 23 final Function onDismiss; | 36 final Function onDismiss; |
| 24 | 37 |
| 25 Color get color { | 38 Color get _color { |
| 26 switch (Theme.of(this).brightness) { | 39 switch (Theme.of(this).brightness) { |
| 27 case ThemeBrightness.light: | 40 case ThemeBrightness.light: |
| 28 return colors.White; | 41 return colors.White; |
| 29 case ThemeBrightness.dark: | 42 case ThemeBrightness.dark: |
| 30 return colors.Grey[800]; | 43 return colors.Grey[800]; |
| 31 } | 44 } |
| 32 } | 45 } |
| 33 | 46 |
| 34 Widget build() { | 47 Widget build() { |
| 35 Container mask = new Container( | 48 Container mask = new Container( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 66 child: mask, | 79 child: mask, |
| 67 onGestureTap: (_) => onDismiss() | 80 onGestureTap: (_) => onDismiss() |
| 68 ), | 81 ), |
| 69 new Center( | 82 new Center( |
| 70 child: new Container( | 83 child: new Container( |
| 71 margin: new EdgeDims.symmetric(horizontal: 40.0, vertical: 24.0), | 84 margin: new EdgeDims.symmetric(horizontal: 40.0, vertical: 24.0), |
| 72 child: new ConstrainedBox( | 85 child: new ConstrainedBox( |
| 73 constraints: new BoxConstraints(minWidth: 280.0), | 86 constraints: new BoxConstraints(minWidth: 280.0), |
| 74 child: new Material( | 87 child: new Material( |
| 75 level: 4, | 88 level: 4, |
| 76 color: color, | 89 color: _color, |
| 77 child: new ShrinkWrapWidth( | 90 child: new ShrinkWrapWidth( |
| 78 child: new Block(children) | 91 child: new Block(children) |
| 79 ) | 92 ) |
| 80 ) | 93 ) |
| 81 ) | 94 ) |
| 82 ) | 95 ) |
| 83 ) | 96 ) |
| 84 ]); | 97 ]); |
| 85 } | 98 } |
| 86 } | 99 } |
| OLD | NEW |