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

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

Issue 1235443002: Support for icon theming (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix tests 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
OLDNEW
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 'package:sky/widgets/theme.dart'; 5 import 'package:sky/widgets/theme.dart';
6 6
7 import '../painting/text_style.dart';
7 import '../rendering/flex.dart'; 8 import '../rendering/flex.dart';
9 import '../theme/colors.dart' as colors;
8 import '../theme/shadows.dart'; 10 import '../theme/shadows.dart';
11 import '../theme/typography.dart' as typography;
9 import '../theme/view_configuration.dart'; 12 import '../theme/view_configuration.dart';
10 import 'basic.dart'; 13 import 'basic.dart';
11 import 'default_text_style.dart'; 14 import 'default_text_style.dart';
15 import 'icon_theme.dart';
12 16
13 class ToolBar extends Component { 17 class ToolBar extends Component {
14 18
15 ToolBar({ 19 ToolBar({
16 String key, 20 String key,
17 this.left, 21 this.left,
18 this.center, 22 this.center,
19 this.right, 23 this.right,
20 this.backgroundColor 24 this.backgroundColor
21 }) : super(key: key); 25 }) : super(key: key);
22 26
23 final Widget left; 27 final Widget left;
24 final Widget center; 28 final Widget center;
25 final List<Widget> right; 29 final List<Widget> right;
26 final Color backgroundColor; 30 final Color backgroundColor;
27 31
28 Widget build() { 32 Widget build() {
33 Color toolbarColor = backgroundColor;
34 IconThemeColor iconThemeColor = IconThemeColor.white;
35 TextStyle defaultTextStyle = typography.white.title;
36 if (toolbarColor == null) {
37 ThemeData themeData = Theme.of(this);
38 toolbarColor = themeData.primaryColor;
39 if (themeData.primaryColorBrightness == ThemeBrightness.light) {
40 iconThemeColor = IconThemeColor.black;
41 defaultTextStyle = typography.black.title;
42 }
43 }
44
29 List<Widget> children = new List<Widget>(); 45 List<Widget> children = new List<Widget>();
30 if (left != null) 46 if (left != null)
31 children.add(left); 47 children.add(left);
32 48
33 if (center != null) { 49 if (center != null) {
34 children.add( 50 children.add(
35 new Flexible( 51 new Flexible(
36 child: new Padding( 52 child: new Padding(
37 child: new DefaultTextStyle( 53 child: new DefaultTextStyle(
38 style: Theme.of(this).toolbarText.title, 54 style: defaultTextStyle,
39 child: center 55 child: center
40 ), 56 ),
41 padding: new EdgeDims.only(left: 24.0) 57 padding: new EdgeDims.only(left: 24.0)
42 ) 58 )
43 ) 59 )
44 ); 60 );
45 } 61 }
46 62
47 if (right != null) 63 if (right != null)
48 children.addAll(right); 64 children.addAll(right);
49 65
50 return new Container( 66 return new Container(
51 child: new Flex( 67 child: new IconTheme(
52 [new Container(child: new Flex(children), height: kToolBarHeight)], 68 data: new IconThemeData(color: iconThemeColor),
53 alignItems: FlexAlignItems.flexEnd 69 child: new Flex(
70 [new Container(child: new Flex(children), height: kToolBarHeight)],
71 alignItems: FlexAlignItems.flexEnd
72 )
54 ), 73 ),
55 padding: new EdgeDims.symmetric(horizontal: 8.0), 74 padding: new EdgeDims.symmetric(horizontal: 8.0),
56 decoration: new BoxDecoration( 75 decoration: new BoxDecoration(
57 backgroundColor: backgroundColor == null ? Theme.of(this).primaryColor : backgroundColor, 76 backgroundColor: toolbarColor,
58 boxShadow: shadows[2] 77 boxShadow: shadows[2]
59 ) 78 )
60 ); 79 );
61 } 80 }
62 81
63 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698