Skip to content

Commit 2ade966

Browse files
ethansharlidord-wix
authored andcommitted
Enable useNative when passing activeScale and add its type (#1997)
* Enable useNative when passing activeScale and add its type * Fix check on activeScale
1 parent 7380477 commit 2ade966

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

demo/src/screens/componentScreens/CardsScreen.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
9797
style={{marginBottom: 15}}
9898
onPress={() => {}}
9999
borderRadius={borderRadius}
100-
useNative
101100
bg-$backgroundElevated
102101
activeOpacity={1}
103102
activeScale={isImageOnLeft ? 0.96 : 1.04}
@@ -136,7 +135,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
136135

137136
renderCoupon = (cardProps: CardProps) => {
138137
return (
139-
<Card {...cardProps} flex height={160} onPress={() => {}} useNative activeOpacity={1} activeScale={0.96}>
138+
<Card {...cardProps} flex height={160} onPress={() => {}} activeOpacity={1} activeScale={0.96}>
140139
<Card.Section
141140
bg-$backgroundDangerHeavy
142141
padding-20
@@ -169,7 +168,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
169168

170169
renderComplexImage = (cardProps: CardProps, image: React.ReactNode) => {
171170
return (
172-
<Card {...cardProps} flex marginV-10 onPress={() => {}} useNative activeOpacity={1} activeScale={0.96}>
171+
<Card {...cardProps} flex marginV-10 onPress={() => {}} activeOpacity={1} activeScale={0.96}>
173172
{image}
174173
<Card.Section
175174
bg-$backgroundElevated

src/components/touchableOpacity/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export interface TouchableOpacityProps extends Omit<RNTouchableOpacityProps, 'st
3030
* Apply background color on TouchableOpacity when active (press is on)
3131
*/
3232
activeBackgroundColor?: string;
33+
/**
34+
* Will apply scale press feedback. This will enforce the useNative prop
35+
*/
36+
activeScale?: number;
3337
/**
3438
* Should use a more native touchable opacity component
3539
*/
@@ -112,10 +116,10 @@ class TouchableOpacity extends PureComponent<Props, {active: boolean}> {
112116
}
113117

114118
render() {
115-
const {useNative, style, modifiers, forwardedRef, ...others} = this.props;
119+
const {useNative, activeScale, style, modifiers, forwardedRef, ...others} = this.props;
116120
const {borderRadius, paddings, margins, alignments, flexStyle} = modifiers;
117121

118-
if (useNative) {
122+
if (useNative || !_.isUndefined(activeScale)) {
119123
// @ts-ignore
120124
return <IncubatorTouchableOpacity {...this.props}/>;
121125
}

0 commit comments

Comments
 (0)