您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

InputField.jsx 1.5KB

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