From 2ef7cd649cb5802d63dc593ec276e5d3e48f8b86 Mon Sep 17 00:00:00 2001 From: Will Larche Date: Tue, 4 Sep 2018 19:26:52 -0400 Subject: [PATCH] [Icons] Updating default icon theme values. (#20840) Closes #3188 --- examples/stocks/test/icon_color_test.dart | 2 +- packages/flutter/lib/src/material/button.dart | 4 ++-- .../flutter/lib/src/material/theme_data.dart | 4 ++-- .../flutter/test/material/buttons_test.dart | 22 ++++++++++++++++++- .../test/material/expand_icon_test.dart | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart index 9a592fecd9..74a73214bf 100644 --- a/examples/stocks/test/icon_color_test.dart +++ b/examples/stocks/test/icon_color_test.dart @@ -74,7 +74,7 @@ void main() { // check the colour of the icon - light mode checkIconColor(tester, 'Stock List', Colors.purple); // theme primary color - checkIconColor(tester, 'Account Balance', Colors.black26); // disabled + checkIconColor(tester, 'Account Balance', Colors.black38); // disabled checkIconColor(tester, 'About', Colors.black45); // enabled // switch to dark mode diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index f9f01d4a9f..9a75ac1e70 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -411,11 +411,11 @@ class MaterialButton extends StatelessWidget { case ButtonTextTheme.normal: return enabled ? (themeIsDark ? Colors.white : Colors.black87) - : (themeIsDark ? Colors.white30 : Colors.black26); + : theme.disabledColor; case ButtonTextTheme.accent: return enabled ? theme.accentColor - : (themeIsDark ? Colors.white30 : Colors.black26); + : theme.disabledColor; case ButtonTextTheme.primary: return enabled ? (fillIsDark ? Colors.white : Colors.black) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 1c9160167d..34c8a632fa 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -167,7 +167,7 @@ class ThemeData extends Diagnosticable { splashFactory ??= InkSplash.splashFactory; selectedRowColor ??= Colors.grey[100]; unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54; - disabledColor ??= isDark ? Colors.white30 : Colors.black26; + disabledColor ??= isDark ? Colors.white30 : Colors.black38; buttonColor ??= isDark ? primarySwatch[600] : Colors.grey[300]; buttonTheme ??= const ButtonThemeData(); // Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess. @@ -182,9 +182,9 @@ class ThemeData extends Diagnosticable { hintColor ??= isDark ? const Color(0x80FFFFFF) : const Color(0x8A000000); errorColor ??= Colors.red[700]; inputDecorationTheme ??= const InputDecorationTheme(); - iconTheme ??= isDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); primaryIconTheme ??= primaryIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); + iconTheme ??= isDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black87); platform ??= defaultTargetPlatform; final Typography typography = new Typography(platform: platform); final TextTheme defaultTextTheme = isDark ? typography.white : typography.black; diff --git a/packages/flutter/test/material/buttons_test.dart b/packages/flutter/test/material/buttons_test.dart index 5328ac9b51..a99ea298e4 100644 --- a/packages/flutter/test/material/buttons_test.dart +++ b/packages/flutter/test/material/buttons_test.dart @@ -310,7 +310,27 @@ void main() { ); }); - testWidgets('Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics', (WidgetTester tester) async { + testWidgets('Disabled MaterialButton has correct default text color', (WidgetTester tester) async { + const String testText = 'Disabled'; + const Widget buttonWidget = Directionality( + textDirection: TextDirection.ltr, + child: Material( + child: Center( + child: MaterialButton( + onPressed: null, + child: Text(testText), // button is disabled + ), + ), + ), + ); + + await tester.pumpWidget(buttonWidget); + + final RichText text = tester.widget(find.byType(RichText)); + expect(text.text.style.color, Colors.black38); + }); + + testWidgets('Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics', (WidgetTester tester) async { final SemanticsTester semantics = new SemanticsTester(tester); final Rect expectedButtonSize = new Rect.fromLTRB(0.0, 0.0, 116.0, 48.0); diff --git a/packages/flutter/test/material/expand_icon_test.dart b/packages/flutter/test/material/expand_icon_test.dart index 9de08c2b57..592b5968a0 100644 --- a/packages/flutter/test/material/expand_icon_test.dart +++ b/packages/flutter/test/material/expand_icon_test.dart @@ -37,7 +37,7 @@ void main() { ); final IconTheme iconTheme = tester.firstWidget(find.byType(IconTheme).last); - expect(iconTheme.data.color, equals(Colors.black26)); + expect(iconTheme.data.color, equals(Colors.black38)); }); testWidgets('ExpandIcon test isExpanded does not trigger callback', (WidgetTester tester) async {