diff --git a/src/app/screens/PluviometerSharingDataScreen.js b/src/app/screens/PluviometerSharingDataScreen.js
index e09a0ad..303b036 100644
--- a/src/app/screens/PluviometerSharingDataScreen.js
+++ b/src/app/screens/PluviometerSharingDataScreen.js
@@ -1,6 +1,6 @@
import React, { useState } from "react";
-import { StyleSheet, Text, View, Image, ScrollView } from "react-native";
+import { StyleSheet, Text, View, Image, ScrollView, Modal, Platform } from "react-native";
import * as Yup from "yup";
import {
@@ -13,7 +13,7 @@ import Screen from "../components/Screen";
import useLocation from "../hooks/useLocation";
import FormImagePicker from "../components/forms/FormImagePicker";
import { insertPluviometerData } from "../database/databaseLoader";
-import { TouchableOpacity } from "react-native-gesture-handler";
+import { TouchableHighlight, TouchableOpacity } from "react-native-gesture-handler";
import DateTimePicker from '@react-native-community/datetimepicker';
import { FontAwesome5 } from '@expo/vector-icons';
import { showMessage } from "react-native-flash-message";
@@ -33,6 +33,22 @@ function PluviometerSharingDataScreen(props) {
const [date, setDate] = useState(moment(defaultDate))
const [show, setShow] = useState(false);
let dateTime = new Date().toString();
+ //---------------ios------------------------
+ const onChange = (e, selectedDate) => {
+ setShow(false);
+ if (selectedDate) {
+ setDate(moment(defaultDate));
+ }
+ }
+ const onCancelPress = () => {
+ setDate(moment(defaultDate));
+ setShow(false);
+ }
+ const onDonePress = () => {
+ setDate(moment(date));
+ setShow(false);
+ }
+ //-------------------------------------------
const onAndroidChange = (e, selectedDate) => {
setShow(false);
@@ -42,6 +58,7 @@ function PluviometerSharingDataScreen(props) {
//props.onDateChange(selectedDate);
}
}
+
const renderDatePicker = () => {
return (
)
}
/*---------------------------------------------------------------------------------------------------------*/
return (
-
+
-
+ setShow(true)}>
+
+
+ {date.format('DD/MM/YYYY')}
+
+
+ {Platform.OS !== 'ios' && show && renderDatePicker()}
+ {Platform.OS === 'ios' && show && (
+ setShow(false)}>
+
+
+ onPress={() => setShow(false)}
+ console.log('Datepicker press')}>
+
+
+ { renderDatePicker }
+
+ onCancelPress()}
+ style={(styles.btnText, styles.btnCancel)}>
+ Cancelar
+
+
+ onDonePress()}
+ style={(styles.btnText, styles.btnDone)}>
+ OK
+
+
+
+
+
+
+ )}
+
+
+
+
+
+
+
+
);
@@ -148,7 +218,7 @@ const styles = StyleSheet.create({
backgroundColor: "#f8f4f4",
},
dateIcon: {
- marginRight: 15,
+ marginRight: 25,
},
labelStyle: {
fontSize: 16,
@@ -157,6 +227,21 @@ const styles = StyleSheet.create({
color: "#1976D2",
marginBottom: 5,
},
+ btnText: {
+ position: "absolute",
+ top: 0,
+ height: 42,
+ paddingHorizontal: 20,
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "center"
+ },
+ btnCancel: {
+ left: 0,
+ },
+ btnDone: {
+ right: 0,
+ },
});
export default PluviometerSharingDataScreen;