phone_input.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. // import React, { useState } from "react";
  2. // import { View, Text, TextInput, StyleSheet, ViewStyle, StyleProp } from "react-native";
  3. // import { HandleSignUpFormDataChange } from "../../types/signup";
  4. // interface PhoneInputProps {
  5. // placeholder: string;
  6. // extendedStyle?: StyleProp<ViewStyle>;
  7. // handleFormDataChange?: HandleSignUpFormDataChange;
  8. // editable?: boolean;
  9. // }
  10. // const PhoneInput: React.FC<PhoneInputProps> = ({ placeholder, extendedStyle, handleFormDataChange, editable }) => {
  11. // const [error, setError] = useState("");
  12. // const handleTextChange = (text: string) => {
  13. // if (text.length >= 8) {
  14. // setError("");
  15. // handleFormDataChange?.("phone", text);
  16. // handleFormDataChange?.("phoneVerificationStatus", true);
  17. // } else {
  18. // setError("Please enter at least 8 digits");
  19. // handleFormDataChange?.("phone", text);
  20. // handleFormDataChange?.("phoneVerificationStatus", false);
  21. // }
  22. // };
  23. // return (
  24. // <View>
  25. // <View style={[styles.inputContainer, extendedStyle]}>
  26. // <Text style={styles.prefix}>+852</Text>
  27. // <View style={styles.horizontalLine} />
  28. // <TextInput
  29. // keyboardType="numeric"
  30. // onChangeText={handleTextChange}
  31. // placeholder={placeholder}
  32. // style={[styles.input]}
  33. // placeholderTextColor="#888888"
  34. // editable={editable}
  35. // />
  36. // </View>
  37. // {error && <Text style={styles.errorMessage}>{error}</Text>}
  38. // </View>
  39. // );
  40. // };
  41. // const styles = StyleSheet.create({
  42. // inputContainer: {
  43. // maxWidth: "100%",
  44. // flexDirection: "row",
  45. // alignItems: "center",
  46. // justifyContent: "center",
  47. // borderWidth: 1,
  48. // borderColor: "#bbbbbb",
  49. // borderRadius: 12,
  50. // padding: 20,
  51. // },
  52. // prefix: {
  53. // marginRight: 5,
  54. // fontSize: 16,
  55. // },
  56. // horizontalLine: {
  57. // width: 24,
  58. // borderColor: "#bbbbbb",
  59. // borderWidth: 0.5,
  60. // transform: [{ rotate: "90deg" }],
  61. // },
  62. // input: {
  63. // flex: 1,
  64. // marginLeft: 5,
  65. // fontSize: 16,
  66. // },
  67. // errorMessage: {
  68. // fontSize: 14,
  69. // color: "#ff0033",
  70. // fontWeight: "400",
  71. // marginLeft: 10,
  72. // marginTop: 10,
  73. // },
  74. // });
  75. // export default PhoneInput;
  76. // import React, { useState } from "react";
  77. // import { View, Text, TextInput, StyleSheet, ViewStyle, StyleProp } from "react-native";
  78. // import { SignUpFormData } from "../../types/signUpFormData";
  79. // interface PhoneInputProps {
  80. // placeholder: string;
  81. // extendedStyle?: StyleProp<ViewStyle>;
  82. // editable?: boolean;
  83. // signUpFormData?: SignUpFormData;
  84. // setSignUpFormData?: (newFormData: Partial<SignUpFormData>) => void;
  85. // }
  86. // const PhoneInput: React.FC<PhoneInputProps> = ({
  87. // placeholder,
  88. // extendedStyle,
  89. // editable,
  90. // signUpFormData,
  91. // setSignUpFormData,
  92. // }) => {
  93. // const [error, setError] = useState("");
  94. // const handleTextChange = (text: string) => {
  95. // if (text.length >= 8) {
  96. // setError("");
  97. // setSignUpFormData({
  98. // ...signUpFormData,
  99. // phone: text,
  100. // phoneVerificationStatus: true,
  101. // });
  102. // } else {
  103. // setError("Please enter at least 8 digits");
  104. // setSignUpFormData({
  105. // ...signUpFormData,
  106. // phone: text,
  107. // phoneVerificationStatus: false,
  108. // });
  109. // }
  110. // };
  111. // return (
  112. // <View>
  113. // <View style={[styles.inputContainer, extendedStyle]}>
  114. // <Text style={styles.prefix}>+852</Text>
  115. // <View style={styles.horizontalLine} />
  116. // <TextInput
  117. // value={signUpFormData?.phone}
  118. // keyboardType="numeric"
  119. // onChangeText={handleTextChange}
  120. // placeholder={placeholder}
  121. // style={[styles.input]}
  122. // placeholderTextColor="#888888"
  123. // editable={editable}
  124. // />
  125. // </View>
  126. // {error && <Text style={styles.errorMessage}>{error}</Text>}
  127. // </View>
  128. // );
  129. // };
  130. // const styles = StyleSheet.create({
  131. // inputContainer: {
  132. // maxWidth: "100%",
  133. // flexDirection: "row",
  134. // alignItems: "center",
  135. // justifyContent: "center",
  136. // borderWidth: 1,
  137. // borderColor: "#bbbbbb",
  138. // borderRadius: 12,
  139. // padding: 20,
  140. // },
  141. // prefix: {
  142. // marginRight: 5,
  143. // fontSize: 16,
  144. // },
  145. // horizontalLine: {
  146. // width: 24,
  147. // borderColor: "#bbbbbb",
  148. // borderWidth: 0.5,
  149. // transform: [{ rotate: "90deg" }],
  150. // },
  151. // input: {
  152. // flex: 1,
  153. // marginLeft: 5,
  154. // fontSize: 16,
  155. // },
  156. // errorMessage: {
  157. // fontSize: 14,
  158. // color: "#ff0033",
  159. // fontWeight: "400",
  160. // marginLeft: 10,
  161. // marginTop: 10,
  162. // },
  163. // });
  164. // export default PhoneInput;
  165. import React from 'react';
  166. import {
  167. View,
  168. Text,
  169. TextInput,
  170. StyleSheet,
  171. ViewStyle,
  172. StyleProp
  173. } from 'react-native';
  174. interface PhoneInputProps {
  175. value: string;
  176. onChangeText: (text: string) => void;
  177. placeholder: string;
  178. extendedStyle?: StyleProp<ViewStyle>;
  179. editable?: boolean;
  180. }
  181. const PhoneInput: React.FC<PhoneInputProps> = ({
  182. value,
  183. onChangeText,
  184. placeholder,
  185. extendedStyle,
  186. editable
  187. }) => {
  188. return (
  189. <View>
  190. <View style={[styles.inputContainer, extendedStyle]}>
  191. <Text style={styles.prefix}>+852</Text>
  192. <View style={styles.horizontalLine} />
  193. <TextInput
  194. value={value}
  195. onChangeText={onChangeText}
  196. keyboardType="numeric"
  197. placeholder={placeholder}
  198. style={[styles.input]}
  199. placeholderTextColor="#888888"
  200. editable={editable}
  201. />
  202. </View>
  203. </View>
  204. );
  205. };
  206. const styles = StyleSheet.create({
  207. inputContainer: {
  208. maxWidth: '100%',
  209. flexDirection: 'row',
  210. alignItems: 'center',
  211. justifyContent: 'center',
  212. borderWidth: 1,
  213. borderColor: '#bbbbbb',
  214. borderRadius: 12,
  215. padding: 20
  216. },
  217. prefix: {
  218. marginRight: 5,
  219. fontSize: 16
  220. },
  221. horizontalLine: {
  222. width: 24,
  223. borderColor: '#bbbbbb',
  224. borderWidth: 0.5,
  225. transform: [{ rotate: '90deg' }]
  226. },
  227. input: {
  228. flex: 1,
  229. marginLeft: 5,
  230. fontSize: 16
  231. },
  232. errorMessage: {
  233. fontSize: 14,
  234. color: '#ff0033',
  235. fontWeight: '400',
  236. marginLeft: 10,
  237. marginTop: 10
  238. }
  239. });
  240. export default PhoneInput;