Merge branch '266-implement-consent-for-legal-stuff' into 'master'
Resolve "implement consent for legal stuff" Closes #266 See merge request bloodyhealth/drip!144
This commit is contained in:
+30
-14
@@ -3,26 +3,42 @@ import { View } from 'react-native'
|
||||
import nodejs from 'nodejs-mobile-react-native'
|
||||
import App from './app'
|
||||
import PasswordPrompt from './password-prompt'
|
||||
import License from './license'
|
||||
import { getLicenseFlag } from '../local-storage'
|
||||
|
||||
export default class AppWrapper extends Component {
|
||||
constructor() {
|
||||
super()
|
||||
this.state = {}
|
||||
this.state = {
|
||||
retrievingLicenseSetting: true
|
||||
}
|
||||
nodejs.start('main.js')
|
||||
this.checkLicenseAgreement()
|
||||
}
|
||||
|
||||
async checkLicenseAgreement() {
|
||||
const agreed = await getLicenseFlag()
|
||||
this.setState({retrievingLicenseSetting: false})
|
||||
if (!agreed) this.setState({showLicense: true})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
{this.state.showApp ?
|
||||
<App/>
|
||||
:
|
||||
<PasswordPrompt
|
||||
showApp={() => {
|
||||
this.setState({showApp: true})
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
const whiteScreen = <View style={{ flex: 1 }}></View>
|
||||
const licenseScreen = <License setLicense={() => {
|
||||
this.setState({showLicense: false})
|
||||
}}/>
|
||||
const passwordPrompt = <PasswordPrompt showApp={() => {
|
||||
this.setState({showApp: true})
|
||||
}}/>
|
||||
|
||||
if (this.state.retrievingLicenseSetting) {
|
||||
return whiteScreen
|
||||
} else if (this.state.showLicense) {
|
||||
return licenseScreen
|
||||
} else if (!this.state.showApp) {
|
||||
return passwordPrompt
|
||||
} else {
|
||||
return <App/>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
+13
-19
@@ -10,19 +10,7 @@ import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
||||
import styles from '../styles'
|
||||
import AppText, { AppTextLight } from './app-text'
|
||||
import DripHomeIcon from '../assets/drip-home-icons'
|
||||
|
||||
const HomeButton = ({ backgroundColor, children }) => {
|
||||
return (
|
||||
<View style={[
|
||||
styles.homeButton,
|
||||
{backgroundColor}
|
||||
]}>
|
||||
<AppText style={styles.homeButtonText}>
|
||||
{children}
|
||||
</AppText>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
import Button from './button'
|
||||
|
||||
export default class Home extends Component {
|
||||
constructor(props) {
|
||||
@@ -78,9 +66,11 @@ export default class Home extends Component {
|
||||
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
|
||||
}
|
||||
|
||||
<HomeButton backgroundColor={cycleDayColor}>
|
||||
<Button
|
||||
onPress={() => this.passTodayTo('CycleDay')}
|
||||
backgroundColor={cycleDayColor}>
|
||||
{labels.editToday}
|
||||
</HomeButton>
|
||||
</Button>
|
||||
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -103,9 +93,11 @@ export default class Home extends Component {
|
||||
</AppText>
|
||||
}
|
||||
|
||||
<HomeButton backgroundColor={periodColor}>
|
||||
<Button
|
||||
onPress={() => this.passTodayTo('BleedingEditView')}
|
||||
backgroundColor={periodColor}>
|
||||
{labels.trackPeriod}
|
||||
</HomeButton>
|
||||
</Button>
|
||||
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -136,9 +128,11 @@ export default class Home extends Component {
|
||||
</AppText>
|
||||
}
|
||||
|
||||
<HomeButton backgroundColor={secondaryColor}>
|
||||
<Button
|
||||
onPress={() => this.props.navigate('Chart')}
|
||||
backgroundColor={secondaryColor}>
|
||||
{labels.checkFertility}
|
||||
</HomeButton>
|
||||
</Button>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -116,4 +116,4 @@ export const fertilityStatus = {
|
||||
'double-check for yourself. Make sure the data makes sense to you.'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -122,10 +122,7 @@ export default {
|
||||
title: 'drip is an open-source cycle tracking app',
|
||||
text: `Copyright (C) 2019 Bloody Health GbR
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
You can contact us by email at bloodyhealth@mailbox.com.`
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AsyncStorage } from 'react-native'
|
||||
import Observable from 'obv'
|
||||
import config from '../config'
|
||||
import config from './config'
|
||||
|
||||
export const scaleObservable = Observable()
|
||||
setObvWithInitValue('tempScale', scaleObservable, {
|
||||
@@ -60,6 +60,15 @@ export async function saveEncryptionFlag(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) {
|
||||
const result = await AsyncStorage.getItem(key)
|
||||
let value
|
||||
+16
-1
@@ -89,11 +89,13 @@ export default StyleSheet.create({
|
||||
marginHorizontal: 50,
|
||||
marginTop: 20,
|
||||
},
|
||||
homeButton: {
|
||||
button: {
|
||||
paddingVertical: 10,
|
||||
paddingHorizontal: 20,
|
||||
borderRadius: 5,
|
||||
alignItems: 'center',
|
||||
},
|
||||
homeButton: {
|
||||
width: 200,
|
||||
},
|
||||
homeButtonText: {
|
||||
@@ -391,6 +393,19 @@ export default StyleSheet.create({
|
||||
passwordPromptForgotPasswordText: {
|
||||
marginTop: 20,
|
||||
color: 'grey'
|
||||
},
|
||||
licensePage: {
|
||||
paddingVertical: 20,
|
||||
paddingHorizontal: 10
|
||||
},
|
||||
licenseButtons: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-end',
|
||||
marginTop: 40
|
||||
},
|
||||
licenseButton: {
|
||||
marginLeft: 30,
|
||||
width: 100
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user