form.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { useState } from 'react';
  2. import {
  3. View,
  4. Text,
  5. StyleSheet,
  6. TouchableWithoutFeedback,
  7. Keyboard
  8. } from 'react-native';
  9. import ResetSuccessful from './formPages/resetSuccessful';
  10. import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
  11. import ForgetPasswordPage from './formPages/forgetPasswordPage';
  12. import { forgetPasswordFormData } from '../../../types/signup';
  13. type ForgetPasswordFormProps = {
  14. forgetPasswordFormData: forgetPasswordFormData;
  15. setForgetPasswordFormData: React.Dispatch<
  16. React.SetStateAction<forgetPasswordFormData>
  17. >;
  18. };
  19. const ForgetPasswordForm: React.FC<ForgetPasswordFormProps> = ({
  20. forgetPasswordFormData,
  21. setForgetPasswordFormData
  22. }) => {
  23. const [screen, setScreen] = useState<number>(0);
  24. const FormTitle = ['忘記密碼 - 電話驗證'];
  25. const ScreenDisplay = () => {
  26. switch (screen) {
  27. case 0:
  28. return (
  29. <ForgetPasswordPage
  30. forgetPasswordFormData={forgetPasswordFormData}
  31. setForgetPasswordFormData={setForgetPasswordFormData}
  32. setScreen={setScreen}
  33. />
  34. );
  35. case 1:
  36. return <ResetSuccessful />;
  37. default:
  38. return <></>;
  39. }
  40. };
  41. return (
  42. <>
  43. <KeyboardAwareScrollView
  44. enableOnAndroid={true}
  45. resetScrollToCoords={{ x: 0, y: 0 }}
  46. style={{
  47. height: "100%"
  48. }}
  49. >
  50. {screen === 0 && (
  51. <View style={styles.topContainer}>
  52. <Text style={styles.text}>{FormTitle[screen]}</Text>
  53. <View style={styles.breakline} />
  54. </View>
  55. )}
  56. <View style={styles.bottomContainer}>{ScreenDisplay()}</View>
  57. </KeyboardAwareScrollView>
  58. </>
  59. );
  60. };
  61. const styles = StyleSheet.create({
  62. topContainer: {
  63. flex: 1,
  64. alignItems: 'center',
  65. justifyContent: 'center',
  66. paddingBottom: '25%',
  67. paddingTop: '15%'
  68. },
  69. previouspageAndPaginationWrapper: {
  70. display: 'flex',
  71. width: '100%',
  72. flexDirection: 'row',
  73. justifyContent: 'space-between',
  74. alignItems: 'center',
  75. paddingHorizontal: 25
  76. },
  77. bottomContainer: { flex: 1 },
  78. breakline: {
  79. width: 24,
  80. height: 1,
  81. backgroundColor: '#000000',
  82. marginVertical: 17
  83. },
  84. text: { fontSize: 24, fontWeight: '300' }
  85. });
  86. export default ForgetPasswordForm;