| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import { useState } from 'react';
- import { View, Text, StyleSheet, TouchableWithoutFeedback, Keyboard, Pressable } from 'react-native';
- import ResetSuccessful from './formPages/resetSuccessful';
- import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
- import ForgetPasswordPage from './formPages/forgetPasswordPage';
- import { forgetPasswordFormData } from '../../../types/signup';
- import PaginationIndicator from '../../global/PaginationIndicator';
- import { router } from 'expo-router';
- import { useTranslation } from '../../../util/hooks/useTranslation';
- type ForgetPasswordFormProps = {
- forgetPasswordFormData: forgetPasswordFormData;
- setForgetPasswordFormData: React.Dispatch<React.SetStateAction<forgetPasswordFormData>>;
- };
- const ForgetPasswordForm: React.FC<ForgetPasswordFormProps> = ({
- forgetPasswordFormData,
- setForgetPasswordFormData
- }) => {
- const { t } = useTranslation(); // 使用翻译钩子
- const [screen, setScreen] = useState<number>(0);
- const FormTitle = [t('forgotPassword.phone_verification')];
- const goToPreviousPage = () => {
- if (router.canGoBack()) {
- router.back();
- } else {
- router.replace('/(public)/login');
- }
- };
- const ScreenDisplay = () => {
- switch (screen) {
- case 0:
- return (
- <ForgetPasswordPage
- forgetPasswordFormData={forgetPasswordFormData}
- setForgetPasswordFormData={setForgetPasswordFormData}
- setScreen={setScreen}
- />
- );
- case 1:
- return <ResetSuccessful />;
- default:
- return <></>;
- }
- };
- return (
- <>
- <KeyboardAwareScrollView
- enableOnAndroid={true}
- resetScrollToCoords={{ x: 0, y: 0 }}
- style={{
- height: '100%'
- }}
- >
- {screen === 0 && (
- <View style={styles.topContainer}>
- <Text style={styles.text}>{FormTitle[screen]}</Text>
- <View style={styles.breakline} />
- <View className="w-full flex-row justify-between items-center">
- <Pressable onPress={goToPreviousPage} className="flex-1">
- <Text
- style={{
- color: '#888888',
- fontSize: 18,
- paddingLeft: 25
- }}
- >{t('common.previous')}</Text>
- </Pressable>
- <PaginationIndicator totalPages={2} currentPage={0} />
- <View className="flex-1" />
- </View>
- </View>
- )}
- <View style={styles.bottomContainer}>{ScreenDisplay()}</View>
- </KeyboardAwareScrollView>
- </>
- );
- };
- const styles = StyleSheet.create({
- topContainer: {
- flex: 1,
- alignItems: 'center',
- justifyContent: 'center',
- paddingBottom: '25%',
- paddingTop: '15%'
- },
- previouspageAndPaginationWrapper: {
- display: 'flex',
- width: '100%',
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- paddingHorizontal: 25
- },
- bottomContainer: { flex: 1 },
- breakline: {
- width: 24,
- height: 1,
- backgroundColor: '#000000',
- marginVertical: 17
- },
- text: { fontSize: 24, fontWeight: '300' }
- });
- export default ForgetPasswordForm;
|