|
@ -48,9 +48,11 @@ export default function DatePicker(props) { |
|
|
if (selectedDate) { |
|
|
if (selectedDate) { |
|
|
if (mode == "date") { |
|
|
if (mode == "date") { |
|
|
setDate(moment(selectedDate)); |
|
|
setDate(moment(selectedDate)); |
|
|
props.onDateChange(date); |
|
|
|
|
|
|
|
|
props.onDateChange(moment(selectedDate)); |
|
|
|
|
|
if (props.onTimeChange) { |
|
|
setMode("time"); |
|
|
setMode("time"); |
|
|
setShow(true); // to show the picker again in time mode
|
|
|
setShow(true); // to show the picker again in time mode
|
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (validateTimeInput(selectedDate)) { |
|
|
if (validateTimeInput(selectedDate)) { |
|
|
setTime(moment(selectedDate)); |
|
|
setTime(moment(selectedDate)); |
|
@ -74,8 +76,10 @@ export default function DatePicker(props) { |
|
|
if (mode == "date") { |
|
|
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); |
|
|
|
|
|
if (props.onTimeChange) { |
|
|
setMode("time"); |
|
|
setMode("time"); |
|
|
setShow(true); // to show the picker again in time mode
|
|
|
setShow(true); // to show the picker again in time mode
|
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (validateTimeInput(auxDate)) { |
|
|
if (validateTimeInput(auxDate)) { |
|
|
setTime(moment(auxDate)); |
|
|
setTime(moment(auxDate)); |
|
@ -96,7 +100,7 @@ export default function DatePicker(props) { |
|
|
mode={mode} |
|
|
mode={mode} |
|
|
is24Hour={true} |
|
|
is24Hour={true} |
|
|
locale={"pt-br"} |
|
|
locale={"pt-br"} |
|
|
minimumDate={new Date(moment().subtract(1, "month"))} |
|
|
|
|
|
|
|
|
minimumDate={props.minimumDate} |
|
|
maximumDate={new Date(moment())} |
|
|
maximumDate={new Date(moment())} |
|
|
formatChosenDate={(selectedDate) => { |
|
|
formatChosenDate={(selectedDate) => { |
|
|
if (mode == "date") { |
|
|
if (mode == "date") { |
|
@ -112,7 +116,7 @@ export default function DatePicker(props) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<View> |
|
|
|
|
|
|
|
|
<View flex={1}> |
|
|
<TouchableOpacity disabled={disabled} onPress={() => setShow(true)}> |
|
|
<TouchableOpacity disabled={disabled} onPress={() => setShow(true)}> |
|
|
{props.children} |
|
|
{props.children} |
|
|
</TouchableOpacity> |
|
|
</TouchableOpacity> |
|
@ -144,7 +148,6 @@ export default function DatePicker(props) { |
|
|
borderTopColor: "#d3d3d3", |
|
|
borderTopColor: "#d3d3d3", |
|
|
borderTopWidth: 1, |
|
|
borderTopWidth: 1, |
|
|
}} |
|
|
}} |
|
|
// onPress={() => console.log("datepicker clicked")}
|
|
|
|
|
|
> |
|
|
> |
|
|
<View |
|
|
<View |
|
|
style={{ |
|
|
style={{ |
|
@ -182,7 +185,9 @@ DatePicker.defaultProps = { |
|
|
textStyle: {}, |
|
|
textStyle: {}, |
|
|
defaultDate: moment(), |
|
|
defaultDate: moment(), |
|
|
onDateChange: () => {}, |
|
|
onDateChange: () => {}, |
|
|
onTimeChange: () => {}, |
|
|
|
|
|
|
|
|
onTimeChange: undefined, |
|
|
|
|
|
minimumDate: new Date(moment().subtract(1, "month")), |
|
|
|
|
|
flex: 0, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
const styles = StyleSheet.create({ |
|
|