2022-08-11 14:59:40 +00:00
|
|
|
import { useNavigation } from '@react-navigation/native';
|
|
|
|
import React, { useLayoutEffect, useState } from 'react';
|
|
|
|
import { ScrollView, StyleSheet, Text } from 'react-native';
|
|
|
|
import { useDispatch } from 'react-redux';
|
2020-09-11 14:31:38 +00:00
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
import { encryptionDecodeKey } from '../actions/encryption';
|
|
|
|
import Button from '../containers/Button';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../containers/HeaderButton';
|
2022-08-11 14:59:40 +00:00
|
|
|
import KeyboardView from '../containers/KeyboardView';
|
2022-01-13 18:37:14 +00:00
|
|
|
import SafeAreaView from '../containers/SafeAreaView';
|
2020-09-11 14:31:38 +00:00
|
|
|
import StatusBar from '../containers/StatusBar';
|
2022-06-27 18:46:59 +00:00
|
|
|
import { FormTextInput } from '../containers/TextInput';
|
2022-01-13 18:37:14 +00:00
|
|
|
import I18n from '../i18n';
|
2022-06-06 14:17:51 +00:00
|
|
|
import { events, logEvent } from '../lib/methods/helpers/log';
|
|
|
|
import scrollPersistTaps from '../lib/methods/helpers/scrollPersistTaps';
|
2022-08-11 14:59:40 +00:00
|
|
|
import { useTheme } from '../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
import sharedStyles from './Styles';
|
2020-09-11 14:31:38 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
info: {
|
2022-11-21 19:10:38 +00:00
|
|
|
fontSize: 16,
|
|
|
|
marginVertical: 4,
|
2020-09-11 14:31:38 +00:00
|
|
|
...sharedStyles.textRegular
|
|
|
|
}
|
|
|
|
});
|
2021-11-17 20:03:53 +00:00
|
|
|
|
2022-08-11 14:59:40 +00:00
|
|
|
const E2EEnterYourPasswordView = (): React.ReactElement => {
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const navigation = useNavigation();
|
|
|
|
const dispatch = useDispatch();
|
2021-11-17 20:03:53 +00:00
|
|
|
|
2022-08-11 14:59:40 +00:00
|
|
|
useLayoutEffect(() => {
|
|
|
|
navigation.setOptions({
|
|
|
|
headerLeft: () => <HeaderButton.CloseModal testID='e2e-enter-your-password-view-close' />,
|
|
|
|
title: I18n.t('Enter_Your_E2E_Password')
|
|
|
|
});
|
|
|
|
}, [navigation]);
|
2020-09-11 14:31:38 +00:00
|
|
|
|
2022-08-11 14:59:40 +00:00
|
|
|
const submit = () => {
|
2020-09-11 14:31:38 +00:00
|
|
|
logEvent(events.E2E_ENTER_PW_SUBMIT);
|
2022-01-13 18:37:14 +00:00
|
|
|
dispatch(encryptionDecodeKey(password));
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-09-11 14:31:38 +00:00
|
|
|
|
2022-08-11 14:59:40 +00:00
|
|
|
return (
|
|
|
|
<KeyboardView
|
|
|
|
style={{ backgroundColor: colors.backgroundColor }}
|
|
|
|
contentContainerStyle={sharedStyles.container}
|
|
|
|
keyboardVerticalOffset={128}
|
|
|
|
>
|
|
|
|
<StatusBar />
|
|
|
|
<ScrollView {...scrollPersistTaps} style={sharedStyles.container} contentContainerStyle={sharedStyles.containerScrollView}>
|
2022-11-21 19:10:38 +00:00
|
|
|
<SafeAreaView style={{ backgroundColor: colors.backgroundColor }} testID='e2e-enter-your-password-view'>
|
2022-08-11 14:59:40 +00:00
|
|
|
<FormTextInput
|
|
|
|
placeholder={I18n.t('Password')}
|
|
|
|
returnKeyType='send'
|
|
|
|
secureTextEntry
|
|
|
|
onSubmitEditing={submit}
|
|
|
|
onChangeText={setPassword}
|
|
|
|
testID='e2e-enter-your-password-view-password'
|
|
|
|
textContentType='password'
|
|
|
|
/>
|
|
|
|
<Button onPress={submit} title={I18n.t('Confirm')} disabled={!password} testID='e2e-enter-your-password-view-confirm' />
|
|
|
|
<Text style={[styles.info, { color: colors.bodyText }]}>{I18n.t('Enter_Your_Encryption_Password_desc1')}</Text>
|
|
|
|
<Text style={[styles.info, { color: colors.bodyText }]}>{I18n.t('Enter_Your_Encryption_Password_desc2')}</Text>
|
|
|
|
</SafeAreaView>
|
|
|
|
</ScrollView>
|
|
|
|
</KeyboardView>
|
|
|
|
);
|
|
|
|
};
|
2020-09-11 14:31:38 +00:00
|
|
|
|
2022-08-11 14:59:40 +00:00
|
|
|
export default E2EEnterYourPasswordView;
|