MM-18330 - Updating arrow prop (#3248)

This commit is contained in:
Asaad Mahmood 2019-09-12 18:00:09 +05:00 committed by Saturnino Abril
parent 3706de21e0
commit 2b7df2307c
2 changed files with 25 additions and 12 deletions

View file

@ -570,6 +570,7 @@ export default class ChannelInfo extends PureComponent {
defaultMessage={defaultMessage}
icon='times'
iconColor='#CA3B27'
rightArrow={false}
textId={i18nId}
textColor='#CA3B27'
theme={theme}

View file

@ -25,7 +25,7 @@ function createTouchableComponent(children, action) {
}
function channelInfoRow(props) {
const {action, defaultMessage, detail, icon, iconColor, image, imageTintColor, textColor, textId, togglable, theme, shouldRender, isLandscape} = props;
const {action, defaultMessage, detail, icon, iconColor, image, imageTintColor, rightArrow, textColor, textId, togglable, theme, shouldRender, isLandscape} = props;
if (!shouldRender) {
return null;
@ -52,6 +52,26 @@ function channelInfoRow(props) {
);
}
let actionElement = null;
if (togglable) {
actionElement = (
<Switch
onValueChange={action}
value={detail}
/>
);
}
if (rightArrow) {
actionElement = (
<Icon
name='angle-right'
size={20}
style={style.rightIcon}
/>
);
}
const RowComponent = (
<View style={[style.container, padding(isLandscape)]}>
{iconElement}
@ -61,17 +81,7 @@ function channelInfoRow(props) {
defaultMessage={defaultMessage}
/>
<Text style={style.detail}>{detail}</Text>
{togglable ?
<Switch
onValueChange={action}
value={detail}
/> :
<Icon
name='angle-right'
size={20}
style={style.rightIcon}
/>
}
{actionElement}
</View>
);
@ -94,6 +104,7 @@ channelInfoRow.propTypes = {
iconColor: PropTypes.string,
image: PropTypes.number,
imageTintColor: PropTypes.string,
rightArrow: PropTypes.bool,
textId: PropTypes.string.isRequired,
togglable: PropTypes.bool,
textColor: PropTypes.string,
@ -101,6 +112,7 @@ channelInfoRow.propTypes = {
};
channelInfoRow.defaultProps = {
rightArrow: true,
togglable: false,
shouldRender: true,
};