ChangePasswordScreen.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import { Div, Button, Image, Text, Avatar, Input } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { useTranslation } from 'react-i18next';
  6. import { useCreation } from 'ahooks';
  7. export default function ChangePasswordScreen({ navigation }: StackScreenProps) {
  8. const { t } = useTranslation();
  9. const [password, setPassword] = React.useState<string>('');
  10. const [passwordNew1, setPasswordNew1] = React.useState<string>('');
  11. const [passwordNew2, setPasswordNew2] = React.useState<string>('');
  12. const canNext = useCreation(() => {
  13. if (password && passwordNew1 && passwordNew1 === passwordNew2) {
  14. return true;
  15. } else {
  16. return false;
  17. }
  18. }, [password, passwordNew1, passwordNew2]);
  19. return (
  20. <Div bg="gray100" flex={1}>
  21. <ScrollView
  22. contentContainerStyle={{
  23. flexGrow: 1,
  24. backgroundColor: '#f2f2f2',
  25. }}
  26. >
  27. <Div bg="white" px={15}>
  28. <Div
  29. row
  30. alignItems="center"
  31. py={10}
  32. borderColor="gray100"
  33. borderBottomWidth={1}
  34. >
  35. <Text w={75} textAlign="left">
  36. {t('yuan-mi-ma')}:
  37. </Text>
  38. <Input
  39. flex={1}
  40. rounded="sm"
  41. px={12}
  42. ml={5}
  43. h={30}
  44. type={'custom'}
  45. value={password}
  46. borderWidth={0}
  47. fontSize="md"
  48. secureTextEntry
  49. opacity={1}
  50. loaderColor="gray400"
  51. color="gray900"
  52. onChangeText={(text) => {
  53. setPassword(text);
  54. }}
  55. style={{ flex: 1 }}
  56. placeholder={t('qing-shu-ru-yuan-mi-ma')}
  57. />
  58. </Div>
  59. <Div
  60. row
  61. alignItems="center"
  62. py={10}
  63. borderColor="gray100"
  64. borderBottomWidth={1}
  65. >
  66. <Text w={75} textAlign="left">
  67. {t('xin-mi-ma')}:
  68. </Text>
  69. <Input
  70. flex={1}
  71. rounded="sm"
  72. px={12}
  73. ml={5}
  74. h={30}
  75. type={'custom'}
  76. value={passwordNew1}
  77. borderWidth={0}
  78. fontSize="md"
  79. secureTextEntry
  80. opacity={1}
  81. loaderColor="gray400"
  82. color="gray900"
  83. onChangeText={(text) => {
  84. setPasswordNew1(text);
  85. }}
  86. style={{ flex: 1 }}
  87. placeholder={t('qing-shu-ru-xin-mi-ma')}
  88. />
  89. </Div>
  90. <Div
  91. row
  92. alignItems="center"
  93. py={10}
  94. borderColor="gray100"
  95. borderBottomWidth={1}
  96. >
  97. <Text w={75} textAlign="left">
  98. {t('que-ren-mi-ma')}:
  99. </Text>
  100. <Input
  101. flex={1}
  102. rounded="sm"
  103. px={12}
  104. ml={5}
  105. h={30}
  106. type={'custom'}
  107. value={passwordNew2}
  108. borderWidth={0}
  109. fontSize="md"
  110. secureTextEntry
  111. opacity={1}
  112. loaderColor="gray400"
  113. color="gray900"
  114. onChangeText={(text) => {
  115. setPasswordNew2(text);
  116. }}
  117. style={{ flex: 1 }}
  118. placeholder={t('qing-zhong-fu-shu-ru-xin-mi-ma')}
  119. />
  120. </Div>
  121. </Div>
  122. <Button
  123. disabled={!canNext}
  124. block
  125. my={50}
  126. mx={15}
  127. bg="yellow500"
  128. fontSize="sm"
  129. >
  130. {t('bao-cun')}
  131. </Button>
  132. </ScrollView>
  133. </Div>
  134. );
  135. }