Skip to content

Commit

Permalink
removing changes to Switch iOS (SwitchNativeComponent)
Browse files Browse the repository at this point in the history
facebook#30944 is tagged as
Platform Android.
  • Loading branch information
fabOnReact committed Feb 8, 2022
1 parent 94a6a7f commit 135c562
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ const SwitchWithForwardedRef: React.AbstractComponent<
> = React.forwardRef(function Switch(props, forwardedRef): React.Node {
const {
disabled,
accessibilityState,
ios_backgroundColor,
onChange,
onValueChange,
Expand Down Expand Up @@ -184,15 +183,18 @@ const SwitchWithForwardedRef: React.AbstractComponent<
}
}, [value, native]);

const _disabled = disabled != null ? disabled : accessibilityState?.disabled;
if (Platform.OS === 'android') {
const {accessibilityState} = restProps;
const _disabled =
disabled != null ? disabled : accessibilityState?.disabled;

const _accessibilityState =
_disabled !== accessibilityState?.disabled
? {...accessibilityState, disabled: _disabled}
: accessibilityState;
const _accessibilityState =
_disabled !== accessibilityState?.disabled
? {...accessibilityState, disabled: _disabled}
: accessibilityState;

if (Platform.OS === 'android') {
const platformProps = {
accessibilityState: _accessibilityState,
enabled: _disabled !== true,
on: value === true,
style,
Expand All @@ -205,7 +207,6 @@ const SwitchWithForwardedRef: React.AbstractComponent<
return (
<AndroidSwitchNativeComponent
{...restProps}
accessibilityState={_accessibilityState}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'switch'}
onChange={handleChange}
Expand All @@ -216,7 +217,7 @@ const SwitchWithForwardedRef: React.AbstractComponent<
);
} else {
const platformProps = {
disabled: _disabled,
disabled,
onTintColor: trackColorForTrue,
style: StyleSheet.compose(
{height: 31, width: 51},
Expand Down

0 comments on commit 135c562

Please sign in to comment.