diff --git a/components/labels.js b/components/labels.js index 1c90f8831afc2f90ce9e67b5e29bf58f1499077c..d4b5876d0a594854fef63e3b4e7b922471022568 100644 --- a/components/labels.js +++ b/components/labels.js @@ -107,5 +107,12 @@ export const bleedingPrediction = { export const passwordPrompt = { title: 'Unlock app', - enterPassword: 'Enter password here' + 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' } \ No newline at end of file diff --git a/components/password-prompt.js b/components/password-prompt.js index 735168932cf6b6b47a32af473a221d3591dcf5c6..3c972eb686a3cc7d38a82db11271a94c674d5ef9 100644 --- a/components/password-prompt.js +++ b/components/password-prompt.js @@ -4,7 +4,7 @@ import nodejs from 'nodejs-mobile-react-native' import { AppText } from './app-text' import { hasEncryptionObservable } from '../local-storage' import styles from '../styles' -import { passwordPrompt, shared } from './labels' +import { passwordPrompt as labels, shared } from './labels' import { requestHash, deleteDbAndOpenNew, openDb } from '../db' export default class PasswordPrompt extends Component { @@ -66,7 +66,7 @@ export default class PasswordPrompt extends Component { onChangeText={val => this.setState({ password: val })} style={styles.passwordPromptField} secureTextEntry={true} - placeholder={passwordPrompt.enterPassword} + placeholder={labels.enterPassword} /> <TouchableOpacity style={styles.passwordPromptButton} @@ -75,18 +75,41 @@ export default class PasswordPrompt extends Component { }} > <AppText style={styles.passwordPromptButtonText}> - {passwordPrompt.title} + {labels.title} </AppText> </TouchableOpacity> <TouchableOpacity - style={styles.passwordPromptButton} onPress={async () => { - await deleteDbAndOpenNew() - this.setState({ showApp: true }) + Alert.alert( + labels.deleteDatabaseTitle, + labels.deleteDatabaseExplainer, + [{ + text: shared.cancel, + style: 'cancel' + }, { + text: labels.deleteData, + onPress: () => { + Alert.alert( + labels.areYouSureTitle, + labels.areYouSure, + [{ + text: shared.cancel, + style: 'cancel' + }, { + text: labels.reallyDeleteData, + onPress: async () => { + await deleteDbAndOpenNew() + this.props.showApp() + } + }] + ) + } + }] + ) }} > - <AppText style={styles.passwordPromptButtonText}> - {'Delete old db and make unencrypted new'} + <AppText style={styles.passwordPromptForgotPasswordText}> + {labels.forgotPassword} </AppText> </TouchableOpacity> </View> diff --git a/styles/index.js b/styles/index.js index 82c6e71b5d1eee6bd517ed9d8a0e2d00f4ace709..ee63b83cb349ba7716827c8c74183b85b8fdc1d7 100644 --- a/styles/index.js +++ b/styles/index.js @@ -282,6 +282,10 @@ export default StyleSheet.create({ color: fontOnPrimaryColor, fontSize: 20 }, + passwordPromptForgotPasswordText: { + marginTop: 20, + color: 'grey' + } }) export const iconStyles = {