Set show more on homescreen to default and get rid of more/less switch
This commit is contained in:
+4
-39
@@ -1,42 +1,22 @@
|
|||||||
import { ChronoUnit, LocalDate } from 'js-joda'
|
import { ChronoUnit, LocalDate } from 'js-joda'
|
||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Dimensions, ScrollView, TouchableHighlight, View } from 'react-native'
|
import { ScrollView, View } from 'react-native'
|
||||||
import Icon from 'react-native-vector-icons/Entypo'
|
|
||||||
|
|
||||||
import DripHomeIcon from '../assets/drip-home-icons'
|
import DripHomeIcon from '../assets/drip-home-icons'
|
||||||
import { getCycleDay } from '../db'
|
import { getCycleDay } from '../db'
|
||||||
import {
|
import {
|
||||||
bleedingPrediction as predictLabels,
|
bleedingPrediction as predictLabels,
|
||||||
home as labels,
|
home as labels
|
||||||
shared,
|
|
||||||
} from '../i18n/en/labels'
|
} from '../i18n/en/labels'
|
||||||
import links from '../i18n/en/links'
|
import links from '../i18n/en/links'
|
||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
||||||
import styles, { cycleDayColor, periodColor, secondaryColor } from '../styles'
|
import styles, { cycleDayColor, periodColor, secondaryColor } from '../styles'
|
||||||
|
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import Button from './button'
|
import Button from './button'
|
||||||
import { formatDateForShortText } from './helpers/format-date'
|
import { formatDateForShortText } from './helpers/format-date'
|
||||||
|
|
||||||
const ShowMoreToggler = ({ isShowingMore, onToggle }) => {
|
|
||||||
const {height, width} = Dimensions.get('window')
|
|
||||||
const leftPosition = isShowingMore ? 10 : width - 40
|
|
||||||
const style = isShowingMore ? styles.showLess : styles.showMore
|
|
||||||
const topPosition = height / 2 - styles.header.height - 30
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TouchableHighlight
|
|
||||||
onPress={onToggle}
|
|
||||||
style={[style, { top: topPosition, left: leftPosition}]}
|
|
||||||
>
|
|
||||||
<View style={{alignItems: 'center'}}>
|
|
||||||
<AppText>{isShowingMore ? shared.less : shared.more}</AppText>
|
|
||||||
<Icon name='chevron-thin-down' />
|
|
||||||
</View>
|
|
||||||
</TouchableHighlight>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const IconText = ({ children, wrapperStyles }) => {
|
const IconText = ({ children, wrapperStyles }) => {
|
||||||
return (
|
return (
|
||||||
<View style={[styles.homeIconTextWrapper, wrapperStyles]}>
|
<View style={[styles.homeIconTextWrapper, wrapperStyles]}>
|
||||||
@@ -75,7 +55,6 @@ export default class Home extends Component {
|
|||||||
const fertilityStatus = getFertilityStatusForDay(this.todayDateString)
|
const fertilityStatus = getFertilityStatusForDay(this.todayDateString)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isShowingMore: false,
|
|
||||||
cycleDayNumber: this.getCycleDayNumber(this.todayDateString),
|
cycleDayNumber: this.getCycleDayNumber(this.todayDateString),
|
||||||
predictionText: determinePredictionText(prediction),
|
predictionText: determinePredictionText(prediction),
|
||||||
bleedingPredictionRange: getBleedingPredictionRange(prediction),
|
bleedingPredictionRange: getBleedingPredictionRange(prediction),
|
||||||
@@ -91,12 +70,8 @@ export default class Home extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleShowingMore = () => {
|
|
||||||
this.setState({ isShowingMore: !this.state.isShowingMore })
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isShowingMore, cycleDayNumber, phase, status } = this.state
|
const { cycleDayNumber, phase, status } = this.state
|
||||||
const { navigate } = this.props
|
const { navigate } = this.props
|
||||||
const cycleDayMoreText = cycleDayNumber ?
|
const cycleDayMoreText = cycleDayNumber ?
|
||||||
labels.cycleDayKnown(cycleDayNumber) :
|
labels.cycleDayKnown(cycleDayNumber) :
|
||||||
@@ -121,9 +96,7 @@ export default class Home extends Component {
|
|||||||
{cycleDayNumber || labels.unknown}
|
{cycleDayNumber || labels.unknown}
|
||||||
</IconText>
|
</IconText>
|
||||||
|
|
||||||
{ isShowingMore &&
|
|
||||||
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
|
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
|
||||||
}
|
|
||||||
</HomeElement>
|
</HomeElement>
|
||||||
|
|
||||||
<HomeElement
|
<HomeElement
|
||||||
@@ -139,11 +112,9 @@ export default class Home extends Component {
|
|||||||
{this.state.bleedingPredictionRange}
|
{this.state.bleedingPredictionRange}
|
||||||
</IconText>
|
</IconText>
|
||||||
|
|
||||||
{ isShowingMore &&
|
|
||||||
<AppText style={styles.paragraph}>
|
<AppText style={styles.paragraph}>
|
||||||
{this.state.predictionText}
|
{this.state.predictionText}
|
||||||
</AppText>
|
</AppText>
|
||||||
}
|
|
||||||
</HomeElement>
|
</HomeElement>
|
||||||
|
|
||||||
<HomeElement
|
<HomeElement
|
||||||
@@ -160,20 +131,14 @@ export default class Home extends Component {
|
|||||||
{ phase &&
|
{ phase &&
|
||||||
<AppText>{`${labels.phase(phase)} (${status})`}</AppText>
|
<AppText>{`${labels.phase(phase)} (${status})`}</AppText>
|
||||||
}
|
}
|
||||||
{ isShowingMore &&
|
|
||||||
<View>
|
<View>
|
||||||
<AppText styles={styles.paragraph}>
|
<AppText styles={styles.paragraph}>
|
||||||
{ `${statusText} ${links.wiki.url}.` }
|
{ `${statusText} ${links.wiki.url}.` }
|
||||||
</AppText>
|
</AppText>
|
||||||
</View>
|
</View>
|
||||||
}
|
|
||||||
</HomeElement>
|
</HomeElement>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ShowMoreToggler
|
|
||||||
isShowingMore={isShowingMore}
|
|
||||||
onToggle={this.toggleShowingMore}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ export const shared = {
|
|||||||
date: 'Date',
|
date: 'Date',
|
||||||
cycleDayWithLinebreak: 'Cycle\nday',
|
cycleDayWithLinebreak: 'Cycle\nday',
|
||||||
loading: 'Loading ...',
|
loading: 'Loading ...',
|
||||||
more: 'more',
|
|
||||||
less: 'less',
|
|
||||||
enter: 'Enter'
|
enter: 'Enter'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,14 +157,6 @@ export default StyleSheet.create({
|
|||||||
iconText: {
|
iconText: {
|
||||||
fontSize: 25
|
fontSize: 25
|
||||||
},
|
},
|
||||||
showMore: {
|
|
||||||
transform: [{rotate: '90deg'}],
|
|
||||||
position: 'absolute',
|
|
||||||
},
|
|
||||||
showLess: {
|
|
||||||
transform: [{rotate: '270deg'}],
|
|
||||||
position: 'absolute'
|
|
||||||
},
|
|
||||||
cycleDayNumber: {
|
cycleDayNumber: {
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
color: fontOnPrimaryColor,
|
color: fontOnPrimaryColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user