Skip to content

Commit

Permalink
Delete thumbTintColor, tintColor, onTintColor props
Browse files Browse the repository at this point in the history
Summary:
Deprecations for these props were added in 0.57, June 2018, in this commit: 965adee#diff-6ee4e62c750fcd87064f152f53214a05, with warnings added in 9a4fd6b#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 of 965adee#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
  • Loading branch information
elicwhite authored and facebook-github-bot committed Feb 6, 2020
1 parent 8e5fac8 commit 26912bd
Showing 1 changed file with 9 additions and 39 deletions.
48 changes: 9 additions & 39 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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(
Expand All @@ -185,8 +155,8 @@ class Switch extends React.Component<Props> {
},
),
),
thumbTintColor: _thumbColor,
tintColor: _trackColorForFalse,
thumbTintColor: thumbColor,
tintColor: trackColorForFalse,
value: value === true,
};

Expand Down

0 comments on commit 26912bd

Please sign in to comment.