import React from 'react';
import {View, Text, TextInput} from 'react-native';
import {HEIGHTXD, WIDTHXD, getFontXD} from '../../config/Functions';
import R from '../../assets/R';

const TextField = props => {
  const {
    title,
    titleFontSize,
    required, 
    onChangeText, 
    maxLength,
    backgroundColor, 
    value, 
    editable,
    placeholder,
    fontSizePlaceHolder,
    containerMarginVertical,
    containerMarginHorizontal,
    containerMarginBottom,
    containerBackgroundColor,
    onFocus,
    fontFamily,
  } = props;

  return (
    <View style={{marginVertical: containerMarginVertical, marginHorizontal: containerMarginHorizontal, marginBottom: containerMarginBottom , backgroundColor: containerBackgroundColor}}>
      <Text
        style={{
          fontSize: titleFontSize,
          color: 'black',
          fontFamily:fontFamily,
          fontWeight:'400',
          marginBottom: 5,
        }}>
        {title ? title : ''}
        <Text style={{color: R.colors.red}}> {required ? "*" : ""}</Text>
      </Text>
      <TextInput
        placeholder={placeholder}
        maxLength={maxLength}
        textAlign={'left'}
        editable={editable != null ? editable : true}
        value={value}
        onChangeText={val => onChangeText(val)}
        multiline={true}
        numberOfLines={5}
        onFocus={onFocus}
        placeholderTextColor="gray"
        autoCapitalize="none"
        style={{
          textAlignVertical: 'top',
          textAlign: 'left',
          color: 'black',
          height: 210,
          borderColor:R.colors.grayBorderInputTextHeader,
          borderWidth:1,
          width: '100%',
          borderRadius: 7,
          fontSize: fontSizePlaceHolder,
          paddingVertical: 10,
          paddingHorizontal: 10,
          backgroundColor: backgroundColor,
          
        }}
      />
    </View>
  );
};

export default React.memo(TextField);
