Add press handlers to buttons
This commit is contained in:
@@ -18,14 +18,13 @@ export default class AppWrapper extends Component {
|
||||
|
||||
async checkLicenseAgreement() {
|
||||
const agreed = await getLicenseFlag()
|
||||
console.log(agreed)
|
||||
if (agreed) this.setState({showLicense: false})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
this.state.showLicense ?
|
||||
<License/>
|
||||
<License setLicense={() => this.setState({showLicense: false})}/>
|
||||
:
|
||||
<View style={{ flex: 1 }}>
|
||||
{this.state.showApp ?
|
||||
|
||||
+11
-9
@@ -1,18 +1,20 @@
|
||||
import React from 'react'
|
||||
import { View } from 'react-native'
|
||||
import { TouchableOpacity } from 'react-native'
|
||||
import AppText from './app-text'
|
||||
import styles from '../styles'
|
||||
|
||||
export default function Button({ backgroundColor, style, children }) {
|
||||
export default function Button(props) {
|
||||
return (
|
||||
<View style={[
|
||||
styles.button,
|
||||
style,
|
||||
{backgroundColor}
|
||||
]}>
|
||||
<TouchableOpacity
|
||||
onPress={props.onPress}
|
||||
style={[
|
||||
styles.button,
|
||||
props.style,
|
||||
{backgroundColor: props.backgroundColor}
|
||||
]}>
|
||||
<AppText style={styles.homeButtonText}>
|
||||
{children}
|
||||
{props.children}
|
||||
</AppText>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
+9
-3
@@ -66,7 +66,9 @@ export default class Home extends Component {
|
||||
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
|
||||
}
|
||||
|
||||
<Button backgroundColor={cycleDayColor}>
|
||||
<Button
|
||||
onPress={() => this.passTodayTo('CycleDay')}
|
||||
backgroundColor={cycleDayColor}>
|
||||
{labels.editToday}
|
||||
</Button>
|
||||
|
||||
@@ -91,7 +93,9 @@ export default class Home extends Component {
|
||||
</AppText>
|
||||
}
|
||||
|
||||
<Button backgroundColor={periodColor}>
|
||||
<Button
|
||||
onPress={() => this.passTodayTo('BleedingEditView')}
|
||||
backgroundColor={periodColor}>
|
||||
{labels.trackPeriod}
|
||||
</Button>
|
||||
|
||||
@@ -124,7 +128,9 @@ export default class Home extends Component {
|
||||
</AppText>
|
||||
}
|
||||
|
||||
<Button backgroundColor={secondaryColor}>
|
||||
<Button
|
||||
onPress={() => this.props.navigate('Chart')}
|
||||
backgroundColor={secondaryColor}>
|
||||
{labels.checkFertility}
|
||||
</Button>
|
||||
</TouchableOpacity>
|
||||
|
||||
+16
-4
@@ -1,19 +1,31 @@
|
||||
import React from 'react'
|
||||
import { ScrollView, View } from 'react-native'
|
||||
import { ScrollView, View, BackHandler } from 'react-native'
|
||||
import AppText from './app-text'
|
||||
import { licenseText, shared } from '../i18n/en/labels'
|
||||
import styles,{secondaryColor} from '../styles'
|
||||
import Button from './button'
|
||||
import { saveLicenseFlag } from '../local-storage';
|
||||
|
||||
export default function License() {
|
||||
export default function License({setLicense}) {
|
||||
return (
|
||||
<ScrollView style={styles.licensePage}>
|
||||
<AppText>{licenseText}</AppText>
|
||||
<View style={styles.licenseButtons}>
|
||||
<Button style={styles.licenseButton} backgroundColor={'grey'}>
|
||||
<Button
|
||||
style={styles.licenseButton}
|
||||
backgroundColor={'grey'}
|
||||
onPress={() => BackHandler.exitApp()}
|
||||
>
|
||||
{shared.cancel}
|
||||
</Button>
|
||||
<Button style={styles.licenseButton} backgroundColor={secondaryColor}>
|
||||
<Button
|
||||
style={styles.licenseButton}
|
||||
backgroundColor={secondaryColor}
|
||||
onPress={async () => {
|
||||
await saveLicenseFlag()
|
||||
setLicense()
|
||||
}}
|
||||
>
|
||||
{shared.ok}
|
||||
</Button>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user