mattermost-mobile/app/components/touchable_with_feedback/touchable_with_feedback.ios.js
Joseph Baylon 48dbb75471
MM-29024 Detox/E2E: Add unit and e2e tests for disabled mobile upload (#4954)
* MM-29024 Detox/E2E: Add unit and e2e tests for disabled mobile upload

* Simplified element call

* Remove extra lines

* Added e2e for mobile upload enabled - quick actions

* Fix upload item snap file

* Added check for license

* Fix lint

* Update function export

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-12 21:29:16 -03:00

71 lines
2 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import {PanResponder, TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback, View} from 'react-native';
import PropTypes from 'prop-types';
import CustomPropTypes from 'app/constants/custom_prop_types';
export default class TouchableWithFeedbackIOS extends PureComponent {
static propTypes = {
testID: PropTypes.string,
children: CustomPropTypes.Children,
cancelTouchOnPanning: PropTypes.bool,
type: PropTypes.oneOf(['native', 'opacity', 'none']),
};
static defaultProps = {
type: 'native',
};
constructor(props) {
super(props);
this.panResponder = PanResponder.create({
onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
return this.props.cancelTouchOnPanning && (gestureState.dx >= 5 || gestureState.dy >= 5 || gestureState.vx > 5);
},
});
}
render() {
const {testID, children, type, ...props} = this.props;
switch (type) {
case 'native':
return (
<View
testID={testID}
{...this.panResponder.panHandlers}
>
<TouchableHighlight
{...props}
>
{children}
</TouchableHighlight>
</View>
);
case 'opacity':
return (
<TouchableOpacity
testID={testID}
{...props}
>
{children}
</TouchableOpacity>
);
case 'none':
return (
<TouchableWithoutFeedback
testID={testID}
{...props}
>
{children}
</TouchableWithoutFeedback>
);
}
return null;
}
}