Add license page

This commit is contained in:
Julia Friesel
2018-12-21 17:14:27 +01:00
parent c713ed5490
commit 000e1b63c7
7 changed files with 101 additions and 33 deletions
+27 -12
View File
@@ -3,26 +3,41 @@ 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 = {
showLicense: true
}
nodejs.start('main.js')
this.checkLicenseAgreement()
}
async checkLicenseAgreement() {
const agreed = await getLicenseFlag()
console.log(agreed)
if (agreed) this.setState({showLicense: false})
}
render() {
return (
<View style={{ flex: 1 }}>
{this.state.showApp ?
<App/>
:
<PasswordPrompt
showApp={() => {
this.setState({showApp: true})
}}
/>
}
</View>
this.state.showLicense ?
<License/>
:
<View style={{ flex: 1 }}>
{this.state.showApp ?
<App/>
:
<PasswordPrompt
showApp={() => {
this.setState({showApp: true})
}}
/>
}
</View>
)
}
}
+18
View File
@@ -0,0 +1,18 @@
import React from 'react'
import { View } from 'react-native'
import AppText from './app-text'
import styles from '../styles'
export default function Button({ backgroundColor, style, children }) {
return (
<View style={[
styles.button,
style,
{backgroundColor}
]}>
<AppText style={styles.homeButtonText}>
{children}
</AppText>
</View>
)
}
+7 -19
View File
@@ -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,9 @@ export default class Home extends Component {
<AppText style={styles.paragraph}>{cycleDayMoreText}</AppText>
}
<HomeButton backgroundColor={cycleDayColor}>
<Button backgroundColor={cycleDayColor}>
{labels.editToday}
</HomeButton>
</Button>
</TouchableOpacity>
@@ -103,9 +91,9 @@ export default class Home extends Component {
</AppText>
}
<HomeButton backgroundColor={periodColor}>
<Button backgroundColor={periodColor}>
{labels.trackPeriod}
</HomeButton>
</Button>
</TouchableOpacity>
@@ -136,9 +124,9 @@ export default class Home extends Component {
</AppText>
}
<HomeButton backgroundColor={secondaryColor}>
<Button backgroundColor={secondaryColor}>
{labels.checkFertility}
</HomeButton>
</Button>
</TouchableOpacity>
</View>
+22
View File
@@ -0,0 +1,22 @@
import React from 'react'
import { ScrollView, View } from 'react-native'
import AppText from './app-text'
import { licenseText, shared } from '../i18n/en/labels'
import styles,{secondaryColor} from '../styles'
import Button from './button'
export default function License() {
return (
<ScrollView style={styles.licensePage}>
<AppText>{licenseText}</AppText>
<View style={styles.licenseButtons}>
<Button style={styles.licenseButton} backgroundColor={'grey'}>
{shared.cancel}
</Button>
<Button style={styles.licenseButton} backgroundColor={secondaryColor}>
{shared.ok}
</Button>
</View>
</ScrollView>
)
}
+2
View File
@@ -117,3 +117,5 @@ export const fertilityStatus = {
)
}
}
export const licenseText = 'This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall copyright holders be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.'
+10 -1
View File
@@ -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
+15 -1
View File
@@ -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,18 @@ export default StyleSheet.create({
passwordPromptForgotPasswordText: {
marginTop: 20,
color: 'grey'
},
licensePage: {
paddingVertical: 20,
paddingHorizontal: 20
},
licenseButtons: {
flexDirection: 'row',
justifyContent: 'flex-end'
},
licenseButton: {
marginLeft: 30,
width: 100
}
})