mattermost-mobile/app/components/message_attachments/action_button/action_button.js
Orjiewuru Kingdom Isaac 102eeb93fe MM-13151 Increase double tap delay for post action buttons (#2406)
* Use app state to disable a button when click to prevent double tap

* remove disable button state after 4000ms

* modify preventDoubleTap to have optional delayTime param

* remove local state use for button control

* remove unused method

* remove app state method to disable a button

* Update tap.js
2019-04-02 10:22:31 -04:00

61 lines
1.7 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import {Text} from 'react-native';
import PropTypes from 'prop-types';
import Button from 'react-native-button';
import {preventDoubleTap} from 'app/utils/tap';
import {makeStyleSheetFromTheme} from 'app/utils/theme';
export default class ActionButton extends PureComponent {
static propTypes = {
actions: PropTypes.shape({
doPostAction: PropTypes.func.isRequired,
}).isRequired,
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
postId: PropTypes.string.isRequired,
theme: PropTypes.object.isRequired,
};
handleActionPress = preventDoubleTap(() => {
const {actions, id, postId} = this.props;
actions.doPostAction(postId, id);
}, 4000);
render() {
const {name, theme} = this.props;
const style = getStyleSheet(theme);
return (
<Button
containerStyle={style.button}
onPress={this.handleActionPress}
>
<Text style={style.text}>{name}</Text>
</Button>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
button: {
borderRadius: 2,
backgroundColor: theme.buttonBg,
alignItems: 'center',
marginBottom: 2,
marginRight: 5,
marginTop: 10,
paddingHorizontal: 10,
paddingVertical: 7,
},
text: {
color: theme.buttonColor,
fontSize: 12,
fontWeight: '600',
},
};
});