Commit 6c38fc1b authored by Collin Jackson's avatar Collin Jackson

Add a new Theme widget to control color and text color of apps

R=abarth@chromium.org, abarth, hixie

Review URL: https://codereview.chromium.org/1194743003.
parent 639e47bd
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:sky/rendering/sky_binding.dart'; import 'package:sky/rendering/sky_binding.dart';
import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/theme/theme_data.dart';
import 'package:sky/theme/typography.dart' as typography;
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/navigator.dart'; import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/widget.dart'; import 'package:sky/widgets/widget.dart';
import 'stock_data.dart'; import 'stock_data.dart';
...@@ -46,7 +50,10 @@ class StocksApp extends App { ...@@ -46,7 +50,10 @@ class StocksApp extends App {
} }
Widget build() { Widget build() {
return new Navigator(_navigationState); return new Theme(
data: new ThemeData(color: colors.Purple, text: typography.white),
child: new Navigator(_navigationState)
);
} }
} }
......
...@@ -169,8 +169,7 @@ class StockHome extends Component { ...@@ -169,8 +169,7 @@ class StockHome extends Component {
new IconButton( new IconButton(
icon: 'navigation/more_vert_white', icon: 'navigation/more_vert_white',
onPressed: _handleMenuShow) onPressed: _handleMenuShow)
], ]
backgroundColor: colors.Purple[500]
); );
} }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:sky/theme/colors.dart' as colors; import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/theme/typography.dart' as typography;
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/checkbox.dart'; import 'package:sky/widgets/checkbox.dart';
import 'package:sky/widgets/icon_button.dart'; import 'package:sky/widgets/icon_button.dart';
import 'package:sky/widgets/menu_item.dart'; import 'package:sky/widgets/menu_item.dart';
import 'package:sky/widgets/navigator.dart'; import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/scaffold.dart'; import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/tool_bar.dart';
class StockSettings extends Component { class StockSettings extends Component {
...@@ -30,8 +30,7 @@ class StockSettings extends Component { ...@@ -30,8 +30,7 @@ class StockSettings extends Component {
left: new IconButton( left: new IconButton(
icon: 'navigation/arrow_back_white', icon: 'navigation/arrow_back_white',
onPressed: _navigator.pop), onPressed: _navigator.pop),
center: new Text('Settings', style: typography.white.title), center: new Text('Settings', style: Theme.of(this).text.title)
backgroundColor: colors.Purple[500]
); );
} }
......
...@@ -7,13 +7,15 @@ import 'dart:math' as math; ...@@ -7,13 +7,15 @@ import 'dart:math' as math;
import 'package:sky/rendering/box.dart'; import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/flex.dart'; import 'package:sky/rendering/flex.dart';
import 'package:sky/rendering/sky_binding.dart'; import 'package:sky/rendering/sky_binding.dart';
import 'package:sky/theme/colors.dart'; import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/theme/edges.dart'; import 'package:sky/theme/edges.dart';
import 'package:sky/theme/typography.dart'; import 'package:sky/theme/theme_data.dart';
import 'package:sky/theme/typography.dart' as typography;
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/material.dart'; import 'package:sky/widgets/material.dart';
import 'package:sky/widgets/raised_button.dart'; import 'package:sky/widgets/raised_button.dart';
import 'package:sky/widgets/scaffold.dart'; import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/tool_bar.dart';
import 'package:sky/widgets/widget.dart'; import 'package:sky/widgets/widget.dart';
...@@ -74,61 +76,63 @@ class SectorApp extends App { ...@@ -74,61 +76,63 @@ class SectorApp extends App {
} }
Widget build() { Widget build() {
return new Scaffold( return new Theme(
toolbar: new ToolBar( data: new ThemeData(color: colors.Blue, text: typography.white),
center: new Text('Sector Layout in a Widget Tree', style: white.title), child: new Scaffold(
backgroundColor: Blue[500]), toolbar: new ToolBar(
body: new Material( center: new Text('Sector Layout in a Widget Tree', style: typography.white.title)),
edge: MaterialEdge.canvas, body: new Material(
child: new Flex([ edge: MaterialEdge.canvas,
new Container( child: new Flex([
padding: new EdgeDims.symmetric(horizontal: 8.0, vertical: 25.0), new Container(
child: new Flex([ padding: new EdgeDims.symmetric(horizontal: 8.0, vertical: 25.0),
new RaisedButton( child: new Flex([
enabled: enabledAdd, new RaisedButton(
child: new ShrinkWrapWidth( enabled: enabledAdd,
child: new Flex([ child: new ShrinkWrapWidth(
new Container( child: new Flex([
padding: new EdgeDims.all(4.0), new Container(
margin: new EdgeDims.only(right: 10.0), padding: new EdgeDims.all(4.0),
child: new WidgetToRenderBoxAdapter(sectorAddIcon) margin: new EdgeDims.only(right: 10.0),
), child: new WidgetToRenderBoxAdapter(sectorAddIcon)
new Text('ADD SECTOR'), ),
]) new Text('ADD SECTOR'),
])
),
onPressed: addSector
), ),
onPressed: addSector new RaisedButton(
enabled: enabledRemove,
child: new ShrinkWrapWidth(
child: new Flex([
new Container(
padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(sectorRemoveIcon)
),
new Text('REMOVE SECTOR'),
])
),
onPressed: removeSector
)
],
justifyContent: FlexJustifyContent.spaceAround
)
),
new Flexible(
child: new Container(
margin: new EdgeDims.all(8.0),
decoration: new BoxDecoration(
border: new Border.all(new BorderSide(color: new Color(0xFF000000)))
), ),
new RaisedButton( padding: new EdgeDims.all(8.0),
enabled: enabledRemove, child: new WidgetToRenderBoxAdapter(sectors)
child: new ShrinkWrapWidth( )
child: new Flex([ ),
new Container( ],
padding: new EdgeDims.all(4.0), direction: FlexDirection.vertical,
margin: new EdgeDims.only(right: 10.0), justifyContent: FlexJustifyContent.spaceBetween
child: new WidgetToRenderBoxAdapter(sectorRemoveIcon) )
),
new Text('REMOVE SECTOR'),
])
),
onPressed: removeSector
)
],
justifyContent: FlexJustifyContent.spaceAround
)
),
new Flexible(
child: new Container(
margin: new EdgeDims.all(8.0),
decoration: new BoxDecoration(
border: new Border.all(new BorderSide(color: new Color(0xFF000000)))
),
padding: new EdgeDims.all(8.0),
child: new WidgetToRenderBoxAdapter(sectors)
)
),
],
direction: FlexDirection.vertical,
justifyContent: FlexJustifyContent.spaceBetween
) )
) )
); );
......
...@@ -7,10 +7,12 @@ import 'package:sky/rendering/box.dart'; ...@@ -7,10 +7,12 @@ import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/flex.dart'; import 'package:sky/rendering/flex.dart';
import 'package:sky/rendering/sky_binding.dart'; import 'package:sky/rendering/sky_binding.dart';
import 'package:sky/theme/colors.dart'; import 'package:sky/theme/colors.dart';
import 'package:sky/theme/theme_data.dart';
import 'package:sky/theme/typography.dart'; import 'package:sky/theme/typography.dart';
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/material.dart'; import 'package:sky/widgets/material.dart';
import 'package:sky/widgets/scaffold.dart'; import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/theme.dart';
import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/tool_bar.dart';
import 'package:sky/widgets/widget.dart'; import 'package:sky/widgets/widget.dart';
...@@ -105,11 +107,13 @@ HAL: This mission is too important for me to allow you to jeopardize it.'''; ...@@ -105,11 +107,13 @@ HAL: This mission is too important for me to allow you to jeopardize it.''';
onPointerDown: toggleToTextFunction onPointerDown: toggleToTextFunction
); );
return new Scaffold( return new Theme(
body: new Material(child: interactiveBody), data: new ThemeData(color: Blue, text: white),
toolbar: new ToolBar( child: new Scaffold(
center: new Text('Hal and Dave', style: white.title), body: new Material(child: interactiveBody),
backgroundColor: Blue[500] toolbar: new ToolBar(
center: new Text('Hal and Dave', style: white.title)
)
) )
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment