vn-verdnaturachat/app/utils/touch.js

41 lines
828 B
JavaScript
Raw Normal View History

2019-12-04 16:39:53 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { RectButton } from 'react-native-gesture-handler';
import { themes } from '../constants/colors';
class Touch extends React.Component {
setNativeProps(props) {
this.ref.setNativeProps(props);
}
getRef = ref => {
2019-12-04 16:39:53 +00:00
this.ref = ref;
};
render() {
const { children, onPress, theme, underlayColor, ...props } = this.props;
2019-12-04 16:39:53 +00:00
return (
<RectButton
ref={this.getRef}
onPress={onPress}
activeOpacity={1}
underlayColor={underlayColor || themes[theme].bannerBackground}
2019-12-04 16:39:53 +00:00
rippleColor={themes[theme].bannerBackground}
{...props}>
2019-12-04 16:39:53 +00:00
{children}
</RectButton>
);
}
}
Touch.propTypes = {
children: PropTypes.node,
onPress: PropTypes.func,
theme: PropTypes.string,
underlayColor: PropTypes.string
2019-12-04 16:39:53 +00:00
};
export default Touch;