Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

InputField.jsx 1.6KB

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