normal_input.tsx 2.9 KB

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