Skip to content
Snippets Groups Projects
Commit 71af282d authored by Julia Friesel's avatar Julia Friesel
Browse files

Convert radio button group to select tab group

parent 1d0b2497
No related branches found
No related tags found
No related merge requests found
...@@ -6,13 +6,21 @@ import { ...@@ -6,13 +6,21 @@ import {
import styles from '../../styles' import styles from '../../styles'
import { AppText } from '../app-text' import { AppText } from '../app-text'
export default class RadioButton extends Component { export default class SelectTabGroup extends Component {
render() { render() {
return ( return (
<View style={styles.radioButtonGroup}> <View style={styles.selectTabGroup}>
{ {
this.props.buttons.map(({ label, value }) => { this.props.buttons.map(({ label, value }, i) => {
let firstOrLastStyle
if (i === this.props.buttons.length - 1) {
firstOrLastStyle = styles.selectTabLast
} else if (i === 0) {
firstOrLastStyle = styles.selectTabFirst
}
let activeStyle
const isActive = value === this.props.active const isActive = value === this.props.active
if (isActive) activeStyle = styles.selectTabActive
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={() => this.props.onSelect(value)} onPress={() => this.props.onSelect(value)}
...@@ -20,11 +28,13 @@ export default class RadioButton extends Component { ...@@ -20,11 +28,13 @@ export default class RadioButton extends Component {
activeOpacity={1} activeOpacity={1}
> >
<View style={styles.radioButtonTextGroup}> <View style={styles.radioButtonTextGroup}>
<View style={styles.radioButton}> <View style={[
{isActive ? styles.selectTab,
<View style={styles.radioButtonActiveDot}/> : null} firstOrLastStyle,
activeStyle
]}>
<AppText style={activeStyle}>{label}</AppText>
</View> </View>
<AppText>{label}</AppText>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
) )
......
...@@ -8,7 +8,7 @@ import styles from '../../../styles' ...@@ -8,7 +8,7 @@ import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { bleeding as labels } from '../labels/labels' import { bleeding as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader, AppText } from '../../app-text' import { SymptomSectionHeader, AppText } from '../../app-text'
export default class Bleeding extends Component { export default class Bleeding extends Component {
...@@ -39,7 +39,7 @@ export default class Bleeding extends Component { ...@@ -39,7 +39,7 @@ export default class Bleeding extends Component {
<View> <View>
<SymptomSectionHeader>Heaviness</SymptomSectionHeader> <SymptomSectionHeader>Heaviness</SymptomSectionHeader>
<AppText>How heavy is the bleeding?</AppText> <AppText>How heavy is the bleeding?</AppText>
<RadioButtonGroup <SelectTabGroup
buttons={bleedingRadioProps} buttons={bleedingRadioProps}
active={this.state.currentValue} active={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
......
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
cervixPosition as positionLabels cervixPosition as positionLabels
} from '../labels/labels' } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader } from '../../app-text' import { SymptomSectionHeader } from '../../app-text'
export default class Cervix extends Component { export default class Cervix extends Component {
...@@ -54,19 +54,19 @@ export default class Cervix extends Component { ...@@ -54,19 +54,19 @@ export default class Cervix extends Component {
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<SymptomSectionHeader>Opening</SymptomSectionHeader> <SymptomSectionHeader>Opening</SymptomSectionHeader>
<RadioButtonGroup <SelectTabGroup
buttons={cervixOpeningRadioProps} buttons={cervixOpeningRadioProps}
active={this.state.opening} active={this.state.opening}
onSelect={val => this.setState({ opening: val })} onSelect={val => this.setState({ opening: val })}
/> />
<SymptomSectionHeader>Firmness</SymptomSectionHeader> <SymptomSectionHeader>Firmness</SymptomSectionHeader>
<RadioButtonGroup <SelectTabGroup
buttons={cervixFirmnessRadioProps} buttons={cervixFirmnessRadioProps}
active={this.state.firmness} active={this.state.firmness}
onSelect={val => this.setState({ firmness: val })} onSelect={val => this.setState({ firmness: val })}
/> />
<SymptomSectionHeader>Position</SymptomSectionHeader> <SymptomSectionHeader>Position</SymptomSectionHeader>
<RadioButtonGroup <SelectTabGroup
buttons={cervixPositionRadioProps} buttons={cervixPositionRadioProps}
active={this.state.position} active={this.state.position}
onSelect={val => this.setState({ position: val })} onSelect={val => this.setState({ position: val })}
......
...@@ -7,7 +7,7 @@ import styles from '../../../styles' ...@@ -7,7 +7,7 @@ import styles from '../../../styles'
import { saveSymptom } from '../../../db' import { saveSymptom } from '../../../db'
import { intensity as labels } from '../labels/labels' import { intensity as labels } from '../labels/labels'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group' import SelectTabGroup from '../select-tab-group'
export default class Desire extends Component { export default class Desire extends Component {
constructor(props) { constructor(props) {
...@@ -31,7 +31,7 @@ export default class Desire extends Component { ...@@ -31,7 +31,7 @@ export default class Desire extends Component {
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<RadioButtonGroup <SelectTabGroup
buttons={desireRadioProps} buttons={desireRadioProps}
acitve={this.state.currentValue} acitve={this.state.currentValue}
onSelect={val => this.setState({ currentValue: val })} onSelect={val => this.setState({ currentValue: val })}
......
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
} from '../labels/labels' } from '../labels/labels'
import computeSensiplanValue from '../../../lib/sensiplan-mucus' import computeSensiplanValue from '../../../lib/sensiplan-mucus'
import ActionButtonFooter from './action-button-footer' import ActionButtonFooter from './action-button-footer'
import RadioButtonGroup from '../radio-button-group' import SelectTabGroup from '../select-tab-group'
import { SymptomSectionHeader } from '../../app-text' import { SymptomSectionHeader } from '../../app-text'
...@@ -52,13 +52,13 @@ export default class Mucus extends Component { ...@@ -52,13 +52,13 @@ export default class Mucus extends Component {
<ScrollView style={styles.page}> <ScrollView style={styles.page}>
<View> <View>
<SymptomSectionHeader>Feeling</SymptomSectionHeader> <SymptomSectionHeader>Feeling</SymptomSectionHeader>
<RadioButtonGroup <SelectTabGroup
buttons={mucusFeeling} buttons={mucusFeeling}
onSelect={val => this.setState({ feeling: val })} onSelect={val => this.setState({ feeling: val })}
active={this.state.feeling} active={this.state.feeling}
/> />
<SymptomSectionHeader>Texture</SymptomSectionHeader> <SymptomSectionHeader>Texture</SymptomSectionHeader>
<RadioButtonGroup <SelectTabGroup
buttons={mucusTexture} buttons={mucusTexture}
onSelect={val => this.setState({ texture: val })} onSelect={val => this.setState({ texture: val })}
active={this.state.texture} active={this.state.texture}
......
...@@ -213,31 +213,33 @@ export default StyleSheet.create({ ...@@ -213,31 +213,33 @@ export default StyleSheet.create({
flexWrap: 'wrap', flexWrap: 'wrap',
marginVertical: 10, marginVertical: 10,
}, },
radioButtonGroup: { selectTabGroup: {
marginTop: 10 marginTop: 10,
flexDirection: 'row'
}, },
radioButton: { selectTab: {
width: 20, backgroundColor: 'lightgrey',
height: 20,
borderRadius: 100,
borderStyle: 'solid', borderStyle: 'solid',
borderWidth: 2, borderLeftWidth: 1,
borderColor: secondaryColor, paddingVertical: 10,
paddingHorizontal: 15,
borderColor: 'white',
marginBottom: 3, marginBottom: 3,
marginRight: 10,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center' justifyContent: 'center'
}, },
radioButtonActiveDot: { selectTabActive: {
width: 10, backgroundColor: secondaryColor,
height: 10, color: fontOnPrimaryColor
borderRadius: 100,
backgroundColor: secondaryColor
}, },
radioButtonTextGroup: { selectTabLast: {
marginRight: 10, borderTopRightRadius: 10,
flexDirection: 'row', borderBottomRightRadius: 10,
marginBottom: 10 },
selectTabFirst: {
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
borderLeftWidth: null
}, },
page: { page: {
marginHorizontal: 10 marginHorizontal: 10
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment