Delete thumbTintColor, tintColor, onTintColor props
Summary: Deprecations for these props were added in 0.57, June 2018, in this commit:965adee109 (diff-6ee4e62c750fcd87064f152f53214a05)
, with warnings added in9a4fd6b78d (diff-6ee4e62c750fcd87064f152f53214a05)
It has been a couple releases now, so let's clean up the component code and finally remove support. For instructions on how to migrate off these props, see the commit summary of965adee109 (diff-6ee4e62c750fcd87064f152f53214a05)
Changelog: [Breaking][General] Switch: Remove support for thumbTintColor, tintColor, onTintColor props (deprecated in 0.57) Reviewed By: cpojer Differential Revision: D19760913 fbshipit-source-id: 8fdcf7af99fecadecf3157c00e6d1cbab8e63268
This commit is contained in:
Родитель
8e5fac89bb
Коммит
26912bd979
|
@ -113,48 +113,18 @@ class Switch extends React.Component<Props> {
|
|||
...props
|
||||
} = this.props;
|
||||
|
||||
// Support deprecated color props.
|
||||
let _thumbColor = thumbColor;
|
||||
let _trackColorForFalse = trackColor?.false;
|
||||
let _trackColorForTrue = trackColor?.true;
|
||||
|
||||
// TODO: Remove support for these props after a couple releases.
|
||||
const {thumbTintColor, tintColor, onTintColor} = (props: $FlowFixMe);
|
||||
if (thumbTintColor != null) {
|
||||
_thumbColor = thumbTintColor;
|
||||
if (__DEV__) {
|
||||
console.warn(
|
||||
'Switch: `thumbTintColor` is deprecated, use `thumbColor` instead.',
|
||||
);
|
||||
}
|
||||
}
|
||||
if (tintColor != null) {
|
||||
_trackColorForFalse = tintColor;
|
||||
if (__DEV__) {
|
||||
console.warn(
|
||||
'Switch: `tintColor` is deprecated, use `trackColor` instead.',
|
||||
);
|
||||
}
|
||||
}
|
||||
if (onTintColor != null) {
|
||||
_trackColorForTrue = onTintColor;
|
||||
if (__DEV__) {
|
||||
console.warn(
|
||||
'Switch: `onTintColor` is deprecated, use `trackColor` instead.',
|
||||
);
|
||||
}
|
||||
}
|
||||
const trackColorForFalse = trackColor?.false;
|
||||
const trackColorForTrue = trackColor?.true;
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
const platformProps = {
|
||||
enabled: disabled !== true,
|
||||
on: value === true,
|
||||
style,
|
||||
thumbTintColor: _thumbColor,
|
||||
trackColorForFalse: _trackColorForFalse,
|
||||
trackColorForTrue: _trackColorForTrue,
|
||||
trackTintColor:
|
||||
value === true ? _trackColorForTrue : _trackColorForFalse,
|
||||
thumbTintColor: thumbColor,
|
||||
trackColorForFalse: trackColorForFalse,
|
||||
trackColorForTrue: trackColorForTrue,
|
||||
trackTintColor: value === true ? trackColorForTrue : trackColorForFalse,
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -172,7 +142,7 @@ class Switch extends React.Component<Props> {
|
|||
|
||||
const platformProps = {
|
||||
disabled,
|
||||
onTintColor: _trackColorForTrue,
|
||||
onTintColor: trackColorForTrue,
|
||||
style: StyleSheet.compose(
|
||||
{height: 31, width: 51},
|
||||
StyleSheet.compose(
|
||||
|
@ -185,8 +155,8 @@ class Switch extends React.Component<Props> {
|
|||
},
|
||||
),
|
||||
),
|
||||
thumbTintColor: _thumbColor,
|
||||
tintColor: _trackColorForFalse,
|
||||
thumbTintColor: thumbColor,
|
||||
tintColor: trackColorForFalse,
|
||||
value: value === true,
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче