Add license page
This commit is contained in:
@@ -3,15 +3,30 @@ 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 = {}
|
||||
nodejs.start('main.js')
|
||||
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 (
|
||||
this.state.showLicense ?
|
||||
<License/>
|
||||
:
|
||||
<View style={{ flex: 1 }}>
|
||||
{this.state.showApp ?
|
||||
<App/>
|
||||
|
||||
@@ -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
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -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.'
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user