Replaces the inheritance with composition pattern in the Symptom view

This commit is contained in:
Sofiya Tepikin
2019-08-16 20:32:02 +02:00
parent c0235d148b
commit 8ce840306a
17 changed files with 2577 additions and 2495 deletions
@@ -0,0 +1,41 @@
import React, { Component } from 'react'
import { TouchableOpacity } from 'react-native'
import PropTypes from 'prop-types'
import Icon from 'react-native-vector-icons/Entypo'
import InfoPopUp from './info-symptom'
import styles, { iconStyles } from '../../../styles'
export default class SymptomInfo extends Component {
static propTypes = {
symptom: PropTypes.string
}
constructor() {
super()
this.state = { showInfo: false }
}
showInfo = () => this.setState({ showInfo: true })
hideInfo = () => this.setState({ showInfo: false })
render() {
return (
<React.Fragment>
<TouchableOpacity
onPress={this.showInfo}
style={styles.infoButtonSymptomView}
testID="symptomInfoButton"
>
<Icon name="info-with-circle" style={iconStyles.info} />
</TouchableOpacity>
{ this.state.showInfo &&
<InfoPopUp symptom={this.props.symptom} close={this.hideInfo} />
}
</React.Fragment>
)
}
}