Commit 729efa25 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Propagate platform through the subsidiary themes. (#6396)

Since we can change the theme's platform, we need to make sure we
propagate that throughout rather than having half the app use the native
platform and half the app use the selected platform.
parent 039c2715
...@@ -162,7 +162,8 @@ class KeyPad extends StatelessWidget { ...@@ -162,7 +162,8 @@ class KeyPad extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData themeData = new ThemeData( final ThemeData themeData = new ThemeData(
primarySwatch: Colors.purple, primarySwatch: Colors.purple,
brightness: Brightness.dark brightness: Brightness.dark,
platform: Theme.of(context).platform,
); );
return new Theme( return new Theme(
data: themeData, data: themeData,
......
...@@ -99,7 +99,8 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -99,7 +99,8 @@ class ContactsDemoState extends State<ContactsDemo> {
return new Theme( return new Theme(
data: new ThemeData( data: new ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
primarySwatch: Colors.indigo primarySwatch: Colors.indigo,
platform: Theme.of(context).platform,
), ),
child: new Scaffold( child: new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
......
...@@ -82,7 +82,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -82,7 +82,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final double statusBarHeight = MediaQuery.of(context).padding.top; final double statusBarHeight = MediaQuery.of(context).padding.top;
return new Theme( return new Theme(
data: _kTheme, data: _kTheme.copyWith(platform: Theme.of(context).platform),
child: new Scaffold( child: new Scaffold(
key: scaffoldKey, key: scaffoldKey,
scrollableKey: config.scrollableKey, scrollableKey: config.scrollableKey,
...@@ -168,7 +168,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -168,7 +168,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
settings: const RouteSettings(name: "/pesto/recipe"), settings: const RouteSettings(name: "/pesto/recipe"),
builder: (BuildContext context) { builder: (BuildContext context) {
return new Theme( return new Theme(
data: _kTheme, data: _kTheme.copyWith(platform: Theme.of(context).platform),
child: new RecipePage(recipe: recipe) child: new RecipePage(recipe: recipe)
); );
} }
......
...@@ -10,11 +10,12 @@ import 'shrine/shrine_theme.dart' show ShrineTheme; ...@@ -10,11 +10,12 @@ import 'shrine/shrine_theme.dart' show ShrineTheme;
// This code would ordinarily be part of the MaterialApp's home. It's being // This code would ordinarily be part of the MaterialApp's home. It's being
// used by the ShrineDemo and by each route pushed from there because this // used by the ShrineDemo and by each route pushed from there because this
// isn't a standalone app with its own main() and MaterialApp. // isn't a standalone app with its own main() and MaterialApp.
Widget buildShrine(Widget child) { Widget buildShrine(BuildContext context, Widget child) {
return new Theme( return new Theme(
data: new ThemeData( data: new ThemeData(
primarySwatch: Colors.grey, primarySwatch: Colors.grey,
iconTheme: new IconThemeData(color: const Color(0xFF707070)) iconTheme: new IconThemeData(color: const Color(0xFF707070)),
platform: Theme.of(context).platform,
), ),
child: new ShrineTheme(child: child) child: new ShrineTheme(child: child)
); );
...@@ -29,7 +30,7 @@ class ShrinePageRoute<T> extends MaterialPageRoute<T> { ...@@ -29,7 +30,7 @@ class ShrinePageRoute<T> extends MaterialPageRoute<T> {
@override @override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> forwardAnimation) { Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> forwardAnimation) {
return buildShrine(super.buildPage(context, animation, forwardAnimation)); return buildShrine(context, super.buildPage(context, animation, forwardAnimation));
} }
} }
...@@ -37,5 +38,5 @@ class ShrineDemo extends StatelessWidget { ...@@ -37,5 +38,5 @@ class ShrineDemo extends StatelessWidget {
static const String routeName = '/shrine'; // Used by the Gallery app. static const String routeName = '/shrine'; // Used by the Gallery app.
@override @override
Widget build(BuildContext context) => buildShrine(new ShrineHome()); Widget build(BuildContext context) => buildShrine(context, new ShrineHome());
} }
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