diff --git a/components/app-wrapper.js b/components/app-wrapper.js index cd50bb7..4e8665b 100644 --- a/components/app-wrapper.js +++ b/components/app-wrapper.js @@ -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 ( - - {this.state.showApp ? - - : - { - this.setState({showApp: true}) - }} - /> - } - - ) + const whiteScreen = + const licenseScreen = { + this.setState({showLicense: false}) + }}/> + const passwordPrompt = { + 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 + } } } \ No newline at end of file diff --git a/components/button.js b/components/button.js new file mode 100644 index 0000000..70d778e --- /dev/null +++ b/components/button.js @@ -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 ( + + + {props.children} + + + ) +} \ No newline at end of file diff --git a/components/home.js b/components/home.js index e57633d..37e04c2 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,11 @@ export default class Home extends Component { {cycleDayMoreText} } - + @@ -103,9 +93,11 @@ export default class Home extends Component { } - + @@ -136,9 +128,11 @@ export default class Home extends Component { } - + diff --git a/components/license.js b/components/license.js new file mode 100644 index 0000000..8fdfc9e --- /dev/null +++ b/components/license.js @@ -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 ( + + + {labels.title} + {labels.text} + + + + + + + ) +} \ No newline at end of file diff --git a/i18n/en/labels.js b/i18n/en/labels.js index 1917917..0f569aa 100644 --- a/i18n/en/labels.js +++ b/i18n/en/labels.js @@ -116,4 +116,4 @@ export const fertilityStatus = { 'double-check for yourself. Make sure the data makes sense to you.' ) } -} +} \ No newline at end of file diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 52bc075..19c13f0 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -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.` }, 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..5e73a93 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,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 } })