Chromium Code Reviews| Index: sky/sdk/lib/widgets/snack_bar.dart |
| diff --git a/sky/sdk/lib/widgets/snack_bar.dart b/sky/sdk/lib/widgets/snack_bar.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ebb26787f5f6f056d125e55874378afe992759a9 |
| --- /dev/null |
| +++ b/sky/sdk/lib/widgets/snack_bar.dart |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +import 'dart:sky' as sky; |
| + |
| +import '../painting/text_style.dart'; |
| +import '../theme/typography.dart' as typography; |
| +import 'flat_button.dart'; |
| +import 'basic.dart'; |
| +import 'default_text_style.dart'; |
| +import 'material.dart'; |
| +import 'theme.dart'; |
| + |
| +class SnackBarAction extends Component { |
| + SnackBarAction({String key, this.label, this.onPressed }) : super(key: key) { |
| + assert(label != null); |
| + } |
| + |
| + final String label; |
| + final Function onPressed; |
| + |
| + void syncFields(SnackBarAction source) { |
| + label = source.label; |
| + onPressed = source.onPressed; |
| + super.syncFields(source); |
| + } |
|
abarth-chromium
2015/07/06 15:16:45
We should probably remove this function. |label|
jackson
2015/07/06 15:30:58
Agree, but as we discussed, we should probably hav
|
| + |
| + Widget build() { |
| + return new Listener( |
| + onGestureTap: (_) => onPressed(), |
| + child: new Container( |
| + margin: const EdgeDims.only(left: 24.0), |
| + padding: const EdgeDims.only(top: 14.0, bottom: 14.0), |
| + child: new Text(label) |
| + ) |
| + ); |
| + } |
| +} |
| + |
| +class SnackBar extends Component { |
| + |
| + SnackBar({ |
| + String key, |
| + this.content, |
| + this.actions |
| + }) : super(key: key) { |
| + assert(content != null); |
| + } |
| + |
| + final Widget content; |
| + final List<SnackBarAction> actions; |
| + |
| + void syncFields(SnackBar source) { |
| + content = source.children; |
| + actions = source.actions; |
| + super.syncFields(source); |
| + } |
|
abarth-chromium
2015/07/06 15:16:45
ditto
|
| + |
| + Widget build() { |
| + List<Widget> children = [ |
| + new Flexible( |
| + child: new Container( |
| + margin: const EdgeDims.symmetric(vertical: 14.0), |
| + child: new DefaultTextStyle( |
| + style: typography.white.subhead, |
| + child: content |
| + ) |
| + ) |
| + ) |
| + ]..addAll(actions); |
| + return new Material( |
| + level: 2, |
| + color: const Color(0xFF323232), |
| + type: MaterialType.canvas, |
| + child: new Container( |
| + margin: const EdgeDims.symmetric(horizontal: 24.0), |
|
abarth-chromium
2015/07/06 15:16:45
Why margin rather than padding? I guess it does't
jackson
2015/07/06 15:30:58
Yeah.
|
| + child: new DefaultTextStyle( |
| + style: new TextStyle(color: Theme.of(this).accentColor), |
| + child: new Flex(children) |
| + ) |
| + ) |
| + ); |
| + } |
| +} |