mattermost-mobile/app/components/touchable_with_feedback/touchable_with_feedback.android.js
Mattermost Build 81b1ba8489
Fix propTypes warnings (#5285) (#5287)
(cherry picked from commit c6953bef47)

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2021-04-07 10:41:03 -04:00

60 lines
1.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable new-cap */
import React, {PureComponent} from 'react';
import {TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, View} from 'react-native';
import PropTypes from 'prop-types';
export default class TouchableWithFeedbackAndroid extends PureComponent {
static propTypes = {
testID: PropTypes.string,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf([PropTypes.node])]),
underlayColor: PropTypes.string,
type: PropTypes.oneOf(['native', 'opacity', 'none']),
};
static defaultProps = {
type: 'native',
};
render() {
const {testID, children, underlayColor, type, ...props} = this.props;
switch (type) {
case 'native':
return (
<TouchableNativeFeedback
testID={testID}
{...props}
background={TouchableNativeFeedback.Ripple(underlayColor || '#000', false)}
>
<View>
{children}
</View>
</TouchableNativeFeedback>
);
case 'opacity':
return (
<TouchableOpacity
testID={testID}
{...props}
>
{children}
</TouchableOpacity>
);
case 'none':
return (
<TouchableWithoutFeedback
testID={testID}
{...props}
>
{children}
</TouchableWithoutFeedback>
);
}
return null;
}
}