mattermost-mobile/app/components/touchable_with_feedback/touchable_with_feedback.android.tsx
Elias Nahum 784b05fe97
Upgrade Dependencies (#7299)
* upgrade reanimated

* update devDependencies

* upgrade react-intl

* update react-native and some dependencies

* update react-native-permissions

* update RN

* use Share sheet for Report a problem

* update Sentry

* remove step to downloadWebRTC

* update detox deps

* feedback review
2023-04-21 12:16:54 -04:00

55 lines
1.8 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable new-cap */
import React, {memo} from 'react';
import {Touchable, TouchableOpacity, TouchableNativeFeedback, TouchableWithoutFeedback, View, type StyleProp, type ViewStyle} from 'react-native';
type TouchableProps = Touchable & {
children: React.ReactNode | React.ReactNode[];
borderlessRipple?: boolean;
rippleRadius?: number;
style?: StyleProp<ViewStyle>;
testID: string;
type: 'native' | 'opacity' | 'none';
underlayColor: string;
}
const TouchableWithFeedbackAndroid = ({borderlessRipple = false, children, rippleRadius, testID, type = 'native', underlayColor, ...props}: TouchableProps) => {
switch (type) {
case 'native':
return (
<TouchableNativeFeedback
testID={testID}
{...props}
style={[props.style]}
background={TouchableNativeFeedback.Ripple(underlayColor || '#fff', borderlessRipple, rippleRadius)}
>
<View>
{children}
</View>
</TouchableNativeFeedback>
);
case 'opacity':
return (
<TouchableOpacity
testID={testID}
{...props}
>
{children}
</TouchableOpacity>
);
default:
return (
<TouchableWithoutFeedback
testID={testID}
{...props}
>
{children}
</TouchableWithoutFeedback>
);
}
};
export default memo(TouchableWithFeedbackAndroid);