Unverified Commit e1a96b81 authored by Pierre-Louis's avatar Pierre-Louis Committed by GitHub

Deprecate `primaryColorBrightness` (#93396)

parent 8612f80a
......@@ -14,6 +14,38 @@
version: 1
transforms:
# Changes made in https://github.com/flutter/flutter/pull/93396
- title: "Remove 'primaryColorBrightness'"
date: 2021-11-11
element:
uris: [ 'material.dart' ]
method: 'copyWith'
inClass: 'ThemeData'
changes:
- kind: 'removeParameter'
name: 'primaryColorBrightness'
# Changes made in https://github.com/flutter/flutter/pull/93396
- title: "Remove 'primaryColorBrightness'"
date: 2021-11-11
element:
uris: [ 'material.dart' ]
constructor: 'raw'
inClass: 'ThemeData'
changes:
- kind: 'removeParameter'
name: 'primaryColorBrightness'
# Changes made in https://github.com/flutter/flutter/pull/93396
- title: "Remove 'primaryColorBrightness'"
date: 2021-11-11
element:
uris: [ 'material.dart' ]
constructor: ''
inClass: 'ThemeData'
changes:
- kind: 'removeParameter'
name: 'primaryColorBrightness'
# Changes made in https://github.com/flutter/flutter/pull/86198
- title: "Migrate to 'backgroundColor'"
......
......@@ -1047,7 +1047,7 @@ class _AppBarState extends State<AppBar> {
? _systemOverlayStyleForBrightness(
widget.brightness
?? appBarTheme.brightness
?? theme.primaryColorBrightness,
?? ThemeData.estimateBrightnessForColor(backgroundColor),
)
: widget.systemOverlayStyle
?? appBarTheme.systemOverlayStyle
......
......@@ -662,7 +662,7 @@ class TextField extends StatefulWidget {
///
/// This setting is only honored on iOS devices.
///
/// If unset, defaults to the brightness of [ThemeData.primaryColorBrightness].
/// If unset, defaults to [ThemeData.brightness].
final Brightness? keyboardAppearance;
/// {@macro flutter.widgets.editableText.scrollPadding}
......@@ -1143,7 +1143,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
final ThemeData theme = Theme.of(context);
final TextSelectionThemeData selectionTheme = TextSelectionTheme.of(context);
final TextStyle style = theme.textTheme.subtitle1!.merge(widget.style);
final Brightness keyboardAppearance = widget.keyboardAppearance ?? theme.primaryColorBrightness;
final Brightness keyboardAppearance = widget.keyboardAppearance ?? theme.brightness;
final TextEditingController controller = _effectiveController;
final FocusNode focusNode = _effectiveFocusNode;
final List<TextInputFormatter> formatters = <TextInputFormatter>[
......
......@@ -239,7 +239,6 @@ class ThemeData with Diagnosticable {
Brightness? brightness,
MaterialColor? primarySwatch,
Color? primaryColor,
Brightness? primaryColorBrightness,
Color? primaryColorLight,
Color? primaryColorDark,
Color? focusColor,
......@@ -361,6 +360,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.5.0-1.0.pre.',
)
bool? fixTextFieldOutlineLabel,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
Brightness? primaryColorBrightness,
}) {
// GENERAL CONFIGURATION
applyElevationOverlayColor ??= false;
......@@ -390,10 +394,10 @@ class ThemeData with Diagnosticable {
final bool isDark = _brightness == Brightness.dark;
primarySwatch ??= Colors.blue;
primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch;
primaryColorBrightness ??= estimateBrightnessForColor(primaryColor);
final Brightness _primaryColorBrightness = estimateBrightnessForColor(primaryColor);
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
final bool primaryIsDark = primaryColorBrightness == Brightness.dark;
final bool primaryIsDark = _primaryColorBrightness == Brightness.dark;
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!);
accentColor ??= isDark ? Colors.tealAccent[200]! : primarySwatch[500]!;
accentColorBrightness ??= estimateBrightnessForColor(accentColor);
......@@ -500,6 +504,7 @@ class ThemeData with Diagnosticable {
accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!;
fixTextFieldOutlineLabel ??= true;
primaryColorBrightness = _primaryColorBrightness;
return ThemeData.raw(
// GENERAL CONFIGURATION
......@@ -516,7 +521,6 @@ class ThemeData with Diagnosticable {
// COLOR
colorScheme: colorScheme,
primaryColor: primaryColor,
primaryColorBrightness: primaryColorBrightness,
primaryColorLight: primaryColorLight,
primaryColorDark: primaryColorDark,
focusColor: focusColor,
......@@ -589,6 +593,7 @@ class ThemeData with Diagnosticable {
accentIconTheme: accentIconTheme,
buttonColor: buttonColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness,
);
}
......@@ -620,7 +625,6 @@ class ThemeData with Diagnosticable {
// https://github.com/flutter/flutter/issues/91772.
required this.colorScheme,
required this.primaryColor,
required this.primaryColorBrightness,
required this.primaryColorLight,
required this.primaryColorDark,
required this.focusColor,
......@@ -741,6 +745,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.5.0-1.0.pre.',
)
required this.fixTextFieldOutlineLabel,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
required this.primaryColorBrightness,
}) : // GENERAL CONFIGURATION
assert(applyElevationOverlayColor != null),
assert(inputDecorationTheme != null),
......@@ -753,7 +762,6 @@ class ThemeData with Diagnosticable {
// COLOR
assert(colorScheme != null),
assert(primaryColor != null),
assert(primaryColorBrightness != null),
assert(primaryColorLight != null),
assert(primaryColorDark != null),
assert(focusColor != null),
......@@ -825,7 +833,8 @@ class ThemeData with Diagnosticable {
assert(accentTextTheme != null),
assert(accentIconTheme != null),
assert(buttonColor != null),
assert(fixTextFieldOutlineLabel != null);
assert(fixTextFieldOutlineLabel != null),
assert(primaryColorBrightness != null);
/// Create a [ThemeData] based on the colors in the given [colorScheme] and
/// text styles of the optional [textTheme].
......@@ -1089,10 +1098,6 @@ class ThemeData with Diagnosticable {
/// visuals in terms of the theme's [colorScheme].
final Color primaryColor;
/// The brightness of the [primaryColor]. Used to determine the color of text and
/// icons placed on top of the primary color (e.g. toolbar text).
final Brightness primaryColorBrightness;
/// A lighter version of the [primaryColor].
final Color primaryColorLight;
......@@ -1451,6 +1456,21 @@ class ThemeData with Diagnosticable {
)
final bool fixTextFieldOutlineLabel;
/// Obsolete property that was originally used to determine the color
/// of text and icons placed on top of the primary color (e.g. toolbar text).
///
/// The material library no longer uses this property. The [appBarTheme] can
/// be used to configure the appearance of [AppBar]s. The appearance of
/// Keyboards for [TextField]s now uses the overall theme's
/// [ThemeData.brightness] and can also be customized with
/// [TextField.keyboardAppearance]. The brightness of any color can be found
/// with [ThemeData.estimateBrightnessForColor].
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
final Brightness primaryColorBrightness;
/// Creates a copy of this theme but with the given fields replaced with the new values.
///
/// The [brightness] value is applied to the [colorScheme].
......@@ -1473,7 +1493,6 @@ class ThemeData with Diagnosticable {
ColorScheme? colorScheme,
Brightness? brightness,
Color? primaryColor,
Brightness? primaryColorBrightness,
Color? primaryColorLight,
Color? primaryColorDark,
Color? focusColor,
......@@ -1594,6 +1613,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.5.0-1.0.pre.',
)
bool? fixTextFieldOutlineLabel,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
Brightness? primaryColorBrightness,
}) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
return ThemeData.raw(
......@@ -1611,7 +1635,6 @@ class ThemeData with Diagnosticable {
// COLOR
colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
primaryColor: primaryColor ?? this.primaryColor,
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
primaryColorLight: primaryColorLight ?? this.primaryColorLight,
primaryColorDark: primaryColorDark ?? this.primaryColorDark,
focusColor: focusColor ?? this.focusColor,
......@@ -1684,6 +1707,7 @@ class ThemeData with Diagnosticable {
accentIconTheme: accentIconTheme ?? this.accentIconTheme,
buttonColor: buttonColor ?? this.buttonColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
);
}
......@@ -1779,7 +1803,6 @@ class ThemeData with Diagnosticable {
// COLOR
colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!,
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!,
primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!,
focusColor: Color.lerp(a.focusColor, b.focusColor, t)!,
......@@ -1852,6 +1875,7 @@ class ThemeData with Diagnosticable {
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t)!,
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
);
}
......@@ -1877,7 +1901,6 @@ class ThemeData with Diagnosticable {
// COLOR
other.colorScheme == colorScheme &&
other.primaryColor == primaryColor &&
other.primaryColorBrightness == primaryColorBrightness &&
other.primaryColorLight == primaryColorLight &&
other.primaryColorDark == primaryColorDark &&
other.focusColor == focusColor &&
......@@ -1949,7 +1972,8 @@ class ThemeData with Diagnosticable {
other.accentTextTheme == accentTextTheme &&
other.accentIconTheme == accentIconTheme &&
other.buttonColor == buttonColor &&
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel;
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
other.primaryColorBrightness == primaryColorBrightness;
}
@override
......@@ -1972,7 +1996,6 @@ class ThemeData with Diagnosticable {
// COLOR
colorScheme,
primaryColor,
primaryColorBrightness,
primaryColorLight,
primaryColorDark,
focusColor,
......@@ -2045,6 +2068,7 @@ class ThemeData with Diagnosticable {
accentIconTheme,
buttonColor,
fixTextFieldOutlineLabel,
primaryColorBrightness,
];
return hashList(values);
}
......@@ -2067,7 +2091,6 @@ class ThemeData with Diagnosticable {
// COLORS
properties.add(DiagnosticsProperty<ColorScheme>('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug));
properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor, level: DiagnosticLevel.debug));
properties.add(EnumProperty<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
properties.add(ColorProperty('primaryColorLight', primaryColorLight, defaultValue: defaultData.primaryColorLight, level: DiagnosticLevel.debug));
properties.add(ColorProperty('primaryColorDark', primaryColorDark, defaultValue: defaultData.primaryColorDark, level: DiagnosticLevel.debug));
properties.add(ColorProperty('focusColor', focusColor, defaultValue: defaultData.focusColor, level: DiagnosticLevel.debug));
......@@ -2140,6 +2163,7 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme, level: DiagnosticLevel.debug));
properties.add(ColorProperty('buttonColor', buttonColor, defaultValue: defaultData.buttonColor, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<bool>('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, level: DiagnosticLevel.debug));
properties.add(EnumProperty<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
}
}
......
......@@ -5,7 +5,6 @@
// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags(<String>['reduced-test-set'])
import 'dart:typed_data';
import 'package:flutter/material.dart';
......
......@@ -43,8 +43,8 @@ void main() {
});
test('Default primary text theme contrasts with primary brightness', () {
final ThemeData lightTheme = ThemeData(primaryColorBrightness: Brightness.light);
final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark);
final ThemeData lightTheme = ThemeData(primaryColor: Colors.white);
final ThemeData darkTheme = ThemeData(primaryColor: Colors.black);
final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.headline6!.color, typography.black.headline6!.color);
......@@ -61,8 +61,8 @@ void main() {
});
test('Default primary icon theme contrasts with primary brightness', () {
final ThemeData lightTheme = ThemeData(primaryColorBrightness: Brightness.light);
final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark);
final ThemeData lightTheme = ThemeData(primaryColor: Colors.white);
final ThemeData darkTheme = ThemeData(primaryColor: Colors.black);
final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.headline6!.color, typography.black.headline6!.color);
......@@ -670,7 +670,6 @@ void main() {
// COLOR
'colorScheme',
'primaryColor',
'primaryColorBrightness',
'primaryColorLight',
'primaryColorDark',
'focusColor',
......@@ -743,6 +742,7 @@ void main() {
'accentIconTheme',
'buttonColor',
'fixTextFieldOutlineLabel',
'primaryColorBrightness',
};
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
......
......@@ -500,4 +500,11 @@ void main() {
AppBarTheme appBarTheme = AppBarTheme();
appBarTheme.color;
// Changes made in https://github.com/flutter/flutter/pull/93396
ThemeData themeData = ThemeData();
themeData = ThemeData(primaryColorBrightness: Brightness.dark);
themeData = ThemeData.raw(primaryColorBrightness: Brightness.dark);
themeData = themeData.copyWith(primaryColorBrightness: Brightness.dark);
themeData.primaryColorBrightness; // Removing field reference not supported.
}
......@@ -473,4 +473,11 @@ void main() {
AppBarTheme appBarTheme = AppBarTheme();
appBarTheme.backgroundColor;
// Changes made in https://github.com/flutter/flutter/pull/93396
ThemeData themeData = ThemeData();
themeData = ThemeData();
themeData = ThemeData.raw();
themeData = themeData.copyWith();
themeData.primaryColorBrightness; // Removing field reference not supported.
}
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