normal_input.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import React, { forwardRef } from 'react';
  2. import {
  3. TextInput,
  4. StyleSheet,
  5. StyleProp,
  6. ViewStyle,
  7. KeyboardTypeOptions
  8. } from 'react-native';
  9. interface NormalInputProps {
  10. placeholder: string | undefined;
  11. extendedStyle?: StyleProp<ViewStyle>;
  12. onChangeText: (text: string) => void;
  13. type?: KeyboardTypeOptions;
  14. secureTextEntry?: boolean;
  15. value?: string;
  16. editable?: boolean;
  17. textContentType?:
  18. | 'none'
  19. | 'URL'
  20. | 'addressCity'
  21. | 'addressCityAndState'
  22. | 'addressState'
  23. | 'countryName'
  24. | 'creditCardNumber'
  25. | 'emailAddress'
  26. | 'familyName'
  27. | 'fullStreetAddress'
  28. | 'givenName'
  29. | 'jobTitle'
  30. | 'location'
  31. | 'middleName'
  32. | 'name'
  33. | 'namePrefix'
  34. | 'nameSuffix'
  35. | 'nickname'
  36. | 'organizationName'
  37. | 'postalCode'
  38. | 'streetAddressLine1'
  39. | 'streetAddressLine2'
  40. | 'sublocality'
  41. | 'telephoneNumber'
  42. | 'username'
  43. | 'password'
  44. | 'newPassword'
  45. | 'oneTimeCode';
  46. autoComplete?:
  47. | 'name'
  48. | 'nickname'
  49. | 'username'
  50. | 'password'
  51. | 'new-password'
  52. | 'one-time-code'
  53. | 'email'
  54. | 'tel'
  55. | 'street-address'
  56. | 'postal-code'
  57. | 'cc-number'
  58. | 'cc-exp'
  59. | 'cc-csc'
  60. | 'cc-exp-month'
  61. | 'cc-exp-year'
  62. | 'off'
  63. | 'password-new';
  64. }
  65. const NormalInput = forwardRef<TextInput, NormalInputProps>(
  66. (
  67. {
  68. placeholder,
  69. extendedStyle,
  70. type,
  71. onChangeText,
  72. autoComplete,
  73. secureTextEntry = false,
  74. value,
  75. editable,
  76. textContentType = 'oneTimeCode'
  77. },
  78. ref
  79. ) => {
  80. return (
  81. <TextInput
  82. ref={ref}
  83. style={[styles.textInput, extendedStyle]}
  84. placeholder={placeholder}
  85. placeholderTextColor={'#888888'}
  86. secureTextEntry={secureTextEntry}
  87. keyboardType={type ? type : 'default'}
  88. value={value}
  89. onChangeText={(value) => onChangeText(value)}
  90. textContentType={textContentType}
  91. editable={editable}
  92. autoComplete={autoComplete}
  93. />
  94. );
  95. }
  96. );
  97. const styles = StyleSheet.create({
  98. textInput: {
  99. maxWidth: '100%',
  100. fontSize: 16,
  101. borderWidth: 1,
  102. padding: 20,
  103. borderRadius: 12,
  104. borderColor: '#bbbbbb'
  105. }
  106. });
  107. export default NormalInput;