Skip to content
Snippets Groups Projects
Commit 1102a40d authored by Julia Friesel's avatar Julia Friesel
Browse files

Merge branch '266-implement-consent-for-legal-stuff' into 'master'

Resolve "implement consent for legal stuff"

Closes #266

See merge request bloodyhealth/drip!144
parents c713ed54 b80c197b
No related branches found
No related tags found
No related merge requests found
...@@ -3,26 +3,42 @@ import { View } from 'react-native' ...@@ -3,26 +3,42 @@ import { View } from 'react-native'
import nodejs from 'nodejs-mobile-react-native' import nodejs from 'nodejs-mobile-react-native'
import App from './app' import App from './app'
import PasswordPrompt from './password-prompt' import PasswordPrompt from './password-prompt'
import License from './license'
import { getLicenseFlag } from '../local-storage'
export default class AppWrapper extends Component { export default class AppWrapper extends Component {
constructor() { constructor() {
super() super()
this.state = {} this.state = {
retrievingLicenseSetting: true
}
nodejs.start('main.js') nodejs.start('main.js')
this.checkLicenseAgreement()
} }
async checkLicenseAgreement() {
const agreed = await getLicenseFlag()
this.setState({retrievingLicenseSetting: false})
if (!agreed) this.setState({showLicense: true})
}
render() { render() {
return ( const whiteScreen = <View style={{ flex: 1 }}></View>
<View style={{ flex: 1 }}> const licenseScreen = <License setLicense={() => {
{this.state.showApp ? this.setState({showLicense: false})
<App/> }}/>
: const passwordPrompt = <PasswordPrompt showApp={() => {
<PasswordPrompt this.setState({showApp: true})
showApp={() => { }}/>
this.setState({showApp: true})
}} if (this.state.retrievingLicenseSetting) {
/> return whiteScreen
} } else if (this.state.showLicense) {
</View> return licenseScreen
) } else if (!this.state.showApp) {
return passwordPrompt
} else {
return <App/>
}
} }
} }
\ No newline at end of file
import React from 'react'
import { TouchableOpacity } from 'react-native'
import AppText from './app-text'
import styles from '../styles'
export default function Button(props) {
return (
<TouchableOpacity
onPress={props.onPress}
style={[
styles.button,
props.style,
{backgroundColor: props.backgroundColor}
]}>
<AppText style={styles.homeButtonText}>
{props.children}
</AppText>
</TouchableOpacity>
)
}
\ No newline at end of file
...@@ -10,19 +10,7 @@ import { getFertilityStatusForDay } from '../lib/sympto-adapter' ...@@ -10,19 +10,7 @@ import { getFertilityStatusForDay } from '../lib/sympto-adapter'
import styles from '../styles' import styles from '../styles'
import AppText, { AppTextLight } from './app-text' import AppText, { AppTextLight } from './app-text'
import DripHomeIcon from '../assets/drip-home-icons' import DripHomeIcon from '../assets/drip-home-icons'
import Button from './button'
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) {
...@@ -78,9 +66,11 @@ export default class Home extends Component { ...@@ -78,9 +66,11 @@ export default class Home extends Component {
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText> <AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
} }
<HomeButton backgroundColor={cycleDayColor}> <Button
onPress={() => this.passTodayTo('CycleDay')}
backgroundColor={cycleDayColor}>
{labels.editToday} {labels.editToday}
</HomeButton> </Button>
</TouchableOpacity> </TouchableOpacity>
...@@ -103,9 +93,11 @@ export default class Home extends Component { ...@@ -103,9 +93,11 @@ export default class Home extends Component {
</AppText> </AppText>
} }
<HomeButton backgroundColor={periodColor}> <Button
onPress={() => this.passTodayTo('BleedingEditView')}
backgroundColor={periodColor}>
{labels.trackPeriod} {labels.trackPeriod}
</HomeButton> </Button>
</TouchableOpacity> </TouchableOpacity>
...@@ -136,9 +128,11 @@ export default class Home extends Component { ...@@ -136,9 +128,11 @@ export default class Home extends Component {
</AppText> </AppText>
} }
<HomeButton backgroundColor={secondaryColor}> <Button
onPress={() => this.props.navigate('Chart')}
backgroundColor={secondaryColor}>
{labels.checkFertility} {labels.checkFertility}
</HomeButton> </Button>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
import React from 'react'
import { ScrollView, View, BackHandler } from 'react-native'
import Hyperlink from 'react-native-hyperlink'
import AppText from './app-text'
import { shared } from '../i18n/en/labels'
import settingsLabels from '../i18n/en/settings'
import styles,{secondaryColor} from '../styles'
import Button from './button'
import { saveLicenseFlag } from '../local-storage'
import replace from './helpers/replace-url-with-text'
const labels = settingsLabels.license
export default function License({setLicense}) {
return (
<ScrollView style={styles.licensePage}>
<Hyperlink linkStyle={styles.link} linkText={replace}>
<AppText style={styles.settingsSegmentTitle}>{labels.title}</AppText>
<AppText>{labels.text}</AppText>
</Hyperlink>
<View style={styles.licenseButtons}>
<Button
style={styles.licenseButton}
backgroundColor={'grey'}
onPress={() => BackHandler.exitApp()}
>
{shared.cancel}
</Button>
<Button
style={styles.licenseButton}
backgroundColor={secondaryColor}
onPress={async () => {
await saveLicenseFlag()
setLicense()
}}
>
{shared.ok}
</Button>
</View>
</ScrollView>
)
}
\ No newline at end of file
...@@ -116,4 +116,4 @@ export const fertilityStatus = { ...@@ -116,4 +116,4 @@ export const fertilityStatus = {
'double-check for yourself. Make sure the data makes sense to you.' 'double-check for yourself. Make sure the data makes sense to you.'
) )
} }
} }
\ No newline at end of file
...@@ -122,10 +122,7 @@ export default { ...@@ -122,10 +122,7 @@ export default {
title: 'drip is an open-source cycle tracking app', title: 'drip is an open-source cycle tracking app',
text: `Copyright (C) 2019 Bloody Health GbR text: `Copyright (C) 2019 Bloody Health GbR
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details: https://www.gnu.org/licenses/gpl-3.0.html
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details: https://www.gnu.org/licenses/gpl-3.0.html
You can contact us by email at bloodyhealth@mailbox.com.` You can contact us by email at bloodyhealth@mailbox.com.`
}, },
......
import { AsyncStorage } from 'react-native' import { AsyncStorage } from 'react-native'
import Observable from 'obv' import Observable from 'obv'
import config from '../config' import config from './config'
export const scaleObservable = Observable() export const scaleObservable = Observable()
setObvWithInitValue('tempScale', scaleObservable, { setObvWithInitValue('tempScale', scaleObservable, {
...@@ -60,6 +60,15 @@ export async function saveEncryptionFlag(bool) { ...@@ -60,6 +60,15 @@ export async function saveEncryptionFlag(bool) {
hasEncryptionObservable.set(bool) hasEncryptionObservable.set(bool)
} }
export async function getLicenseFlag() {
return AsyncStorage.getItem('agreedToLicense')
}
export async function saveLicenseFlag() {
await AsyncStorage.setItem('agreedToLicense', JSON.stringify(true))
}
async function setObvWithInitValue(key, obv, defaultValue) { async function setObvWithInitValue(key, obv, defaultValue) {
const result = await AsyncStorage.getItem(key) const result = await AsyncStorage.getItem(key)
let value let value
......
...@@ -89,11 +89,13 @@ export default StyleSheet.create({ ...@@ -89,11 +89,13 @@ export default StyleSheet.create({
marginHorizontal: 50, marginHorizontal: 50,
marginTop: 20, marginTop: 20,
}, },
homeButton: { button: {
paddingVertical: 10, paddingVertical: 10,
paddingHorizontal: 20, paddingHorizontal: 20,
borderRadius: 5, borderRadius: 5,
alignItems: 'center', alignItems: 'center',
},
homeButton: {
width: 200, width: 200,
}, },
homeButtonText: { homeButtonText: {
...@@ -391,6 +393,19 @@ export default StyleSheet.create({ ...@@ -391,6 +393,19 @@ export default StyleSheet.create({
passwordPromptForgotPasswordText: { passwordPromptForgotPasswordText: {
marginTop: 20, marginTop: 20,
color: 'grey' color: 'grey'
},
licensePage: {
paddingVertical: 20,
paddingHorizontal: 10
},
licenseButtons: {
flexDirection: 'row',
justifyContent: 'flex-end',
marginTop: 40
},
licenseButton: {
marginLeft: 30,
width: 100
} }
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment