normal_input.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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?: 'oneTimeCode';
  18. }
  19. const NormalInput = forwardRef<TextInput, NormalInputProps>(
  20. (
  21. {
  22. placeholder,
  23. extendedStyle,
  24. type,
  25. onChangeText,
  26. secureTextEntry = false,
  27. value,
  28. editable,
  29. textContentType
  30. },
  31. ref
  32. ) => {
  33. return (
  34. <TextInput
  35. ref={ref}
  36. style={[styles.textInput, extendedStyle]}
  37. placeholder={placeholder}
  38. placeholderTextColor={'#888888'}
  39. secureTextEntry={secureTextEntry}
  40. keyboardType={type ? type : 'default'}
  41. value={value}
  42. onChangeText={(value) => onChangeText(value)}
  43. textContentType={textContentType}
  44. editable={editable}
  45. />
  46. );
  47. }
  48. );
  49. const styles = StyleSheet.create({
  50. textInput: {
  51. maxWidth: '100%',
  52. fontSize: 16,
  53. borderWidth: 1,
  54. padding: 20,
  55. borderRadius: 12,
  56. borderColor: '#bbbbbb'
  57. }
  58. });
  59. export default NormalInput;