Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb33d93f8e | |||
| b4f711e4db | |||
| 1d5737d8a9 | |||
| edc6f350c5 | |||
| d30b7db3fb |
@@ -10,26 +10,34 @@ import Header from './header'
|
|||||||
|
|
||||||
import { saveEncryptionFlag } from '../local-storage'
|
import { saveEncryptionFlag } from '../local-storage'
|
||||||
import { deleteDbAndOpenNew, openDb } from '../db'
|
import { deleteDbAndOpenNew, openDb } from '../db'
|
||||||
import { passwordPrompt as labels, shared } from '../i18n/en/labels'
|
|
||||||
import { Containers, Spacing } from '../styles'
|
import { Containers, Spacing } from '../styles'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
const cancelButton = { text: shared.cancel, style: 'cancel' }
|
|
||||||
|
|
||||||
const PasswordPrompt = ({ enableShowApp }) => {
|
const PasswordPrompt = ({ enableShowApp }) => {
|
||||||
const [password, setPassword] = useState(null)
|
const [password, setPassword] = useState(null)
|
||||||
const isPasswordEntered = Boolean(password)
|
|
||||||
|
const { t } = useTranslation(null, { keyPrefix: 'password' })
|
||||||
|
|
||||||
|
const cancelButton = {
|
||||||
|
text: t('forgotPasswordDialog.cancel'),
|
||||||
|
style: 'cancel',
|
||||||
|
}
|
||||||
|
|
||||||
const unlockApp = async () => {
|
const unlockApp = async () => {
|
||||||
const hash = new SHA512().hex(password)
|
const hash = new SHA512().hex(password)
|
||||||
const connected = await openDb(hash)
|
const connected = await openDb(hash)
|
||||||
|
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
Alert.alert(shared.incorrectPassword, shared.incorrectPasswordMessage, [
|
Alert.alert(
|
||||||
|
t('incorrectPasswordDialog.incorrectPassword'),
|
||||||
|
t('incorrectPasswordDialog.incorrectPasswordMessage'),
|
||||||
|
[
|
||||||
{
|
{
|
||||||
text: shared.tryAgain,
|
text: t('incorrectPasswordDialog.tryAgain'),
|
||||||
onPress: () => setPassword(null),
|
onPress: () => setPassword(null),
|
||||||
},
|
},
|
||||||
])
|
]
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
enableShowApp()
|
enableShowApp()
|
||||||
@@ -42,19 +50,22 @@ const PasswordPrompt = ({ enableShowApp }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onDeleteData = () => {
|
const onDeleteData = () => {
|
||||||
Alert.alert(labels.areYouSureTitle, labels.areYouSure, [
|
Alert.alert(t('confirmationDialog.title'), t('confirmationDialog.text'), [
|
||||||
cancelButton,
|
cancelButton,
|
||||||
{
|
{
|
||||||
text: labels.reallyDeleteData,
|
text: t('confirmationDialog.confirm'),
|
||||||
onPress: onDeleteDataConfirmation,
|
onPress: onDeleteDataConfirmation,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
const onConfirmDeletion = async () => {
|
const onConfirmDeletion = async () => {
|
||||||
Alert.alert(labels.deleteDatabaseTitle, labels.deleteDatabaseExplainer, [
|
Alert.alert(t('forgotPassword'), t('forgotPasswordDialog.text'), [
|
||||||
cancelButton,
|
cancelButton,
|
||||||
{ text: labels.deleteData, onPress: onDeleteData },
|
{
|
||||||
|
text: t('forgotPasswordDialog.confirm'),
|
||||||
|
onPress: onDeleteData,
|
||||||
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,17 +76,13 @@ const PasswordPrompt = ({ enableShowApp }) => {
|
|||||||
<KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={150}>
|
<KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={150}>
|
||||||
<AppTextInput
|
<AppTextInput
|
||||||
onChangeText={setPassword}
|
onChangeText={setPassword}
|
||||||
secureTextEntry={true}
|
secureTextEntry
|
||||||
placeholder={labels.enterPassword}
|
placeholder={t('enterPassword')}
|
||||||
/>
|
/>
|
||||||
<View style={styles.containerButtons}>
|
<View style={styles.containerButtons}>
|
||||||
<Button onPress={onConfirmDeletion}>{labels.forgotPassword}</Button>
|
<Button onPress={onConfirmDeletion}>{t('forgotPassword')}</Button>
|
||||||
<Button
|
<Button disabled={!password} isCTA={!!password} onPress={unlockApp}>
|
||||||
disabled={!isPasswordEntered}
|
{t('unlockApp')}
|
||||||
isCTA={isPasswordEntered}
|
|
||||||
onPress={unlockApp}
|
|
||||||
>
|
|
||||||
{labels.title}
|
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
@@ -7,7 +7,7 @@ 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 AcceptLicense from './AcceptLicense'
|
import AcceptLicense from './AcceptLicense'
|
||||||
import PasswordPrompt from './password-prompt'
|
import PasswordPrompt from './PasswordPrompt'
|
||||||
|
|
||||||
export default function AppWrapper() {
|
export default function AppWrapper() {
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@@ -132,6 +132,26 @@
|
|||||||
"title": "Settings"
|
"title": "Settings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"password": {
|
||||||
|
"confirmationDialog": {
|
||||||
|
"confirm": "Yes, I am sure",
|
||||||
|
"text": "Are you absolutely sure you want to permanently delete all your data?",
|
||||||
|
"title": "Are you sure?"
|
||||||
|
},
|
||||||
|
"enterPassword": "Enter password here",
|
||||||
|
"forgotPassword": "Forgot your password?",
|
||||||
|
"forgotPasswordDialog": {
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"confirm": "Yes, delete all my data",
|
||||||
|
"text": "If you've forgotten your password, unfortunately, there is nothing we can do to recover your data, because it is encrypted with the password only you know. You can, however, delete all your encrypted data and start fresh. Once all data has been erased, you can set a new password in the settings, if you like."
|
||||||
|
},
|
||||||
|
"incorrectPasswordDialog": {
|
||||||
|
"incorrectPassword": "Password incorrect",
|
||||||
|
"incorrectPasswordMessage": "That password is incorrect.",
|
||||||
|
"tryAgain": "Try again"
|
||||||
|
},
|
||||||
|
"unlockApp": "Unlock app"
|
||||||
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"noData": "At least one completed cycle is needed to display stats.",
|
"noData": "At least one completed cycle is needed to display stats.",
|
||||||
"intro": "Basic statistics about the length of your cycles.",
|
"intro": "Basic statistics about the length of your cycles.",
|
||||||
|
|||||||
@@ -26,17 +26,6 @@ export const shared = {
|
|||||||
learnMore: 'Learn more',
|
learnMore: 'Learn more',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const stats = {
|
|
||||||
cycleLengthExplainer: 'Basic statistics about the length of your cycles.',
|
|
||||||
emptyStats: 'At least one completed cycle is needed to display stats.',
|
|
||||||
daysLabel: 'days',
|
|
||||||
basisOfStatsEnd: 'completed\ncycles',
|
|
||||||
averageLabel: 'Average cycle',
|
|
||||||
minLabel: `Shortest`,
|
|
||||||
maxLabel: `Longest`,
|
|
||||||
stdLabel: `Standard\ndeviation`,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const bleedingPrediction = {
|
export const bleedingPrediction = {
|
||||||
predictionInFuture: (startDays, endDays) =>
|
predictionInFuture: (startDays, endDays) =>
|
||||||
`Your next period is likely to start in ${startDays} to ${endDays} days.`,
|
`Your next period is likely to start in ${startDays} to ${endDays} days.`,
|
||||||
@@ -49,20 +38,6 @@ export const bleedingPrediction = {
|
|||||||
`Based on your documented data, your period was likely to start between ${startDate} and ${endDate}.`,
|
`Based on your documented data, your period was likely to start between ${startDate} and ${endDate}.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const passwordPrompt = {
|
|
||||||
title: 'Unlock app',
|
|
||||||
enterPassword: 'Enter password here',
|
|
||||||
deleteDatabaseExplainer:
|
|
||||||
"If you've forgotten your password, unfortunately, there is nothing we can do to recover your data, because it is encrypted with the password only you know. You can, however, delete all your encrypted data and start fresh. Once all data has been erased, you can set a new password in the settings, if you like.",
|
|
||||||
forgotPassword: 'Forgot your password?',
|
|
||||||
deleteDatabaseTitle: 'Forgot your password?',
|
|
||||||
deleteData: 'Yes, delete all my data',
|
|
||||||
areYouSureTitle: 'Are you sure?',
|
|
||||||
areYouSure:
|
|
||||||
'Are you absolutely sure you want to permanently delete all your data?',
|
|
||||||
reallyDeleteData: 'Yes, I am sure',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const fertilityStatus = {
|
export const fertilityStatus = {
|
||||||
fertile: 'fertile',
|
fertile: 'fertile',
|
||||||
infertile: 'infertile',
|
infertile: 'infertile',
|
||||||
|
|||||||
Reference in New Issue
Block a user