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 { useFormikContext } from "formik";
import { ErrorMessage } from "./forms";
import defaultStyles from "../config/styles";
function DropDown({
value,
setValue,
items,
setItems,
formPlaceholder,
searchPlaceholder,
nothingToShow,
doubleItemLine,
}) {
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,
doubleItemLine = false,
}) {
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;