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