2019-12-04 16:39:53 +00:00
|
|
|
import React from 'react';
|
2022-01-12 12:54:04 +00:00
|
|
|
import { RectButton, RectButtonProps } from 'react-native-gesture-handler';
|
2019-12-04 16:39:53 +00:00
|
|
|
|
|
|
|
import { themes } from '../constants/colors';
|
|
|
|
|
2022-01-12 12:54:04 +00:00
|
|
|
interface ITouchProps extends RectButtonProps {
|
|
|
|
children: React.ReactNode;
|
|
|
|
theme: string;
|
|
|
|
accessibilityLabel?: string;
|
|
|
|
testID?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Touch extends React.Component<ITouchProps> {
|
|
|
|
private ref: any;
|
|
|
|
|
|
|
|
setNativeProps(props: ITouchProps): void {
|
2019-12-04 16:39:53 +00:00
|
|
|
this.ref.setNativeProps(props);
|
|
|
|
}
|
|
|
|
|
2022-01-12 12:54:04 +00:00
|
|
|
getRef = (ref: RectButton): void => {
|
2019-12-04 16:39:53 +00:00
|
|
|
this.ref = ref;
|
|
|
|
};
|
|
|
|
|
2022-01-12 12:54:04 +00:00
|
|
|
render(): JSX.Element {
|
2021-09-13 20:41:05 +00:00
|
|
|
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}
|
2021-01-21 19:52:26 +00:00
|
|
|
underlayColor={underlayColor || themes[theme].bannerBackground}
|
2019-12-04 16:39:53 +00:00
|
|
|
rippleColor={themes[theme].bannerBackground}
|
2021-09-13 20:41:05 +00:00
|
|
|
{...props}>
|
2019-12-04 16:39:53 +00:00
|
|
|
{children}
|
|
|
|
</RectButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Touch;
|