| 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 'package:sky/widgets/theme.dart'; | 5 import 'package:sky/widgets/theme.dart'; |
| 6 | 6 |
| 7 import '../painting/text_style.dart'; | 7 import '../painting/text_style.dart'; |
| 8 import '../rendering/flex.dart'; | 8 import '../rendering/flex.dart'; |
| 9 import '../theme/shadows.dart'; | 9 import '../theme/shadows.dart'; |
| 10 import '../theme/typography.dart' as typography; | 10 import '../theme/typography.dart' as typography; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 this.backgroundColor | 23 this.backgroundColor |
| 24 }) : super(key: key); | 24 }) : super(key: key); |
| 25 | 25 |
| 26 final Widget left; | 26 final Widget left; |
| 27 final Widget center; | 27 final Widget center; |
| 28 final List<Widget> right; | 28 final List<Widget> right; |
| 29 final Color backgroundColor; | 29 final Color backgroundColor; |
| 30 | 30 |
| 31 Widget build() { | 31 Widget build() { |
| 32 Color toolbarColor = backgroundColor; | 32 Color toolbarColor = backgroundColor; |
| 33 IconThemeColor iconThemeColor = IconThemeColor.white; | 33 IconThemeData iconThemeData; |
| 34 TextStyle defaultTextStyle = typography.white.title; | 34 TextStyle defaultTextStyle = typography.white.title; |
| 35 if (toolbarColor == null) { | 35 if (toolbarColor == null) { |
| 36 ThemeData themeData = Theme.of(this); | 36 ThemeData themeData = Theme.of(this); |
| 37 toolbarColor = themeData.primaryColor; | 37 toolbarColor = themeData.primaryColor; |
| 38 if (themeData.primaryColorBrightness == ThemeBrightness.light) { | 38 if (themeData.primaryColorBrightness == ThemeBrightness.light) { |
| 39 iconThemeColor = IconThemeColor.black; | |
| 40 defaultTextStyle = typography.black.title; | 39 defaultTextStyle = typography.black.title; |
| 40 iconThemeData = const IconThemeData(color: IconThemeColor.black); |
| 41 } else { |
| 42 iconThemeData = const IconThemeData(color: IconThemeColor.white); |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 List<Widget> children = new List<Widget>(); | 46 List<Widget> children = new List<Widget>(); |
| 45 if (left != null) | 47 if (left != null) |
| 46 children.add(left); | 48 children.add(left); |
| 47 | 49 |
| 48 if (center != null) { | 50 if (center != null) { |
| 49 children.add( | 51 children.add( |
| 50 new Flexible( | 52 new Flexible( |
| 51 child: new Padding( | 53 child: new Padding( |
| 52 child: new DefaultTextStyle( | 54 child: center, |
| 53 style: defaultTextStyle, | |
| 54 child: center | |
| 55 ), | |
| 56 padding: new EdgeDims.only(left: 24.0) | 55 padding: new EdgeDims.only(left: 24.0) |
| 57 ) | 56 ) |
| 58 ) | 57 ) |
| 59 ); | 58 ); |
| 60 } | 59 } |
| 61 | 60 |
| 62 if (right != null) | 61 if (right != null) |
| 63 children.addAll(right); | 62 children.addAll(right); |
| 64 | 63 |
| 65 return new Container( | 64 Widget content = new Container( |
| 66 child: new IconTheme( | 65 child: new DefaultTextStyle( |
| 67 data: new IconThemeData(color: iconThemeColor), | 66 style: defaultTextStyle, |
| 68 child: new Flex( | 67 child: new Flex( |
| 69 [new Container(child: new Flex(children), height: kToolBarHeight)], | 68 [new Container(child: new Flex(children), height: kToolBarHeight)], |
| 70 alignItems: FlexAlignItems.end | 69 alignItems: FlexAlignItems.end |
| 71 ) | 70 ) |
| 72 ), | 71 ), |
| 73 padding: new EdgeDims.symmetric(horizontal: 8.0), | 72 padding: new EdgeDims.symmetric(horizontal: 8.0), |
| 74 decoration: new BoxDecoration( | 73 decoration: new BoxDecoration( |
| 75 backgroundColor: toolbarColor, | 74 backgroundColor: toolbarColor, |
| 76 boxShadow: shadows[2] | 75 boxShadow: shadows[2] |
| 77 ) | 76 ) |
| 78 ); | 77 ); |
| 78 |
| 79 if (iconThemeData != null) |
| 80 content = new IconTheme(data: iconThemeData, child: content); |
| 81 return content; |
| 79 } | 82 } |
| 80 | 83 |
| 81 } | 84 } |
| OLD | NEW |