verdnatura-chat/app/lib/methods/helpers/touch.tsx

44 lines
962 B
TypeScript
Raw Normal View History

2019-12-04 16:39:53 +00:00
import React from 'react';
import { RectButton, RectButtonProps } from 'react-native-gesture-handler';
2019-12-04 16:39:53 +00:00
import { TSupportedThemes } from '../../../theme';
import { themes } from '../../constants';
2019-12-04 16:39:53 +00:00
interface ITouchProps extends RectButtonProps {
children: React.ReactNode;
theme: TSupportedThemes;
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);
}
getRef = (ref: RectButton): void => {
2019-12-04 16:39:53 +00:00
this.ref = ref;
};
render(): JSX.Element {
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>
);
}
}
export default Touch;