2022-01-13 18:37:14 +00:00
|
|
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
2020-09-11 14:31:38 +00:00
|
|
|
import React from 'react';
|
2022-02-07 15:18:37 +00:00
|
|
|
import { ScrollView, StyleSheet, Text, TextInput as RNTextInput } from 'react-native';
|
2020-09-11 14:31:38 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
import { encryptionDecodeKey } from '../actions/encryption';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../lib/constants';
|
2022-01-13 18:37:14 +00:00
|
|
|
import Button from '../containers/Button';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../containers/HeaderButton';
|
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-05-18 19:17:42 +00:00
|
|
|
import FormTextInput from '../containers/TextInput/FormTextInput';
|
2022-01-13 18:37:14 +00:00
|
|
|
import { IBaseScreen } from '../definitions';
|
|
|
|
import I18n from '../i18n';
|
2022-04-13 20:43:56 +00:00
|
|
|
import KeyboardView from '../containers/KeyboardView';
|
2022-01-13 18:37:14 +00:00
|
|
|
import { E2EEnterYourPasswordStackParamList } from '../stacks/types';
|
|
|
|
import { withTheme } from '../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { events, logEvent } from '../utils/log';
|
2022-01-13 18:37:14 +00:00
|
|
|
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
2021-09-13 20:41:05 +00:00
|
|
|
import sharedStyles from './Styles';
|
2020-09-11 14:31:38 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
padding: 28
|
|
|
|
},
|
|
|
|
info: {
|
|
|
|
fontSize: 14,
|
|
|
|
marginVertical: 8,
|
|
|
|
...sharedStyles.textRegular
|
|
|
|
}
|
|
|
|
});
|
2021-11-17 20:03:53 +00:00
|
|
|
|
|
|
|
interface IE2EEnterYourPasswordViewState {
|
|
|
|
password: string;
|
|
|
|
}
|
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
type TE2EEnterYourPasswordViewProps = IBaseScreen<E2EEnterYourPasswordStackParamList, 'E2EEnterYourPasswordView'>;
|
2021-11-17 20:03:53 +00:00
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
class E2EEnterYourPasswordView extends React.Component<TE2EEnterYourPasswordViewProps, IE2EEnterYourPasswordViewState> {
|
2022-02-07 15:18:37 +00:00
|
|
|
private passwordInput?: RNTextInput;
|
2021-11-17 20:03:53 +00:00
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
static navigationOptions = ({ navigation }: Pick<TE2EEnterYourPasswordViewProps, 'navigation'>): StackNavigationOptions => ({
|
2020-10-30 16:15:58 +00:00
|
|
|
headerLeft: () => <HeaderButton.CloseModal navigation={navigation} testID='e2e-enter-your-password-view-close' />,
|
2020-09-11 14:31:38 +00:00
|
|
|
title: I18n.t('Enter_Your_E2E_Password')
|
2021-09-13 20:41:05 +00:00
|
|
|
});
|
2020-09-11 14:31:38 +00:00
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
constructor(props: TE2EEnterYourPasswordViewProps) {
|
2020-09-11 14:31:38 +00:00
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
password: ''
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
submit = () => {
|
|
|
|
logEvent(events.E2E_ENTER_PW_SUBMIT);
|
|
|
|
const { password } = this.state;
|
2022-01-13 18:37:14 +00:00
|
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(encryptionDecodeKey(password));
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-09-11 14:31:38 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { password } = this.state;
|
|
|
|
const { theme } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<KeyboardView
|
|
|
|
style={{ backgroundColor: themes[theme].backgroundColor }}
|
|
|
|
contentContainerStyle={sharedStyles.container}
|
2021-09-13 20:41:05 +00:00
|
|
|
keyboardVerticalOffset={128}>
|
2020-10-30 13:59:44 +00:00
|
|
|
<StatusBar />
|
2021-09-13 20:41:05 +00:00
|
|
|
<ScrollView
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
style={sharedStyles.container}
|
2021-11-17 20:03:53 +00:00
|
|
|
contentContainerStyle={sharedStyles.containerScrollView}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<SafeAreaView
|
|
|
|
style={[styles.container, { backgroundColor: themes[theme].backgroundColor }]}
|
|
|
|
testID='e2e-enter-your-password-view'>
|
2022-05-18 19:17:42 +00:00
|
|
|
<FormTextInput
|
2022-02-07 15:18:37 +00:00
|
|
|
inputRef={(e: RNTextInput) => {
|
2021-09-13 20:41:05 +00:00
|
|
|
this.passwordInput = e;
|
|
|
|
}}
|
2020-09-11 14:31:38 +00:00
|
|
|
placeholder={I18n.t('Password')}
|
|
|
|
returnKeyType='send'
|
|
|
|
secureTextEntry
|
|
|
|
onSubmitEditing={this.submit}
|
|
|
|
onChangeText={value => this.setState({ password: value })}
|
|
|
|
testID='e2e-enter-your-password-view-password'
|
|
|
|
textContentType='password'
|
|
|
|
autoCompleteType='password'
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
onPress={this.submit}
|
|
|
|
title={I18n.t('Confirm')}
|
|
|
|
disabled={!password}
|
|
|
|
theme={theme}
|
2020-10-30 18:31:04 +00:00
|
|
|
testID='e2e-enter-your-password-view-confirm'
|
2020-09-11 14:31:38 +00:00
|
|
|
/>
|
|
|
|
<Text style={[styles.info, { color: themes[theme].bodyText }]}>{I18n.t('Enter_Your_Encryption_Password_desc1')}</Text>
|
|
|
|
<Text style={[styles.info, { color: themes[theme].bodyText }]}>{I18n.t('Enter_Your_Encryption_Password_desc2')}</Text>
|
|
|
|
</SafeAreaView>
|
|
|
|
</ScrollView>
|
|
|
|
</KeyboardView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 18:37:14 +00:00
|
|
|
export default connect(null)(withTheme(E2EEnterYourPasswordView));
|