Rocket.Chat.ReactNative/app/utils/touch.tsx

42 lines
901 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 { themes } from '../constants/colors';
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);
}
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;