Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checkbox from for pw protection for Backup screen #680

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 4 additions & 37 deletions app/components/BackupItemModal/BackupItemModal.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import React, { useState } from 'react';
import { View, Text } from 'react-native';
import { CheckBox } from 'react-native-elements';
import { ConfirmModal, LoadingIndicatorDots, PasswordForm } from '..';

import { TouchableOpacity } from 'react-native';
import React from 'react';
import { Text } from 'react-native';
import { ConfirmModal, LoadingIndicatorDots } from '..';
import { useAsyncCallback } from 'react-async-hook';

import dynamicStyleSheet from './BackupItemModal.styles';
import { BackupItemModalProps } from './BackupItemModal.d';
import { useDynamicStyles } from '../../hooks';


export default function BackupItemModal({ onRequestClose, open, onBackup, backupItemName, backupModalText }: BackupItemModalProps): React.ReactElement {
const { styles, mixins, theme } = useDynamicStyles(dynamicStyleSheet);
const [enablePassword, setEnablePassword] = useState(false);
const [password, setPassword] = useState<string>();

const { mixins } = useDynamicStyles(dynamicStyleSheet);
const createBackup = useAsyncCallback(
() => onBackup(),
{ onSuccess: onRequestClose, onError: onRequestClose }
);

const readyToBackup = !(enablePassword && !password);

if (createBackup.loading) {
return <ConfirmModal
title={`Backing Up Your ${backupItemName}`}
@@ -46,34 +37,10 @@ export default function BackupItemModal({ onRequestClose, open, onBackup, backup
title={`Backup ${backupItemName}`}
cancelText="Cancel"
confirmText="Create Backup"
confirmButtonDisabled={!readyToBackup}
>
<Text style={mixins.modalBodyText}>
{backupModalText}
</Text>
<TouchableOpacity onPress={() => setEnablePassword(!enablePassword)}>
<View style={styles.checkboxButtonContainer}>
<CheckBox
checked={enablePassword}
onPress={ () => setEnablePassword(!enablePassword)}
checkedColor={theme.color.buttonPrimary}
containerStyle={[
mixins.checkboxContainer,
styles.checkboxContainer,
]}
/>
<Text style={styles.checkboxText}>Add password protection</Text>
</View>
</TouchableOpacity>
{enablePassword ? (
<PasswordForm
onChangePassword={setPassword}
style={styles.passwordForm}
textInputBackgroundColor={theme.color.foregroundPrimary}
/>
) : (
<Text style={styles.noteText}>Note: Not password protecting your backup will leave your backup vulnerable.</Text>
)}
</ConfirmModal>
);
}