index.tsx 900 B

12345678910111213141516171819202122232425262728293031323334
  1. import React, { FC, useState } from 'react';
  2. import { TextInput, Text, View, InputModeOptions } from 'react-native';
  3. import { styling } from './style';
  4. type Props = {
  5. placeholder: string;
  6. onChange: (text: string) => void;
  7. header?: string;
  8. isPrivate?: boolean;
  9. inputMode?: InputModeOptions;
  10. };
  11. const Input: FC<Props> = ({ onChange, placeholder, header, isPrivate, inputMode }) => {
  12. const [focused, setFocused] = useState(false);
  13. const styles = styling(focused);
  14. return (
  15. <View>
  16. {header ? <Text style={styles.text}>{header}</Text> : null}
  17. <TextInput
  18. inputMode={inputMode ?? 'text'}
  19. secureTextEntry={isPrivate ?? false}
  20. placeholder={placeholder}
  21. onChangeText={onChange}
  22. onFocus={() => setFocused(true)}
  23. onBlur={() => setFocused(false)}
  24. style={styles.wrapper}
  25. />
  26. </View>
  27. );
  28. };
  29. export default Input;