Extracts buttons on home screen as a component

This commit is contained in:
mashazyu
2018-12-02 13:15:46 +01:00
parent 9131c7a602
commit 0c22644c54
+27 -24
View File
@@ -14,6 +14,19 @@ import styles from '../styles'
import AppText, { AppTextLight } from './app-text' import AppText, { AppTextLight } from './app-text'
import nothingChanged from '../db/db-unchanged' import nothingChanged from '../db/db-unchanged'
const HomeButton = ({ backgroundColor, children }) => {
return (
<View style={[
styles.homeButton,
{backgroundColor}
]}>
<AppText style={styles.homeButtonText}>
{children}
</AppText>
</View>
)
}
export default class Home extends Component { export default class Home extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@@ -92,14 +105,11 @@ export default class Home extends Component {
{ this.state.showMore && { this.state.showMore &&
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText> <AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
} }
<View style={[
styles.homeButton, <HomeButton backgroundColor={cycleDayColor}>
{ backgroundColor: cycleDayColor } {labels.editToday}
]}> </HomeButton>
<AppText style={styles.homeButtonText}>
{labels.editToday}
</AppText>
</View>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
@@ -120,14 +130,11 @@ export default class Home extends Component {
{this.state.predictionText} {this.state.predictionText}
</AppText> </AppText>
} }
<View style={[
styles.homeButton, <HomeButton backgroundColor={periodColor}>
{ backgroundColor: periodColor } {labels.trackPeriod}
]}> </HomeButton>
<AppText style={styles.homeButtonText}>
{labels.trackPeriod}
</AppText>
</View>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
@@ -153,14 +160,10 @@ export default class Home extends Component {
{this.state.statusText} {this.state.statusText}
</AppText> </AppText>
} }
<View style={[
styles.homeButton, <HomeButton backgroundColor={secondaryColor}>
{ backgroundColor: secondaryColor } {labels.checkFertility}
]}> </HomeButton>
<AppText style={styles.homeButtonText}>
{labels.checkFertility}
</AppText>
</View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>