| 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 '../painting/text_style.dart'; | 5 import '../painting/text_style.dart'; |
| 6 import '../theme/typography.dart' as typography; | 6 import '../theme/typography.dart' as typography; |
| 7 import 'basic.dart'; | 7 import 'basic.dart'; |
| 8 import 'default_text_style.dart'; | 8 import 'default_text_style.dart'; |
| 9 import 'material.dart'; | 9 import 'material.dart'; |
| 10 import 'theme.dart'; | 10 import 'theme.dart'; |
| 11 | 11 |
| 12 class SnackBarAction extends Component { | 12 class SnackBarAction extends Component { |
| 13 SnackBarAction({String key, this.label, this.onPressed }) : super(key: key) { | 13 SnackBarAction({String key, this.label, this.onPressed }) : super(key: key) { |
| 14 assert(label != null); | 14 assert(label != null); |
| 15 } | 15 } |
| 16 | 16 |
| 17 final String label; | 17 final String label; |
| 18 final Function onPressed; | 18 final Function onPressed; |
| 19 | 19 |
| 20 @override |
| 20 Widget build() { | 21 Widget build() { |
| 21 return new Listener( | 22 return new Listener( |
| 22 onGestureTap: (_) => onPressed(), | 23 onGestureTap: (_) => onPressed(), |
| 23 child: new Container( | 24 child: new Container( |
| 24 margin: const EdgeDims.only(left: 24.0), | 25 margin: const EdgeDims.only(left: 24.0), |
| 25 padding: const EdgeDims.only(top: 14.0, bottom: 14.0), | 26 padding: const EdgeDims.only(top: 14.0, bottom: 14.0), |
| 26 child: new Text(label) | 27 child: new Text(label) |
| 27 ) | 28 ) |
| 28 ); | 29 ); |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 class SnackBar extends Component { | 33 class SnackBar extends Component { |
| 33 | 34 |
| 34 SnackBar({ | 35 SnackBar({ |
| 35 String key, | 36 String key, |
| 36 this.content, | 37 this.content, |
| 37 this.actions | 38 this.actions |
| 38 }) : super(key: key) { | 39 }) : super(key: key) { |
| 39 assert(content != null); | 40 assert(content != null); |
| 40 } | 41 } |
| 41 | 42 |
| 42 final Widget content; | 43 final Widget content; |
| 43 final List<SnackBarAction> actions; | 44 final List<SnackBarAction> actions; |
| 44 | 45 |
| 46 @override |
| 45 Widget build() { | 47 Widget build() { |
| 46 List<Widget> children = [ | 48 List<Widget> children = [ |
| 47 new Flexible( | 49 new Flexible( |
| 48 child: new Container( | 50 child: new Container( |
| 49 margin: const EdgeDims.symmetric(vertical: 14.0), | 51 margin: const EdgeDims.symmetric(vertical: 14.0), |
| 50 child: new DefaultTextStyle( | 52 child: new DefaultTextStyle( |
| 51 style: typography.white.subhead, | 53 style: typography.white.subhead, |
| 52 child: content | 54 child: content |
| 53 ) | 55 ) |
| 54 ) | 56 ) |
| 55 ) | 57 ) |
| 56 ]..addAll(actions); | 58 ]..addAll(actions); |
| 57 return new Material( | 59 return new Material( |
| 58 level: 2, | 60 level: 2, |
| 59 color: const Color(0xFF323232), | 61 color: const Color(0xFF323232), |
| 60 type: MaterialType.canvas, | 62 type: MaterialType.canvas, |
| 61 child: new Container( | 63 child: new Container( |
| 62 margin: const EdgeDims.symmetric(horizontal: 24.0), | 64 margin: const EdgeDims.symmetric(horizontal: 24.0), |
| 63 child: new DefaultTextStyle( | 65 child: new DefaultTextStyle( |
| 64 style: new TextStyle(color: Theme.of(this).accentColor), | 66 style: new TextStyle(color: Theme.of(this).accentColor), |
| 65 child: new Flex(children) | 67 child: new Flex(children) |
| 66 ) | 68 ) |
| 67 ) | 69 ) |
| 68 ); | 70 ); |
| 69 } | 71 } |
| 70 } | 72 } |
| OLD | NEW |