diff --git a/components/header.js b/components/header.js deleted file mode 100644 index 9ebbe58e4b291069c8fe24b1cdde3580bdb2f199..0000000000000000000000000000000000000000 --- a/components/header.js +++ /dev/null @@ -1,70 +0,0 @@ -import React, { Component } from 'react' -import { - View, - Text, - Dimensions -} from 'react-native' -import moment from 'moment' -import styles, { iconStyles } from '../styles' -import Icon from 'react-native-vector-icons/Entypo' -import FeatherIcon from 'react-native-vector-icons/Feather' - -export default class Header extends Component { - render() { - const middle = Dimensions.get('window').width / 2 - return ( - this.props.isCycleDayOverView ? - <View style={[styles.header, styles.headerCycleDay]}> - <View - style={styles.accentCircle} - left={middle - styles.accentCircle.width / 2} - /> - <Icon - name='chevron-thin-left' - {...iconStyles.navigationArrow} - onPress={() => this.props.goToCycleDay('before')} - /> - <View> - <Text style={styles.dateHeader}> - {moment(this.props.date).format('MMMM Do YYYY')} - </Text> - {this.props.cycleDayNumber && - <Text style={styles.cycleDayNumber} > - Cycle day {this.props.cycleDayNumber} - </Text>} - </View > - <Icon - name='chevron-thin-right' - {...iconStyles.navigationArrow} - onPress={() => this.props.goToCycleDay('after')} - /> - </View > - : this.props.isSymptomView ? - <View style={[styles.header, styles.headerSymptom]}> - <View style={styles.accentCircle} left={middle - styles.accentCircle.width / 2}/> - <Icon - name='chevron-thin-left' - {...iconStyles.navigationArrow} - onPress={() => this.props.goBack()} - - /> - <View> - <Text style={styles.dateHeader}> - {this.props.title} - </Text> - </View > - <FeatherIcon - name='info' - {...iconStyles.symptomHeaderIcons} - /> - </View> - : - <View style={styles.header}> - <View style={styles.accentCircle} /> - <Text style={styles.headerText}> - {this.props.title} - </Text> - </View > - ) - } -} \ No newline at end of file diff --git a/components/header/cycle-day.js b/components/header/cycle-day.js new file mode 100644 index 0000000000000000000000000000000000000000..a78cf1b11939bba1f8616e3b0bae46597b565ac9 --- /dev/null +++ b/components/header/cycle-day.js @@ -0,0 +1,28 @@ +import React from 'react' +import { + View, + Text} from 'react-native' +import moment from 'moment' +import styles from '../../styles' +import NavigationArrow from './navigation-arrow' + +export default function CycleDayHeader(props) { + return (<View style={[styles.header, styles.headerCycleDay]}> + <View + style={styles.accentCircle} + left={props.middle - styles.accentCircle.width / 2} + /> + <NavigationArrow direction='left' {...props}/> + <View> + <Text style={styles.dateHeader}> + {moment(props.date).format('MMMM Do YYYY')} + </Text> + {props.cycleDayNumber && + <Text style={styles.cycleDayNumber}> + Cycle day {props.cycleDayNumber} + </Text>} + </View> + <NavigationArrow direction='right' {...props}/> + </View> + ) +} \ No newline at end of file diff --git a/components/header/index.js b/components/header/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c935f6e5e8743282799408b5d0cb1eaba3612f71 --- /dev/null +++ b/components/header/index.js @@ -0,0 +1,27 @@ +import React from 'react' +import { + View, + Text, + Dimensions +} from 'react-native' +import styles from '../../styles' +import CycleDayHeader from './cycle-day' +import SymptomViewHeader from './symptom-view' + +export default function Header(p) { + const middle = Dimensions.get('window').width / 2 + const props = Object.assign({}, p, {middle}) + return ( + props.isCycleDayOverView ? + <CycleDayHeader {...props} /> + : props.isSymptomView ? + <SymptomViewHeader {...props}/> + : + <View style={styles.header}> + <View style={styles.accentCircle} /> + <Text style={styles.headerText}> + {props.title} + </Text> + </View > + ) +} \ No newline at end of file diff --git a/components/header/navigation-arrow.js b/components/header/navigation-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..6a7b95b00bb729387b47746e217e03c16d7d8f7e --- /dev/null +++ b/components/header/navigation-arrow.js @@ -0,0 +1,31 @@ +import React from 'react' +import { TouchableOpacity } from 'react-native' +import styles, { iconStyles } from '../../styles' +import Icon from 'react-native-vector-icons/Entypo' + +export default function NavigationArrow(props) { + const iconName = { + left: 'chevron-thin-left', + right: 'chevron-thin-right' + }[props.direction] + let pressHandler + if (props.goBack) { + pressHandler = () => props.goBack() + } else { + pressHandler = () => { + const target = props.direction === 'left' ? 'before' : 'after' + props.goToCycleDay(target) + } + } + return ( + <TouchableOpacity + style={styles.navigationArrow} + onPress={pressHandler} + > + <Icon + name={iconName} + {...iconStyles.navigationArrow} + /> + </TouchableOpacity> + ) +} \ No newline at end of file diff --git a/components/header/symptom-view.js b/components/header/symptom-view.js new file mode 100644 index 0000000000000000000000000000000000000000..df8b4bebc872343f4dc2778c860e808e52c1ff05 --- /dev/null +++ b/components/header/symptom-view.js @@ -0,0 +1,31 @@ +import React from 'react' +import { + View, + Text} from 'react-native' +import styles, { iconStyles } from '../../styles' +import FeatherIcon from 'react-native-vector-icons/Feather' +import NavigationArrow from './navigation-arrow' + +export default function SymptomViewHeader(props) { + return ( + <View style={[styles.header, styles.headerCycleDay, styles.headerSymptom]}> + <View + style={styles.accentCircle} + left={props.middle - styles.accentCircle.width / 2} + /> + <NavigationArrow + direction='left' + {...props} + /> + <View> + <Text style={styles.dateHeader}> + {props.title} + </Text> + </View > + <FeatherIcon + name='info' + {...iconStyles.symptomHeaderIcons} + /> + </View> + ) +} \ No newline at end of file diff --git a/styles/index.js b/styles/index.js index 31e62f729a0357328af628ee07ecc98f7f19538f..9c3b0169eaddac94b2839a8937d0418881f57572 100644 --- a/styles/index.js +++ b/styles/index.js @@ -191,11 +191,20 @@ export default StyleSheet.create({ }, header: { backgroundColor: primaryColor, - paddingHorizontal: 15, alignItems: 'center', justifyContent: 'center', height: 80 }, + headerCycleDay: { + flexDirection: 'row', + justifyContent: 'space-between', + }, + headerSymptom: { + paddingRight: 20 + }, + navigationArrow: { + padding: 20 + }, menu: { backgroundColor: primaryColor, alignItems: 'center', @@ -215,18 +224,6 @@ export default StyleSheet.create({ menuTextInActive: { color: colorInActive }, - headerCycleDay: { - flexDirection: 'row', - justifyContent: 'space-between', - }, - headerSymptom: { - flexDirection: 'row', - justifyContent: 'space-between', - }, - navigationArrow: { - fontSize: 60, - color: fontOnPrimaryColor - }, temperatureTextInput: { fontSize: 20, color: 'black',