mattermost-mobile/app/components/post_draft/send_action/index.js
Elias Nahum 48f1875cf1
MM-23090 MM-26078 && MM-26876 Refactor post draft component (#4621)
* Refactor post draft component
Re-styled ReadOnly channels
Remove filename from upload error

* Update canSubmit based on file attachment changes

* Fix error message for max file size

* Fix select autocomplete values on iOS

* Style readonly and refactor accessory view for iOS

* Make PostDraft scrollViewNativeID prop not required

* Update ReadOnly to have a background with 0.40 opacity

* Update max file size error message

* Fix shift+enter with HW keyboard
2020-08-06 19:39:25 -04:00

78 lines
2.1 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 '@components/touchable_with_feedback';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
let PaperPlane = null;
function SendButton(props) {
const {theme} = props;
const style = getStyleSheet(theme);
if (!PaperPlane) {
PaperPlane = require('./paper_plane').default;
}
if (props.disabled) {
return (
<View style={style.sendButtonContainer}>
<View style={[style.sendButton, style.disableButton]}>
<PaperPlane
height={16}
width={19}
color={changeOpacity(theme.buttonColor, 0.5)}
/>
</View>
</View>
);
}
return (
<TouchableWithFeedback
onPress={props.handleSendMessage}
style={style.sendButtonContainer}
type={'opacity'}
>
<View style={style.sendButton}>
<PaperPlane
height={16}
width={19}
color={theme.buttonColor}
/>
</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',
paddingRight: 8,
},
sendButton: {
backgroundColor: theme.buttonBg,
borderRadius: 4,
height: 32,
width: 80,
alignItems: 'center',
justifyContent: 'center',
},
};
});
export default memo(SendButton);