RegisterScreen.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import * as WebBrowser from "expo-web-browser";
  2. import * as React from "react";
  3. import {
  4. Image,
  5. Platform,
  6. StyleSheet,
  7. TouchableOpacity,
  8. View,
  9. ImageBackground,
  10. } from "react-native";
  11. import scrollPage from "../decorator/scrollPage";
  12. import { useModel } from "flooks";
  13. import {
  14. Layout,
  15. Tab,
  16. TabView,
  17. Text,
  18. useTheme,
  19. Button,
  20. } from "@ui-kitten/components";
  21. import FormInput from "../components/FormInput";
  22. import { useFocusEffect } from "@react-navigation/native";
  23. import ScrollPage from "../components/ScrollPage";
  24. import ConnectButton from "../components/ConnectButton";
  25. export default function RegisterScreen({ navigation, route }) {
  26. const theme = useTheme();
  27. const { changeBackground } = useModel("barModel");
  28. const { setNavigation, pushRouter } = useModel("routersModel", true);
  29. const {
  30. welcom,
  31. register_form_1,
  32. register_pla_1,
  33. register_form_2,
  34. register_pla_2,
  35. register_form_4,
  36. register_pla_4,
  37. login_form_3,
  38. login_pla_3,
  39. login_form_2,
  40. login_pla_2,
  41. register_form_3,
  42. register_pla_3,
  43. next,
  44. login_btn_code_1,
  45. } = useModel("wordsModel");
  46. useFocusEffect(
  47. React.useCallback(() => {
  48. changeBackground(theme["background-basic-color-1"]);
  49. setNavigation(navigation);
  50. }, [])
  51. );
  52. const [name, changeName] = React.useState("");
  53. const [showName, changeShowName] = React.useState("");
  54. const [phone, changePhone] = React.useState("");
  55. const [password, changePassword] = React.useState("");
  56. const [password2, changePassword2] = React.useState("");
  57. const [code, changeCode] = React.useState("");
  58. const canNext = React.useMemo(() => {
  59. if (
  60. name &&
  61. showName &&
  62. phone &&
  63. code &&
  64. password &&
  65. password == password2
  66. ) {
  67. return true;
  68. } else {
  69. return false;
  70. }
  71. }, [name, showName, phone, password, code, password2]);
  72. const { registerFirst } = useModel("userModel", true);
  73. return (
  74. <ScrollPage>
  75. <Layout style={styles.container}>
  76. <Image
  77. source={require("../assets/images/logo_1.png")}
  78. style={styles.logo}
  79. />
  80. <Image
  81. source={require("../assets/images/logo_2.png")}
  82. style={styles.logo2}
  83. />
  84. <Text style={styles.text} category='h6'>
  85. {welcom}
  86. </Text>
  87. <Layout style={styles.form}>
  88. {/* 输入商家名称 */}
  89. <FormInput
  90. label={register_form_1 + ":"}
  91. value={name}
  92. placeholder={register_pla_1}
  93. onChange={changeName}
  94. textAlign='right'
  95. />
  96. {/* 显示名称: */}
  97. <FormInput
  98. label={register_form_2 + ":"}
  99. value={showName}
  100. placeholder={register_pla_2}
  101. onChange={changeShowName}
  102. textAlign='right'
  103. />
  104. {/* 手机号 */}
  105. <FormInput
  106. label={register_form_4 + ":"}
  107. value={phone}
  108. type='phone'
  109. placeholder={register_pla_4}
  110. onChange={changePhone}
  111. textAlign='right'
  112. />
  113. {/* 验证码 */}
  114. <FormInput
  115. label={login_form_3 + ":"}
  116. value={code}
  117. type='code'
  118. placeholder={login_pla_3}
  119. onChange={changeCode}
  120. textAlign='right'
  121. btnText={login_btn_code_1}
  122. />
  123. {/* 密码 */}
  124. <FormInput
  125. label={login_form_2 + ":"}
  126. value={password}
  127. type='password'
  128. placeholder={login_pla_2}
  129. onChange={changePassword}
  130. textAlign='right'
  131. />
  132. {/* 确认密码 */}
  133. <FormInput
  134. label={register_form_3 + ":"}
  135. value={password2}
  136. type='password'
  137. placeholder={register_pla_3}
  138. onChange={changePassword2}
  139. textAlign='right'
  140. />
  141. <Layout style={styles.layoutLeft} level='1'>
  142. <Button
  143. status='primary'
  144. disabled={!canNext}
  145. onPress={() =>
  146. registerFirst({
  147. name,
  148. showName,
  149. phone,
  150. password,
  151. })
  152. }
  153. >
  154. {next}
  155. </Button>
  156. </Layout>
  157. </Layout>
  158. <ConnectButton />
  159. </Layout>
  160. </ScrollPage>
  161. );
  162. }
  163. const styles = StyleSheet.create({
  164. container: {
  165. flex: 1,
  166. alignItems: "center",
  167. justifyContent: "center",
  168. paddingTop: 10,
  169. paddingBottom: 33,
  170. },
  171. tabContent: {
  172. backgroundColor: "#fff",
  173. marginTop: 20,
  174. },
  175. logo: {
  176. width: 100,
  177. height: 100,
  178. alignSelf: "center",
  179. },
  180. logo2: {
  181. width: 97,
  182. height: 21,
  183. alignSelf: "center",
  184. marginTop: 2,
  185. },
  186. text: {
  187. marginTop: 16,
  188. },
  189. layoutLeft: {
  190. flexDirection: "row",
  191. paddingVertical: 10,
  192. justifyContent: "center",
  193. },
  194. form: {
  195. paddingHorizontal: 26,
  196. paddingVertical: 20,
  197. },
  198. });