diff --git a/components/app-wrapper.js b/components/app-wrapper.js index cd50bb7..90a904e 100644 --- a/components/app-wrapper.js +++ b/components/app-wrapper.js @@ -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 ( - - {this.state.showApp ? - - : - { - this.setState({showApp: true}) - }} - /> - } - + this.state.showLicense ? + + : + + {this.state.showApp ? + + : + { + this.setState({showApp: true}) + }} + /> + } + ) } } \ No newline at end of file diff --git a/components/button.js b/components/button.js new file mode 100644 index 0000000..696c918 --- /dev/null +++ b/components/button.js @@ -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 ( + + + {children} + + + ) +} \ No newline at end of file diff --git a/components/home.js b/components/home.js index e57633d..ffba42f 100644 --- a/components/home.js +++ b/components/home.js @@ -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 ( - - - {children} - - - ) -} +import Button from './button' export default class Home extends Component { constructor(props) { @@ -78,9 +66,9 @@ export default class Home extends Component { {cycleDayMoreText} } - + @@ -103,9 +91,9 @@ export default class Home extends Component { } - + @@ -136,9 +124,9 @@ export default class Home extends Component { } - + diff --git a/components/license.js b/components/license.js new file mode 100644 index 0000000..4e5027d --- /dev/null +++ b/components/license.js @@ -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 ( + + {licenseText} + + + + + + ) +} \ No newline at end of file diff --git a/i18n/en/labels.js b/i18n/en/labels.js index 1917917..b3842ed 100644 --- a/i18n/en/labels.js +++ b/i18n/en/labels.js @@ -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.' \ No newline at end of file diff --git a/local-storage/index.js b/local-storage.js similarity index 89% rename from local-storage/index.js rename to local-storage.js index 89b37d9..4cc9c75 100644 --- a/local-storage/index.js +++ b/local-storage.js @@ -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 diff --git a/styles/index.js b/styles/index.js index 1c6cf62..18f07d8 100644 --- a/styles/index.js +++ b/styles/index.js @@ -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 } })