mattermost-mobile/app/components/post_draft/send_action/index.js
Joseph Baylon 5f6fd6df7a
MM-30286 Detox/E2E: Add e2e test for MM-T3236 and added basic unit tests (#4969)
* MM-30286 Detox/E2E: Add e2e test for MM-T3236

* Fix more testID hierarchies

* Fix typo

* Fix failing test

* Remove extra lines

* Updated to use string interpolation

* Update channels list element query

* Updated channel item unit test to be more consistent

* Fix error text testID hierarchies; fix edit channel info testIDs

* Fix snap file

* Fix line return
2020-11-24 16:58:09 +08:00

80 lines
2.3 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 CompassIcon from '@components/compass_icon';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
function SendButton(props) {
const {testID, theme} = props;
const sendButtonTestID = `${testID}.send.button`;
const sendButtonDisabledTestID = `${testID}.send.button.disabled`;
const style = getStyleSheet(theme);
if (props.disabled) {
return (
<View
testID={sendButtonDisabledTestID}
style={style.sendButtonContainer}
>
<View style={[style.sendButton, style.disableButton]}>
<CompassIcon
name='send'
size={24}
color={changeOpacity(theme.buttonColor, 0.5)}
/>
</View>
</View>
);
}
return (
<TouchableWithFeedback
testID={sendButtonTestID}
onPress={props.handleSendMessage}
style={style.sendButtonContainer}
type={'opacity'}
>
<View style={style.sendButton}>
<CompassIcon
name='send'
size={24}
color={theme.buttonColor}
/>
</View>
</TouchableWithFeedback>
);
}
SendButton.propTypes = {
testID: PropTypes.string,
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);