Browse Source

time picker for ios

master
analuizaff 4 years ago
parent
commit
2e6ab432e2
  1. 18
      src/app/components/forms/FormDatePicker.js

18
src/app/components/forms/FormDatePicker.js

@ -23,8 +23,6 @@ const FormDatePicker = (props) => {
const [mode, setMode] = useState("date"); const [mode, setMode] = useState("date");
const [time, setTime] = useState(moment(defaultDate)); const [time, setTime] = useState(moment(defaultDate));
//-------------------------- Time picker ainda não está habilitado pra ios --------------------------------
const onChange = (e, selectedDate) => { const onChange = (e, selectedDate) => {
setAuxDate(moment(selectedDate)); // variavel auxiliar para não alterar a data com a rolagem, apenas com o done setAuxDate(moment(selectedDate)); // variavel auxiliar para não alterar a data com a rolagem, apenas com o done
}; };
@ -51,14 +49,20 @@ const FormDatePicker = (props) => {
}; };
const onDonePress = () => { const onDonePress = () => {
setShow(false);
if (mode == "date") {
setDate(moment(auxDate)); //atualizar a data com a variável auxiliar setDate(moment(auxDate)); //atualizar a data com a variável auxiliar
props.onDateChange(auxDate); props.onDateChange(auxDate);
setMode("time");
setShow(true); // to show the picker again in time mode
}
else {
setTime(moment(auxDate));
props.onTimeChange(auxDate);
setShow(false); setShow(false);
};
const formatDate = (date, time) => {
time.getHours();
time.getMinuts();
setMode("date");
}
}; };
const renderDatePicker = () => { const renderDatePicker = () => {

Loading…
Cancel
Save