forked from cemaden-educacao/WPD-MobileApp
GabrielTrettel
3 years ago
2 changed files with 72 additions and 2 deletions
@ -0,0 +1,70 @@ |
|||
import React, {useState} from "react"; |
|||
import ErrorMessage from "./ErrorMessage"; |
|||
import { useFormikContext } from "formik"; |
|||
import { View, TextInput, StyleSheet } from "react-native"; |
|||
import { MaterialCommunityIcons } from "@expo/vector-icons"; |
|||
import colors from "../../config/colors"; |
|||
import defaultStyles from "../../config/styles"; |
|||
|
|||
function PasswordFormField({ name, ...otherProps }) { |
|||
const { |
|||
values, |
|||
setFieldTouched, |
|||
setFieldValue, |
|||
handleChange, |
|||
errors, |
|||
touched, |
|||
} = useFormikContext(); |
|||
const [fieldVal, setFieldVal] = useState(values[name]); |
|||
|
|||
|
|||
return ( |
|||
<View> |
|||
<View style={styles.container}> |
|||
<TextInput |
|||
flex={1} |
|||
onBlur={() => setFieldTouched(name)} |
|||
onChangeText={(val) => { |
|||
setFieldVal(val); |
|||
}} |
|||
value={fieldVal.toString()} |
|||
style={defaultStyles.text} |
|||
height={48} |
|||
placeholderTextColor={colors.medium} |
|||
{...otherProps} |
|||
/> |
|||
|
|||
<MaterialCommunityIcons |
|||
name={"eye"} |
|||
size={20} |
|||
color={defaultStyles.colors.medium} |
|||
style={styles.icon} |
|||
/> |
|||
</View> |
|||
<View style={{ paddingHorizontal: 16 }}> |
|||
<ErrorMessage error={errors[name]} visible={touched[name]} /> |
|||
</View> |
|||
</View> |
|||
); |
|||
} |
|||
|
|||
const styles = StyleSheet.create({ |
|||
container: { |
|||
...defaultStyles.shadow, |
|||
flexDirection: "row", |
|||
alignItems: "center", |
|||
backgroundColor: colors.white, |
|||
borderRadius: 6, |
|||
borderColor: colors.grayBG, |
|||
borderWidth: 1, |
|||
padding: 5, |
|||
paddingLeft: 10, |
|||
marginHorizontal: 16 |
|||
}, |
|||
icon: { |
|||
marginRight: 10, |
|||
alignItems: "flex-end" |
|||
}, |
|||
}); |
|||
|
|||
export default PasswordFormField; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue