Browse Source

Making SearchablePicker not dependent on Formik

master
GabrielTrettel 3 years ago
parent
commit
54522a45c8
  1. 13
      src/app/components/SearchablePicker.js
  2. 2
      src/app/config/dimensions.js

13
src/app/components/SearchablePicker.js

@ -61,15 +61,22 @@ function SearchablePicker({
formPlaceholder, formPlaceholder,
searchPlaceholder, searchPlaceholder,
name, name,
setSelected,
nothingToShow = "Não encontramos nada com esse termo", nothingToShow = "Não encontramos nada com esse termo",
marginRight = 2, marginRight = 2,
marginLeft = 16, marginLeft = 16,
}) { }) {
const { values, setFieldValue, errors, touched } = useFormikContext();
const [value, setValue] = useState(values[name]);
const { values, setFieldValue, errors, touched } = name ? useFormikContext() : [1,1,1,1];
const [value, setValue] = useState(name ? values[name] : "");
useEffect(() => { useEffect(() => {
if (name)
setFieldValue(name, value, true); setFieldValue(name, value, true);
else
setSelected(value)
}, [value]); }, [value]);
return ( return (
@ -97,7 +104,7 @@ function SearchablePicker({
/> />
</Shadow> </Shadow>
<ErrorMessage error={errors[name]} visible={touched[name]} />
{name && (<ErrorMessage error={errors[name]} visible={touched[name]} />)}
</View> </View>
); );
} }

2
src/app/config/dimensions.js

@ -5,7 +5,7 @@ const screen_height = Dimensions.get("window").height;
const dimensions = { const dimensions = {
text: { text: {
header: 26,
header: 24,
secondary: 18, secondary: 18,
default: 16, default: 16,
tertiary: 14, tertiary: 14,

Loading…
Cancel
Save