Unverified Commit 164e19be authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated actionsForegroundColor (#73745)

parent cd57af14
...@@ -130,21 +130,6 @@ Widget _wrapWithBackground({ ...@@ -130,21 +130,6 @@ Widget _wrapWithBackground({
); );
} }
// This exists to support backward compatibility with arguments like
// `actionsForegroundColor`. CupertinoThemes can be used to support these
// scenarios now. To support `actionsForegroundColor`, the nav bar rewraps
// its children with a CupertinoTheme.
Widget _wrapActiveColor(Color? color, BuildContext context, Widget child) {
if (color == null) {
return child;
}
return CupertinoTheme(
data: CupertinoTheme.of(context).copyWith(primaryColor: color),
child: child,
);
}
// Whether the current route supports nav bar hero transitions from or to. // Whether the current route supports nav bar hero transitions from or to.
bool _isTransitionable(BuildContext context) { bool _isTransitionable(BuildContext context) {
final ModalRoute<dynamic>? route = ModalRoute.of(context); final ModalRoute<dynamic>? route = ModalRoute.of(context);
...@@ -244,7 +229,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer ...@@ -244,7 +229,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer
this.backgroundColor, this.backgroundColor,
this.brightness, this.brightness,
this.padding, this.padding,
this.actionsForegroundColor,
this.transitionBetweenRoutes = true, this.transitionBetweenRoutes = true,
this.heroTag = _defaultHeroTag, this.heroTag = _defaultHeroTag,
}) : assert(automaticallyImplyLeading != null), }) : assert(automaticallyImplyLeading != null),
...@@ -372,21 +356,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer ...@@ -372,21 +356,6 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer
/// {@endtemplate} /// {@endtemplate}
final Border? border; final Border? border;
/// {@template flutter.cupertino.CupertinoNavigationBar.actionsForegroundColor}
/// Default color used for text and icons of the [leading] and [trailing]
/// widgets in the navigation bar.
///
/// Defaults to the `primaryColor` of the [CupertinoTheme] when null.
/// {@endtemplate}
///
/// The default color for text in the [middle] slot is always black, as per
/// iOS standard design.
@Deprecated(
'Use CupertinoTheme and primaryColor to propagate color. '
'This feature was deprecated after v1.1.2.'
)
final Color? actionsForegroundColor;
/// {@template flutter.cupertino.CupertinoNavigationBar.transitionBetweenRoutes} /// {@template flutter.cupertino.CupertinoNavigationBar.transitionBetweenRoutes}
/// Whether to transition between navigation bars. /// Whether to transition between navigation bars.
/// ///
...@@ -486,44 +455,35 @@ class _CupertinoNavigationBarState extends State<CupertinoNavigationBar> { ...@@ -486,44 +455,35 @@ class _CupertinoNavigationBarState extends State<CupertinoNavigationBar> {
), ),
); );
final Color? actionsForegroundColor = CupertinoDynamicColor.maybeResolve(
widget.actionsForegroundColor,
context,
);
if (!widget.transitionBetweenRoutes || !_isTransitionable(context)) { if (!widget.transitionBetweenRoutes || !_isTransitionable(context)) {
// Lint ignore to maintain backward compatibility. // Lint ignore to maintain backward compatibility.
return _wrapActiveColor(actionsForegroundColor, context, navBar); return navBar;
} }
return _wrapActiveColor( return Builder(
// Lint ignore to maintain backward compatibility. // Get the context that might have a possibly changed CupertinoTheme.
actionsForegroundColor, builder: (BuildContext context) {
context, return Hero(
Builder( tag: widget.heroTag == _defaultHeroTag
// Get the context that might have a possibly changed CupertinoTheme. ? _HeroTag(Navigator.of(context))
builder: (BuildContext context) { : widget.heroTag,
return Hero( createRectTween: _linearTranslateWithLargestRectSizeTween,
tag: widget.heroTag == _defaultHeroTag placeholderBuilder: _navBarHeroLaunchPadBuilder,
? _HeroTag(Navigator.of(context)) flightShuttleBuilder: _navBarHeroFlightShuttleBuilder,
: widget.heroTag, transitionOnUserGestures: true,
createRectTween: _linearTranslateWithLargestRectSizeTween, child: _TransitionableNavigationBar(
placeholderBuilder: _navBarHeroLaunchPadBuilder, componentsKeys: keys,
flightShuttleBuilder: _navBarHeroFlightShuttleBuilder, backgroundColor: backgroundColor,
transitionOnUserGestures: true, backButtonTextStyle: CupertinoTheme.of(context).textTheme.navActionTextStyle,
child: _TransitionableNavigationBar( titleTextStyle: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
componentsKeys: keys, largeTitleTextStyle: null,
backgroundColor: backgroundColor, border: widget.border,
backButtonTextStyle: CupertinoTheme.of(context).textTheme.navActionTextStyle, hasUserMiddle: widget.middle != null,
titleTextStyle: CupertinoTheme.of(context).textTheme.navTitleTextStyle, largeExpanded: false,
largeTitleTextStyle: null, child: navBar,
border: widget.border, ),
hasUserMiddle: widget.middle != null, );
largeExpanded: false, },
child: navBar,
),
);
},
),
); );
} }
} }
...@@ -604,7 +564,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget { ...@@ -604,7 +564,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
this.backgroundColor, this.backgroundColor,
this.brightness, this.brightness,
this.padding, this.padding,
this.actionsForegroundColor,
this.transitionBetweenRoutes = true, this.transitionBetweenRoutes = true,
this.heroTag = _defaultHeroTag, this.heroTag = _defaultHeroTag,
this.stretch = true, this.stretch = true,
...@@ -686,16 +645,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget { ...@@ -686,16 +645,6 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
/// {@macro flutter.cupertino.CupertinoNavigationBar.border} /// {@macro flutter.cupertino.CupertinoNavigationBar.border}
final Border? border; final Border? border;
/// {@macro flutter.cupertino.CupertinoNavigationBar.actionsForegroundColor}
///
/// The default color for text in the [largeTitle] slot is always black, as per
/// iOS standard design.
@Deprecated(
'Use CupertinoTheme and primaryColor to propagate color. '
'This feature was deprecated after v1.1.2.'
)
final Color? actionsForegroundColor;
/// {@macro flutter.cupertino.CupertinoNavigationBar.transitionBetweenRoutes} /// {@macro flutter.cupertino.CupertinoNavigationBar.transitionBetweenRoutes}
final bool transitionBetweenRoutes; final bool transitionBetweenRoutes;
...@@ -730,10 +679,6 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation ...@@ -730,10 +679,6 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Lint ignore to maintain backward compatibility.
final Color actionsForegroundColor = CupertinoDynamicColor.maybeResolve(widget.actionsForegroundColor, context)
?? CupertinoTheme.of(context).primaryColor;
final _NavigationBarStaticComponents components = _NavigationBarStaticComponents( final _NavigationBarStaticComponents components = _NavigationBarStaticComponents(
keys: keys, keys: keys,
route: ModalRoute.of(context), route: ModalRoute.of(context),
...@@ -748,29 +693,24 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation ...@@ -748,29 +693,24 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation
large: true, large: true,
); );
return _wrapActiveColor( return MediaQuery(
// Lint ignore to maintain backward compatibility. data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
actionsForegroundColor, child: SliverPersistentHeader(
context, pinned: true, // iOS navigation bars are always pinned.
MediaQuery( delegate: _LargeTitleNavigationBarSliverDelegate(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1), keys: keys,
child: SliverPersistentHeader( components: components,
pinned: true, // iOS navigation bars are always pinned. userMiddle: widget.middle,
delegate: _LargeTitleNavigationBarSliverDelegate( backgroundColor: CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).barBackgroundColor,
keys: keys, brightness: widget.brightness,
components: components, border: widget.border,
userMiddle: widget.middle, padding: widget.padding,
backgroundColor: CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).barBackgroundColor, actionsForegroundColor: CupertinoTheme.of(context).primaryColor,
brightness: widget.brightness, transitionBetweenRoutes: widget.transitionBetweenRoutes,
border: widget.border, heroTag: widget.heroTag,
padding: widget.padding, persistentHeight: _kNavBarPersistentHeight + MediaQuery.of(context).padding.top,
actionsForegroundColor: actionsForegroundColor, alwaysShowMiddle: widget.middle != null,
transitionBetweenRoutes: widget.transitionBetweenRoutes, stretchConfiguration: widget.stretch ? OverScrollHeaderStretchConfiguration() : null,
heroTag: widget.heroTag,
persistentHeight: _kNavBarPersistentHeight + MediaQuery.of(context).padding.top,
alwaysShowMiddle: widget.middle != null,
stretchConfiguration: widget.stretch ? OverScrollHeaderStretchConfiguration() : null,
),
), ),
), ),
); );
......
...@@ -309,6 +309,7 @@ void main() { ...@@ -309,6 +309,7 @@ void main() {
count = 0x000000; count = 0x000000;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(primaryColor: Color(0xFF001122)),
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
leading: CupertinoButton( leading: CupertinoButton(
onPressed: () { }, onPressed: () { },
...@@ -319,7 +320,6 @@ void main() { ...@@ -319,7 +320,6 @@ void main() {
onPressed: () { }, onPressed: () { },
child: const _ExpectStyles(color: Color(0xFF001122), index: 0x010000), child: const _ExpectStyles(color: Color(0xFF001122), index: 0x010000),
), ),
actionsForegroundColor: const Color(0xFF001122),
), ),
), ),
); );
......
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