Use dark theme in GridTileBar (#6527)

* Use dark theme in GridTileBar

Reduce IconTheme, Typography hardcoding by applying a dark theme to the
contents. This is still not ideal; the theme brightness should really be
driven by backgroundColor.

* Add back IconTheme

Since IconTheme.of() finds the closest IconTheme, not the closest
IconTheme or Theme (which specifies IconThemeData), the previous commit
doesn't necessarily override any IconThemes futher up the tree.
This commit is contained in:
Chris Bracken
2016-10-27 13:15:10 -07:00
committed by GitHub
parent e0515f310b
commit ea5fd81557

View File

@@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart';
import 'colors.dart';
import 'icon_theme.dart';
import 'icon_theme_data.dart';
import 'typography.dart';
import 'theme.dart';
/// A header used in a material design [GridTile].
///
@@ -77,6 +77,12 @@ class GridTileBar extends StatelessWidget {
if (leading != null)
children.add(new Padding(padding: const EdgeInsets.only(right: 8.0), child: leading));
ThemeData theme = Theme.of(context);
ThemeData darkTheme = new ThemeData(
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness
);
if (title != null && subtitle != null) {
children.add(
new Flexible(
@@ -84,13 +90,13 @@ class GridTileBar extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new DefaultTextStyle(
style: Typography.white.subhead,
style: darkTheme.textTheme.subhead,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title
),
new DefaultTextStyle(
style: Typography.white.caption,
style: darkTheme.textTheme.caption,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: subtitle
@@ -103,7 +109,7 @@ class GridTileBar extends StatelessWidget {
children.add(
new Flexible(
child: new DefaultTextStyle(
style: Typography.white.subhead,
style: darkTheme.textTheme.subhead,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title ?? subtitle
@@ -118,12 +124,15 @@ class GridTileBar extends StatelessWidget {
return new Container(
padding: padding,
decoration: decoration,
child: new IconTheme.merge(
context: context,
data: new IconThemeData(color: Colors.white),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: children
child: new Theme(
data: darkTheme,
child: new IconTheme.merge(
context: context,
data: new IconThemeData(color: Colors.white),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: children
)
)
)
);