diff --git a/components/settings/password/create.js b/components/settings/password/create.js index aaa021dcb905756c15a5be1f6a85c1064661fea2..9178312c81a0f32ea81a44952be8b57a18f46051 100644 --- a/components/settings/password/create.js +++ b/components/settings/password/create.js @@ -19,7 +19,7 @@ export default class CreatePassword extends Component { } startSettingPassword = () => { - showBackUpReminder(this.toggleSettingPassword) + showBackUpReminder(this.toggleSettingPassword, () => {}) } render () { diff --git a/components/settings/password/delete.js b/components/settings/password/delete.js index b6435a09d38448cdd552d8c10ad8d723c8465213..d034a73d878e49a213c6efebf4d8dfdaa0cdf210 100644 --- a/components/settings/password/delete.js +++ b/components/settings/password/delete.js @@ -1,4 +1,6 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' + import labels from '../../../i18n/en/settings' import { changeEncryptionAndRestartApp } from '../../../db' import ConfirmWithPassword from '../shared/confirm-with-password' @@ -14,7 +16,7 @@ export default class DeletePassword extends Component { startConfirmWithPassword = () => { this.setState({ enteringCurrentPassword: true }) - this.props.onStartDeletingPassword() + this.props.onStartDelete() } startDeletePassword = async () => { @@ -23,6 +25,7 @@ export default class DeletePassword extends Component { cancelConfirmationWithPassword = () => { this.setState({ enteringCurrentPassword: false }) + this.props.onCancelDelete() } render() { @@ -44,4 +47,9 @@ export default class DeletePassword extends Component { </SettingsButton> ) } +} + +DeletePassword.propTypes = { + onStartDelete: PropTypes.func, + onCancelDelete: PropTypes.func } \ No newline at end of file diff --git a/components/settings/password/index.js b/components/settings/password/index.js index d4d02428147290a98fff98bec7f79c0473d9676d..08406a440cf38ea7dadd88ddbf32e0f6087bb1eb 100644 --- a/components/settings/password/index.js +++ b/components/settings/password/index.js @@ -24,10 +24,18 @@ export default class PasswordSetting extends Component { this.setState({ isChangingPassword: true }) } + onCancelChangingPassword = () => { + this.setState({ isChangingPassword: false }) + } + onDeletingPassword = () => { this.setState({ isDeletingPassword: true }) } + onCancelDeletingPassword = () => { + this.setState({ isDeletingPassword: false }) + } + render() { const { @@ -53,13 +61,15 @@ export default class PasswordSetting extends Component { { (isPasswordSet && !isDeletingPassword) && ( <ChangePassword - onStartChangingPassword = {this.onChangingPassword} + onStartChange = {this.onChangingPassword} + onCancelChange = {this.onCancelChangingPassword} /> )} { (isPasswordSet && !isChangingPassword) && ( <DeletePassword - onStartDeletingPassword = {this.onDeletingPassword} + onStartDelete = {this.onDeletingPassword} + onCancelDelete = {this.onCancelDeletingPassword} /> )} </FramedSegment> diff --git a/components/settings/password/show-backup-reminder.js b/components/settings/password/show-backup-reminder.js index f61e5a479b5c1efcc11ae1cf17f11c2f8a715e96..bf956462379ce9752d3037bf2d93bb5d44dff450 100644 --- a/components/settings/password/show-backup-reminder.js +++ b/components/settings/password/show-backup-reminder.js @@ -2,7 +2,7 @@ import { Alert } from 'react-native' import { shared } from '../../../i18n/en/labels' import labels from '../../../i18n/en/settings' -export default function showBackUpReminder(okHandler, isDelete) { +export default function showBackUpReminder(okHandler, cancelHandler, isDelete) { let title, message if (isDelete) { title = labels.passwordSettings.deleteBackupReminderTitle @@ -17,10 +17,12 @@ export default function showBackUpReminder(okHandler, isDelete) { message, [{ text: shared.cancel, + onPress: cancelHandler, style: 'cancel' }, { text: shared.ok, onPress: okHandler - }] + }], + { onDismiss: cancelHandler } ) } \ No newline at end of file diff --git a/components/settings/password/update.js b/components/settings/password/update.js index e09433ae7525cd5084bdc94b63809f2ba5513327..447b9de0a208b12b1fc757c49e60a6a723ff03ad 100644 --- a/components/settings/password/update.js +++ b/components/settings/password/update.js @@ -1,4 +1,6 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' + import settings from '../../../i18n/en/settings' import EnterNewPassword from './enter-new-password' import SettingsButton from '../shared/settings-button' @@ -17,10 +19,15 @@ export default class ChangePassword extends Component { } startChangingPassword = () => { - showBackUpReminder(() => { - this.setState({ enteringCurrentPassword: true }) - }) - this.props.onStartChangingPassword() + showBackUpReminder( + this.startEnteringCurrentPassword, + this.cancelConfirmationWithPassword + ) + } + + startEnteringCurrentPassword = () => { + this.setState({ enteringCurrentPassword: true }) + this.props.onStartChange() } startEnteringNewPassword = () => { @@ -37,6 +44,7 @@ export default class ChangePassword extends Component { enteringNewPassword: false, enteringCurrentPassword: false }) + this.props.onCancelChange() } render() { @@ -71,4 +79,9 @@ export default class ChangePassword extends Component { </SettingsButton> ) } +} + +ChangePassword.propTypes = { + onStartChange: PropTypes.func, + onCancelChange: PropTypes.func } \ No newline at end of file diff --git a/components/settings/shared/confirm-with-password.js b/components/settings/shared/confirm-with-password.js index 0f34422a40c047a26cb19df06d1d44099ac07c5e..02d56002f5db18d17615f9ea1c55f607117fbb8d 100644 --- a/components/settings/shared/confirm-with-password.js +++ b/components/settings/shared/confirm-with-password.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' import { View, Alert } from 'react-native' import nodejs from 'nodejs-mobile-react-native' @@ -99,4 +100,9 @@ export default class ConfirmWithPassword extends Component { ) } +} + +ConfirmWithPassword.propTypes = { + onSuccess: PropTypes.func, + onCancel: PropTypes.func } \ No newline at end of file