From 76efadac0e3100db16c91c6f68099155bb680d09 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 11 Aug 2022 11:59:40 -0300 Subject: [PATCH] Chore: Migrate E2EEnterYourPasswordView to hooks (#4423) * migrate E2EEnterYourPasswordView to hooks * remove navigation options * minor tweak Co-authored-by: Reinaldo Neto --- app/stacks/InsideStack.tsx | 6 +- app/stacks/MasterDetailStack/index.tsx | 6 +- app/views/E2EEnterYourPasswordView.tsx | 124 ++++++++++--------------- 3 files changed, 49 insertions(+), 87 deletions(-) diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx index 5c077081c..21b2004d8 100644 --- a/app/stacks/InsideStack.tsx +++ b/app/stacks/InsideStack.tsx @@ -296,11 +296,7 @@ const E2EEnterYourPasswordStackNavigator = () => { - + ); }; diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index c740c781f..bba752d80 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -201,11 +201,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { options={E2ESaveYourPasswordView.navigationOptions} /> - + { + const [password, setPassword] = useState(''); + const { colors } = useTheme(); + const navigation = useNavigation(); + const dispatch = useDispatch(); -type TE2EEnterYourPasswordViewProps = IBaseScreen; + useLayoutEffect(() => { + navigation.setOptions({ + headerLeft: () => , + title: I18n.t('Enter_Your_E2E_Password') + }); + }, [navigation]); -class E2EEnterYourPasswordView extends React.Component { - private passwordInput?: RNTextInput; - - static navigationOptions = ({ navigation }: Pick): StackNavigationOptions => ({ - headerLeft: () => , - title: I18n.t('Enter_Your_E2E_Password') - }); - - constructor(props: TE2EEnterYourPasswordViewProps) { - super(props); - this.state = { - password: '' - }; - } - - submit = () => { + const submit = () => { logEvent(events.E2E_ENTER_PW_SUBMIT); - const { password } = this.state; - const { dispatch } = this.props; dispatch(encryptionDecodeKey(password)); }; - render() { - const { password } = this.state; - const { theme } = this.props; - - return ( - - - + + + - - { - this.passwordInput = e; - }} - 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' - /> -