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
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } from '../theme';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2019-12-04 16:39:53 +00:00
|
|
|
|
2022-01-12 12:54:04 +00:00
|
|
|
interface ITouchProps extends RectButtonProps {
|
|
|
|
children: React.ReactNode;
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
2022-01-12 12:54:04 +00:00
|
|
|
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;
|