From 606abc915fb85e6896c85e19c1cf3fa4f526745a Mon Sep 17 00:00:00 2001 From: "Masayuki Ono (mono)" Date: Thu, 20 Aug 2020 01:01:06 +0900 Subject: [PATCH] Fix title color of license detail page (#63249) --- packages/flutter/lib/src/material/about.dart | 6 +- .../flutter/test/material/about_test.dart | 109 ++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 1ccae57f82..ff59d5ce05 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -917,7 +917,11 @@ class _PackageLicensePageState extends State<_PackageLicensePage> { if (widget.scrollController == null) { page = Scaffold( appBar: AppBar( - title: _PackageLicensePageTitle(title, subtitle, theme.primaryTextTheme), + title: _PackageLicensePageTitle( + title, + subtitle, + theme.appBarTheme.textTheme ?? theme.primaryTextTheme, + ), ), body: Center( child: Material( diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index ba20725866..8cffd2a8ec 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -234,6 +234,115 @@ void main() { expect(find.text('Another license'), findsOneWidget); }, skip: isBrowser); // https://github.com/flutter/flutter/issues/54385 + testWidgets('_PackageLicensePage title style without AppBarTheme', ( + WidgetTester tester, + ) async { + LicenseRegistry.addLicense(() { + return Stream.fromIterable([ + const LicenseEntryWithLineBreaks(['AAA'], 'BBB'), + ]); + }); + + const TextStyle titleTextStyle = TextStyle( + fontSize: 20, + color: Colors.black, + inherit: false, + ); + const TextStyle subtitleTextStyle = TextStyle( + fontSize: 15, + color: Colors.red, + inherit: false, + ); + + await tester.pumpWidget( + MaterialApp( + theme: ThemeData( + primaryTextTheme: const TextTheme( + headline6: titleTextStyle, + subtitle2: subtitleTextStyle, + ), + ), + home: const Center( + child: LicensePage(), + ), + ), + ); + await tester.pumpAndSettle(); + + // Check for packages. + expect(find.text('AAA'), findsOneWidget); + + // Check license is displayed after entering into license page for 'AAA'. + await tester.tap(find.text('AAA')); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); + + // Check for titles style. + final Text title = tester.widget(find.text('AAA')); + expect(title.style, titleTextStyle); + final Text subtitle = tester.widget(find.text('1 license.')); + expect(subtitle.style, subtitleTextStyle); + }, skip: isBrowser); // https://github.com/flutter/flutter/issues/54385 + + testWidgets('_PackageLicensePage title style with AppBarTheme', ( + WidgetTester tester, + ) async { + LicenseRegistry.addLicense(() { + return Stream.fromIterable([ + const LicenseEntryWithLineBreaks(['AAA'], 'BBB'), + ]); + }); + + const TextStyle titleTextStyle = TextStyle( + fontSize: 20, + color: Colors.black, + ); + const TextStyle subtitleTextStyle = TextStyle( + fontSize: 15, + color: Colors.red, + ); + + await tester.pumpWidget( + MaterialApp( + theme: ThemeData( + // Not used because appBarTheme is prioritized. + primaryTextTheme: const TextTheme( + headline6: TextStyle( + fontSize: 12, + color: Colors.grey, + ), + subtitle2: TextStyle( + fontSize: 10, + color: Colors.grey, + ), + ), + appBarTheme: const AppBarTheme( + textTheme: TextTheme( + headline6: titleTextStyle, + subtitle2: subtitleTextStyle, + ), + ), + ), + home: const Center( + child: LicensePage(), + ), + ), + ); + await tester.pumpAndSettle(); + + // Check for packages. + expect(find.text('AAA'), findsOneWidget); + + // Check license is displayed after entering into license page for 'AAA'. + await tester.tap(find.text('AAA')); + await tester.pumpAndSettle(const Duration(milliseconds: 100)); + + // Check for titles style. + final Text title = tester.widget(find.text('AAA')); + expect(title.style, titleTextStyle); + final Text subtitle = tester.widget(find.text('1 license.')); + expect(subtitle.style, subtitleTextStyle); + }, skip: isBrowser); // https://github.com/flutter/flutter/issues/54385 + testWidgets('LicensePage respects the notch', (WidgetTester tester) async { const double safeareaPadding = 27.0;