| 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 'material.dart'; | 8 import 'material.dart'; |
| 8 import "theme.dart"; | 9 import "theme.dart"; |
| 9 | 10 |
| 10 class Dialog extends Component { | 11 class Dialog extends Component { |
| 11 Dialog({ | 12 Dialog({ |
| 12 String key, | 13 String key, |
| 13 this.title, | 14 this.title, |
| 14 this.content, | 15 this.content, |
| 15 this.actions, | 16 this.actions, |
| 16 this.onDismiss | 17 this.onDismiss |
| 17 }) : super(key: key); | 18 }) : super(key: key); |
| 18 | 19 |
| 19 final Widget title; | 20 final Widget title; |
| 20 final Widget content; | 21 final Widget content; |
| 21 final Widget actions; | 22 final List<Widget> actions; |
| 22 final Function onDismiss; | 23 final Function onDismiss; |
| 23 | 24 |
| 24 Color get color { | 25 Color get color { |
| 25 switch (Theme.of(this).brightness) { | 26 switch (Theme.of(this).brightness) { |
| 26 case ThemeBrightness.light: | 27 case ThemeBrightness.light: |
| 27 return colors.White; | 28 return colors.White; |
| 28 case ThemeBrightness.dark: | 29 case ThemeBrightness.dark: |
| 29 return colors.Grey[800]; | 30 return colors.Grey[800]; |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 | 33 |
| 33 Widget build() { | 34 Widget build() { |
| 34 Container mask = new Container( | 35 Container mask = new Container( |
| 35 decoration: const BoxDecoration( | 36 decoration: const BoxDecoration( |
| 36 backgroundColor: const Color(0x7F000000))); | 37 backgroundColor: const Color(0x7F000000))); |
| 37 | 38 |
| 38 List<Widget> children = new List<Widget>(); | 39 List<Widget> children = new List<Widget>(); |
| 39 | 40 |
| 40 if (title != null) | 41 if (title != null) { |
| 41 children.add(title); | 42 children.add(new Padding( |
| 43 padding: new EdgeDims(24.0, 24.0, content == null ? 20.0 : 0.0, 24.0), |
| 44 child: new DefaultTextStyle( |
| 45 style: Theme.of(this).text.title, |
| 46 child: title |
| 47 ) |
| 48 )); |
| 49 } |
| 42 | 50 |
| 43 if (content != null) | 51 if (content != null) { |
| 44 children.add(content); | 52 children.add(new Padding( |
| 53 padding: const EdgeDims(20.0, 24.0, 24.0, 24.0), |
| 54 child: new DefaultTextStyle( |
| 55 style: Theme.of(this).text.subhead, |
| 56 child: content |
| 57 ) |
| 58 )); |
| 59 } |
| 45 | 60 |
| 46 if (actions != null) | 61 if (actions != null) |
| 47 children.add(actions); | 62 children.add(new Flex(actions, justifyContent: FlexJustifyContent.flexEnd)
); |
| 48 | 63 |
| 49 return new Stack([ | 64 return new Stack([ |
| 50 new Listener( | 65 new Listener( |
| 51 child: mask, | 66 child: mask, |
| 52 onGestureTap: (_) => onDismiss() | 67 onGestureTap: (_) => onDismiss() |
| 53 ), | 68 ), |
| 54 new Center( | 69 new Center( |
| 55 child: new ConstrainedBox( | 70 child: new Container( |
| 56 constraints: new BoxConstraints(minWidth: 280.0), | 71 margin: new EdgeDims.symmetric(horizontal: 40.0, vertical: 24.0), |
| 57 child: new Material( | 72 child: new ConstrainedBox( |
| 58 level: 4, | 73 constraints: new BoxConstraints(minWidth: 280.0), |
| 59 color: color, | 74 child: new Material( |
| 60 child: new ShrinkWrapWidth( | 75 level: 4, |
| 61 child: new Block(children) | 76 color: color, |
| 77 child: new ShrinkWrapWidth( |
| 78 child: new Block(children) |
| 79 ) |
| 62 ) | 80 ) |
| 63 ) | 81 ) |
| 64 ) | 82 ) |
| 65 ) | 83 ) |
| 66 ]); | 84 ]); |
| 67 } | 85 } |
| 68 } | 86 } |
| OLD | NEW |