Distinction between License and AcceptLicense screens
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import { BackHandler, StyleSheet, View } from 'react-native'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
import License from './settings/License'
|
||||||
|
import Button from './common/button'
|
||||||
|
|
||||||
|
import { saveLicenseFlag } from '../local-storage'
|
||||||
|
|
||||||
|
import { Containers } from '../styles'
|
||||||
|
|
||||||
|
export default function AcceptLicense({ setLicense }) {
|
||||||
|
const onAcceptLicense = async () => {
|
||||||
|
await saveLicenseFlag()
|
||||||
|
setLicense()
|
||||||
|
}
|
||||||
|
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<License>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Button onPress={BackHandler.exitApp} testID="licenseCancelButton">
|
||||||
|
{t('labels.shared.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button isCTA onPress={onAcceptLicense} testID="licenseOkButton">
|
||||||
|
{t('labels.shared.ok')}
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</License>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
AcceptLicense.propTypes = {
|
||||||
|
setLicense: PropTypes.func.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
...Containers.rowContainer,
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
import { BackHandler, StyleSheet, View } from 'react-native'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
|
|
||||||
import AppPage from './common/app-page'
|
|
||||||
import AppText from './common/app-text'
|
|
||||||
import Button from './common/button'
|
|
||||||
import Segment from './common/segment'
|
|
||||||
|
|
||||||
import { saveLicenseFlag } from '../local-storage'
|
|
||||||
|
|
||||||
import { Containers } from '../styles'
|
|
||||||
|
|
||||||
export default function License({ setLicense }) {
|
|
||||||
const onAcceptLicense = async () => {
|
|
||||||
await saveLicenseFlag()
|
|
||||||
setLicense()
|
|
||||||
}
|
|
||||||
|
|
||||||
const { t } = useTranslation()
|
|
||||||
const currentYear = new Date().getFullYear()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AppPage testID="licensePage">
|
|
||||||
<Segment last testID="test" title={t('settings.license.title')}>
|
|
||||||
<AppText testID="test">
|
|
||||||
{t('settings.license.text', { currentYear })}
|
|
||||||
</AppText>
|
|
||||||
<View style={styles.container}>
|
|
||||||
<Button onPress={BackHandler.exitApp} testID="licenseCancelButton">
|
|
||||||
{t('labels.shared.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button isCTA onPress={onAcceptLicense} testID="licenseOkButton">
|
|
||||||
{t('labels.shared.ok')}
|
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
</Segment>
|
|
||||||
</AppPage>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
License.propTypes = {
|
|
||||||
setLicense: PropTypes.func.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
container: {
|
|
||||||
...Containers.rowContainer,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -7,7 +7,7 @@ import { openDb } from '../db'
|
|||||||
import App from './app'
|
import App from './app'
|
||||||
import AppLoadingView from './common/app-loading'
|
import AppLoadingView from './common/app-loading'
|
||||||
import AppStatusBar from './common/app-status-bar'
|
import AppStatusBar from './common/app-status-bar'
|
||||||
import License from './License'
|
import AcceptLicense from './AcceptLicense'
|
||||||
import PasswordPrompt from './password-prompt'
|
import PasswordPrompt from './password-prompt'
|
||||||
|
|
||||||
export default function AppWrapper() {
|
export default function AppWrapper() {
|
||||||
@@ -38,7 +38,7 @@ export default function AppWrapper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isLicenseAccepted) {
|
if (!isLicenseAccepted) {
|
||||||
return <License setLicense={() => setIsLicenseAccepted(true)} />
|
return <AcceptLicense setLicense={() => setIsLicenseAccepted(true)} />
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import NfpSettings from './nfp-settings'
|
|||||||
import DataManagement from './data-management'
|
import DataManagement from './data-management'
|
||||||
import Password from './password'
|
import Password from './password'
|
||||||
import About from './about'
|
import About from './about'
|
||||||
import License from './license'
|
import License from './License'
|
||||||
import PrivacyPolicy from './privacy-policy'
|
import PrivacyPolicy from './privacy-policy'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
import AppPage from '../common/app-page'
|
import AppPage from '../common/app-page'
|
||||||
import AppText from '../common/app-text'
|
import AppText from '../common/app-text'
|
||||||
import Segment from '../common/segment'
|
import Segment from '../common/segment'
|
||||||
|
|
||||||
const License = () => {
|
const License = ({ children }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const currentYear = new Date().getFullYear()
|
const currentYear = new Date().getFullYear()
|
||||||
|
|
||||||
@@ -13,9 +14,14 @@ const License = () => {
|
|||||||
<AppPage title={t('settings.license.title')}>
|
<AppPage title={t('settings.license.title')}>
|
||||||
<Segment last>
|
<Segment last>
|
||||||
<AppText>{t('settings.license.text', { currentYear })}</AppText>
|
<AppText>{t('settings.license.text', { currentYear })}</AppText>
|
||||||
|
{children}
|
||||||
</Segment>
|
</Segment>
|
||||||
</AppPage>
|
</AppPage>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
License.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
}
|
||||||
|
|
||||||
export default License
|
export default License
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { render, screen } from '@testing-library/react-native'
|
|
||||||
import License from '../components/License'
|
|
||||||
|
|
||||||
jest.mock('../local-storage', () => ({ saveLicenseFlag: jest.fn() }))
|
|
||||||
|
|
||||||
jest.mock('react-i18next', () => ({
|
|
||||||
useTranslation: () => ({
|
|
||||||
t: (str, options) => {
|
|
||||||
return str + (options ? JSON.stringify(options) : '')
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}))
|
|
||||||
|
|
||||||
describe('License screen', () => {
|
|
||||||
test('It should have a correct year', async () => {
|
|
||||||
render(<License setLicense={() => {}} />)
|
|
||||||
const year = new Date().getFullYear().toString()
|
|
||||||
screen.getByText(year, { exact: false })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user