mattermost-mobile/app/components/send_button.js
Elias Nahum 9975a19b91
MM-18236 Prevent the post menu from triggering when using the back gesture (#3319)
* MM-18236 Prevent the post menu from triggering when using the back gesture in the thread screen

* Update snapshots

* Update app/components/touchable_with_feedback/touchable_with_feedback.ios.js

Co-Authored-By: Miguel Alatzar <migbot@users.noreply.github.com>

* Update app/components/touchable_with_feedback/touchable_with_feedback.ios.js

Co-Authored-By: Miguel Alatzar <migbot@users.noreply.github.com>

* Update app/components/post/post.js

Co-Authored-By: Miguel Alatzar <migbot@users.noreply.github.com>

* Update app/components/touchable_with_feedback/touchable_with_feedback.ios.js

* Fix eslint
2019-09-26 00:19:49 +03:00

79 lines
2 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {memo} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import TouchableWithFeedback from 'app/components/touchable_with_feedback';
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
let PaperPlane = null;
function SendButton(props) {
const {theme} = props;
const style = getStyleSheet(theme);
if (!PaperPlane) {
PaperPlane = require('app/components/paper_plane').default;
}
const icon = (
<PaperPlane
height={13}
width={15}
color={theme.buttonColor}
/>
);
if (props.disabled) {
return (
<View style={style.sendButtonContainer}>
<View style={[style.sendButton, style.disableButton]}>
{icon}
</View>
</View>
);
}
return (
<TouchableWithFeedback
onPress={props.handleSendMessage}
style={style.sendButtonContainer}
type={'opacity'}
>
<View style={style.sendButton}>
{icon}
</View>
</TouchableWithFeedback>
);
}
SendButton.propTypes = {
handleSendMessage: PropTypes.func.isRequired,
disabled: PropTypes.bool.isRequired,
theme: PropTypes.object.isRequired,
};
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
disableButton: {
backgroundColor: changeOpacity(theme.buttonBg, 0.3),
},
sendButtonContainer: {
justifyContent: 'flex-end',
paddingHorizontal: 5,
paddingVertical: 3,
},
sendButton: {
backgroundColor: theme.buttonBg,
borderRadius: 18,
height: 28,
width: 28,
alignItems: 'center',
justifyContent: 'center',
},
};
});
export default memo(SendButton);