From b7af5e714d78e18e8988f22dd556395d52a79972 Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 25 Dec 2019 23:49:55 -0800 Subject: [PATCH] Revert "Add `brightness` to CupertinoNavigationBar (fixes #46216) (#47521)" (#47805) --- .../flutter/lib/src/cupertino/nav_bar.dart | 39 ++--------- .../flutter/test/cupertino/nav_bar_test.dart | 64 ------------------- 2 files changed, 4 insertions(+), 99 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index d5776ee8a0..91cac6cb24 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -87,24 +87,15 @@ class _HeroTag { Widget _wrapWithBackground({ Border border, Color backgroundColor, - Brightness brightness, Widget child, bool updateSystemUiOverlay = true, }) { Widget result = child; if (updateSystemUiOverlay) { - final bool isDark = backgroundColor.computeLuminance() < 0.179; - final Brightness newBrightness = brightness ?? (isDark ? Brightness.dark : Brightness.light); - SystemUiOverlayStyle overlayStyle; - switch (newBrightness) { - case Brightness.dark: - overlayStyle = SystemUiOverlayStyle.light; - break; - case Brightness.light: - default: - overlayStyle = SystemUiOverlayStyle.dark; - break; - } + final bool darkBackground = backgroundColor.computeLuminance() < 0.179; + final SystemUiOverlayStyle overlayStyle = darkBackground + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark; result = AnnotatedRegion( value: overlayStyle, sized: true, @@ -215,7 +206,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer this.trailing, this.border = _kDefaultNavBarBorder, this.backgroundColor, - this.brightness, this.padding, this.actionsForegroundColor, this.transitionBetweenRoutes = true, @@ -311,18 +301,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer /// {@endtemplate} final Color backgroundColor; - /// {@template flutter.cupertino.navBar.brightness} - /// The brightness of the specified [backgroundColor]. - /// - /// Setting this value changes the style of the system status bar. Typically - /// used to increase the contrast ratio of the system status bar over - /// [backgroundColor]. - /// - /// If set to null, the value of the property will be inferred from the relative - /// luminance of [backgroundColor]. - /// {@endtemplate} - final Brightness brightness; - /// {@template flutter.cupertino.navBar.padding} /// Padding for the contents of the navigation bar. /// @@ -449,7 +427,6 @@ class _CupertinoNavigationBarState extends State { final Widget navBar = _wrapWithBackground( border: widget.border, backgroundColor: backgroundColor, - brightness: widget.brightness, child: DefaultTextStyle( style: CupertinoTheme.of(context).textTheme.textStyle, child: _PersistentNavigationBar( @@ -570,7 +547,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget { this.trailing, this.border = _kDefaultNavBarBorder, this.backgroundColor, - this.brightness, this.padding, this.actionsForegroundColor, this.transitionBetweenRoutes = true, @@ -644,9 +620,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget { /// {@macro flutter.cupertino.navBar.backgroundColor} final Color backgroundColor; - /// {@macro flutter.cupertino.navBar.brightness} - final Brightness brightness; - /// {@macro flutter.cupertino.navBar.padding} final EdgeInsetsDirectional padding; @@ -721,7 +694,6 @@ class _CupertinoSliverNavigationBarState extends State region1 = tester.allWidgets.singleWhere(( - Widget widget) => widget is AnnotatedRegion); - expect(region1.value, SystemUiOverlayStyle.light); - - await tester.pumpWidget( - const CupertinoApp( - home: CupertinoNavigationBar( - backgroundColor: Color(0xF01D1D1D), - brightness: Brightness.light, - ), - ), - ); - - final AnnotatedRegion region2 = tester.allWidgets.singleWhere(( - Widget widget) => widget is AnnotatedRegion); - expect(region2.value, SystemUiOverlayStyle.dark); - - await tester.pumpWidget( - const CupertinoApp( - home: CustomScrollView( - slivers: [ - CupertinoSliverNavigationBar( - largeTitle: Text('Title'), - backgroundColor: Color(0xF0F9F9F9), - brightness: Brightness.dark, - ) - ], - ), - ), - ); - - final AnnotatedRegion region3 = tester.allWidgets.singleWhere(( - Widget widget) => widget is AnnotatedRegion); - expect(region3.value, SystemUiOverlayStyle.light); - - await tester.pumpWidget( - const CupertinoApp( - home: CustomScrollView( - slivers: [ - CupertinoSliverNavigationBar( - largeTitle: Text('Title'), - backgroundColor: Color(0xF01D1D1D), - brightness: Brightness.light, - ) - ], - ), - ), - ); - - final AnnotatedRegion region4 = tester.allWidgets.singleWhere(( - Widget widget) => widget is AnnotatedRegion); - expect(region4.value, SystemUiOverlayStyle.dark); - }); - testWidgets('Padding works in RTL', (WidgetTester tester) async { await tester.pumpWidget( const CupertinoApp(