normal_input.tsx 1.4 KB

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