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

Side by Side Diff: sky/sdk/lib/widgets/snack_bar.dart

Issue 1216613004: Initial implementation of SnackBar (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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/scaffold.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:sky' as sky;
6
7 import '../painting/text_style.dart';
8 import '../theme/typography.dart' as typography;
9 import 'flat_button.dart';
10 import 'basic.dart';
11 import 'default_text_style.dart';
12 import 'material.dart';
13 import 'theme.dart';
14
15 class SnackBarAction extends Component {
16 SnackBarAction({String key, this.label, this.onPressed }) : super(key: key) {
17 assert(label != null);
18 }
19
20 final String label;
21 final Function onPressed;
22
23 void syncFields(SnackBarAction source) {
24 label = source.label;
25 onPressed = source.onPressed;
26 super.syncFields(source);
27 }
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
28
29 Widget build() {
30 return new Listener(
31 onGestureTap: (_) => onPressed(),
32 child: new Container(
33 margin: const EdgeDims.only(left: 24.0),
34 padding: const EdgeDims.only(top: 14.0, bottom: 14.0),
35 child: new Text(label)
36 )
37 );
38 }
39 }
40
41 class SnackBar extends Component {
42
43 SnackBar({
44 String key,
45 this.content,
46 this.actions
47 }) : super(key: key) {
48 assert(content != null);
49 }
50
51 final Widget content;
52 final List<SnackBarAction> actions;
53
54 void syncFields(SnackBar source) {
55 content = source.children;
56 actions = source.actions;
57 super.syncFields(source);
58 }
abarth-chromium 2015/07/06 15:16:45 ditto
59
60 Widget build() {
61 List<Widget> children = [
62 new Flexible(
63 child: new Container(
64 margin: const EdgeDims.symmetric(vertical: 14.0),
65 child: new DefaultTextStyle(
66 style: typography.white.subhead,
67 child: content
68 )
69 )
70 )
71 ]..addAll(actions);
72 return new Material(
73 level: 2,
74 color: const Color(0xFF323232),
75 type: MaterialType.canvas,
76 child: new Container(
77 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.
78 child: new DefaultTextStyle(
79 style: new TextStyle(color: Theme.of(this).accentColor),
80 child: new Flex(children)
81 )
82 )
83 );
84 }
85 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/scaffold.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698