You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InputField.jsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React from "react";
  2. import {
  3. View,
  4. Text,
  5. TouchableOpacity,
  6. TextInput,
  7. StyleSheet,
  8. } from "react-native";
  9. import { globalStyles } from "../styles/global";
  10. import { useTheme } from "@Styles";
  11. const InputField = ({
  12. label,
  13. icon,
  14. inputType,
  15. keyboardType,
  16. filedButtonLabel,
  17. fieldButtonFunction,
  18. onChangeText,
  19. text,
  20. name,
  21. handleBlur,
  22. }) => {
  23. const { colors } = useTheme();
  24. return (
  25. <View style={styles.textField}>
  26. {icon}
  27. {inputType === "password" ? (
  28. <TextInput
  29. name={name}
  30. placeholder={label}
  31. placeholderTextColor="#C6C6C6"
  32. keyboardType={keyboardType}
  33. style={[styles.textInput, { color: colors.textPrimary }]}
  34. secureTextEntry={true}
  35. value={text}
  36. onChangeText={onChangeText}
  37. onBlur={handleBlur}
  38. />
  39. ) : (
  40. <TextInput
  41. name={name}
  42. autoCapitalize="none"
  43. autoCorrect={false}
  44. placeholder={label}
  45. placeholderTextColor="#C6C6C6"
  46. keyboardType={keyboardType}
  47. style={[styles.textInput, { color: colors.textPrimary }]}
  48. value={text}
  49. onChangeText={onChangeText}
  50. onBlur={handleBlur}
  51. />
  52. )}
  53. <TouchableOpacity onPress={fieldButtonFunction}>
  54. <Text style={globalStyles.primaryBold}>{filedButtonLabel}</Text>
  55. </TouchableOpacity>
  56. </View>
  57. );
  58. };
  59. const styles = StyleSheet.create({
  60. textField: {
  61. flexDirection: "row",
  62. borderBottomColor: "#ccc",
  63. borderBottomWidth: 1,
  64. paddingBottom: 8,
  65. marginBottom: 25,
  66. },
  67. textInput: {
  68. flex: 1,
  69. paddingVertical: 0,
  70. fontFamily: "poppins-regular",
  71. },
  72. });
  73. export default InputField;