Commit ed4ca503 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Use typography from ThemeData in SnackBar (#6522)

Eliminates hardcoding of Typography.white in favour of picking up the
platform default typography from ThemeData.
parent 2ac7d67e
...@@ -11,7 +11,6 @@ import 'material.dart'; ...@@ -11,7 +11,6 @@ import 'material.dart';
import 'scaffold.dart'; import 'scaffold.dart';
import 'theme_data.dart'; import 'theme_data.dart';
import 'theme.dart'; import 'theme.dart';
import 'typography.dart';
// https://material.google.com/components/snackbars-toasts.html#snackbars-toasts-specs // https://material.google.com/components/snackbars-toasts.html#snackbars-toasts-specs
const double _kSnackBarPadding = 24.0; const double _kSnackBarPadding = 24.0;
...@@ -134,13 +133,19 @@ class SnackBar extends StatelessWidget { ...@@ -134,13 +133,19 @@ class SnackBar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(animation != null); assert(animation != null);
ThemeData theme = Theme.of(context);
ThemeData darkTheme = new ThemeData(
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness
);
List<Widget> children = <Widget>[ List<Widget> children = <Widget>[
const SizedBox(width: _kSnackBarPadding), const SizedBox(width: _kSnackBarPadding),
new Flexible( new Flexible(
child: new Container( child: new Container(
padding: const EdgeInsets.symmetric(vertical: _kSingleLineVerticalPadding), padding: const EdgeInsets.symmetric(vertical: _kSingleLineVerticalPadding),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: Typography.white.subhead, style: darkTheme.textTheme.subhead,
child: content child: content
) )
) )
...@@ -157,7 +162,6 @@ class SnackBar extends StatelessWidget { ...@@ -157,7 +162,6 @@ class SnackBar extends StatelessWidget {
} }
CurvedAnimation heightAnimation = new CurvedAnimation(parent: animation, curve: _snackBarHeightCurve); CurvedAnimation heightAnimation = new CurvedAnimation(parent: animation, curve: _snackBarHeightCurve);
CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation, curve: _snackBarFadeCurve, reverseCurve: const Threshold(0.0)); CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation, curve: _snackBarFadeCurve, reverseCurve: const Threshold(0.0));
ThemeData theme = Theme.of(context);
return new ClipRect( return new ClipRect(
child: new AnimatedBuilder( child: new AnimatedBuilder(
animation: heightAnimation, animation: heightAnimation,
...@@ -181,12 +185,7 @@ class SnackBar extends StatelessWidget { ...@@ -181,12 +185,7 @@ class SnackBar extends StatelessWidget {
elevation: 6, elevation: 6,
color: _kSnackBackground, color: _kSnackBackground,
child: new Theme( child: new Theme(
data: new ThemeData( data: darkTheme,
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness,
textTheme: Typography.white
),
child: new FadeTransition( child: new FadeTransition(
opacity: fadeAnimation, opacity: fadeAnimation,
child: new Row( child: new Row(
......
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