verdnatura-chat/app/views/RoomInfoEditView/SwitchContainer.js

50 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { View, Text, Switch } from 'react-native';
import PropTypes from 'prop-types';
import styles from './styles';
2019-12-04 16:39:53 +00:00
import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors';
export default class SwitchContainer extends React.PureComponent {
static propTypes = {
value: PropTypes.bool,
disabled: PropTypes.bool,
leftLabelPrimary: PropTypes.string,
leftLabelSecondary: PropTypes.string,
rightLabelPrimary: PropTypes.string,
rightLabelSecondary: PropTypes.string,
2018-05-23 13:39:18 +00:00
onValueChange: PropTypes.func,
2019-12-04 16:39:53 +00:00
theme: PropTypes.string,
2018-05-23 13:39:18 +00:00
testID: PropTypes.string
}
render() {
const {
2019-12-04 16:39:53 +00:00
value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID
} = this.props;
return (
[
<View key='switch-container' style={styles.switchContainer}>
2019-12-04 16:39:53 +00:00
<View style={styles.switchLabelContainer}>
<Text style={[styles.switchLabelPrimary, { color: themes[theme].titleText }]}>{leftLabelPrimary}</Text>
<Text style={[styles.switchLabelSecondary, { color: themes[theme].titleText }]}>{leftLabelSecondary}</Text>
</View>
<Switch
style={styles.switch}
onValueChange={onValueChange}
value={value}
disabled={disabled}
trackColor={SWITCH_TRACK_COLOR}
2018-05-23 13:39:18 +00:00
testID={testID}
/>
<View style={styles.switchLabelContainer}>
2019-12-04 16:39:53 +00:00
<Text style={[styles.switchLabelPrimary, { color: themes[theme].titleText }]}>{rightLabelPrimary}</Text>
<Text style={[styles.switchLabelSecondary, { color: themes[theme].titleText }]}>{rightLabelSecondary}</Text>
</View>
</View>,
2019-12-04 16:39:53 +00:00
<View key='switch-divider' style={[styles.divider, { borderColor: themes[theme].separatorColor }]} />
]
);
}
}