import React, { useState, useEffect } from "react"; import { StyleSheet, View } from "react-native"; import colors from "../config/colors"; import DropDownPicker from "react-native-dropdown-picker"; import { Shadow } from "react-native-shadow-2"; import { useFormikContext } from "formik"; import { ErrorMessage } from "./forms"; function DropDown({ value, setValue, items, setItems, formPlaceholder, searchPlaceholder, nothingToShow, }) { const [open, setOpen] = useState(false); return ( ); } function SearchablePicker({ items, setItems, formPlaceholder, searchPlaceholder, name, setSelected, nothingToShow = "Não encontramos nada com esse termo", marginRight = 2, marginLeft = 16, }) { const { values, setFieldValue, errors, touched } = name ? useFormikContext() : [1,1,1,1]; const [value, setValue] = useState(name ? values[name] : ""); useEffect(() => { if (name) setFieldValue(name, value, true); else setSelected(value) }, [value]); return ( {name && ()} ); } const styles = StyleSheet.create({ location: { flex: 1, alignSelf: "flex-start", }, }); export default SearchablePicker;