|
|
@ -1,6 +1,6 @@ |
|
|
|
import React, { useState } from "react"; |
|
|
|
|
|
|
|
import { StyleSheet, Text, View, Image, Button, TouchableHighlight, Platform } from "react-native"; |
|
|
|
import { StyleSheet, Text, View, Image, ScrollView } from "react-native"; |
|
|
|
import * as Yup from "yup"; |
|
|
|
|
|
|
|
import { |
|
|
@ -10,15 +10,13 @@ import { |
|
|
|
SubmitButton, |
|
|
|
} from "../components/forms"; |
|
|
|
import Screen from "../components/Screen"; |
|
|
|
import DatePicker from "react-native-datepicker"; |
|
|
|
import useLocation from "../hooks/useLocation"; |
|
|
|
import FormImagePicker from "../components/forms/FormImagePicker"; |
|
|
|
import { insertPluviometerData } from "../database/databaseLoader"; |
|
|
|
import RNDateTimePicker from '@react-native-community/datetimepicker'; |
|
|
|
import { TextInput, TouchableOpacity } from "react-native-gesture-handler"; |
|
|
|
import { 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"; |
|
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
const validationSchema = Yup.object().shape({ |
|
|
@ -34,25 +32,16 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
const { textStyle, defaultDate } = props; |
|
|
|
const [date, setDate] = useState(moment(defaultDate)) |
|
|
|
const [show, setShow] = useState(false); |
|
|
|
let dateTime = new Date().toString(); |
|
|
|
|
|
|
|
const onAndroidChange = (e, selectedDate) => { |
|
|
|
setShow(false); |
|
|
|
if (selectedDate) { |
|
|
|
setDate(moment(selectedDate)); |
|
|
|
dateTime = moment(selectedDate).format("DD/MM/YYYY").toString(); |
|
|
|
//props.onDateChange(selectedDate);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const onCancelPress = () => { |
|
|
|
setDate(moment(defaultDate)); |
|
|
|
setShow(false); |
|
|
|
} |
|
|
|
|
|
|
|
const onDonePress = () => { |
|
|
|
// props.onDateChange(date);
|
|
|
|
setShow(false); |
|
|
|
} |
|
|
|
|
|
|
|
const renderDatePicker = () => { |
|
|
|
return ( |
|
|
|
<DateTimePicker |
|
|
@ -64,14 +53,10 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
/> |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------------------------------*/ |
|
|
|
|
|
|
|
// var day = new Date().getDate();
|
|
|
|
// var month = new Date().getMonth() + 1;
|
|
|
|
// var year = new Date().getFullYear();
|
|
|
|
return ( |
|
|
|
<Screen style={styles.container}> |
|
|
|
|
|
|
|
<View style={{ alignSelf: "center" }}> |
|
|
|
<Image |
|
|
|
style={styles.image} |
|
|
@ -81,14 +66,20 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
Pluviômetro |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
|
|
|
|
<ScrollView style={styles.container}> |
|
|
|
<Form |
|
|
|
initialValues={{ |
|
|
|
pluviometer: "", |
|
|
|
images: [], |
|
|
|
}} |
|
|
|
onSubmit={(values) => { |
|
|
|
insertPluviometerData({ ...values, date, location }); |
|
|
|
insertPluviometerData({ ...values, dateTime, location }); |
|
|
|
showMessage({ |
|
|
|
message: "Informação enviada!", |
|
|
|
duration: 1950, |
|
|
|
icon: "success", |
|
|
|
type: "success", |
|
|
|
}); |
|
|
|
props.navigation.goBack(null); |
|
|
|
}} |
|
|
|
validationSchema={validationSchema} |
|
|
@ -113,10 +104,10 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
<TouchableOpacity style={styles.datepickerStyle} |
|
|
|
onPress={() => setShow(true)}> |
|
|
|
<View style={styles.datePickerView}> |
|
|
|
<Text style={{ fontSize: 16, marginLeft:15}}> |
|
|
|
<Text style={{ fontSize: 16, marginLeft: 15 }}> |
|
|
|
{date.format('DD/MM/YYYY')} |
|
|
|
</Text> |
|
|
|
<FontAwesome5 style={styles.dateIcon} name="calendar-day" size={24} color="grey"/> |
|
|
|
<FontAwesome5 style={styles.dateIcon} name="calendar-day" size={24} color="grey" /> |
|
|
|
{show && renderDatePicker()} |
|
|
|
</View> |
|
|
|
</TouchableOpacity> |
|
|
@ -126,8 +117,11 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
name="images" |
|
|
|
styles={{ width: 50 }} |
|
|
|
/> |
|
|
|
<SubmitButton title="Enviar" /> |
|
|
|
<SubmitButton title="Enviar" style={{marginBottom:100}}/> |
|
|
|
<View style={{ flex: 1 }}> |
|
|
|
</View> |
|
|
|
</Form> |
|
|
|
</ScrollView> |
|
|
|
</Screen> |
|
|
|
); |
|
|
|
} |
|
|
@ -135,6 +129,7 @@ function PluviometerSharingDataScreen(props) { |
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
paddingHorizontal: 10, |
|
|
|
width: "100%", |
|
|
|
}, |
|
|
|
image: { |
|
|
|
width: 85, |
|
|
@ -144,9 +139,9 @@ const styles = StyleSheet.create({ |
|
|
|
}, |
|
|
|
datePickerView: { |
|
|
|
width: 280, |
|
|
|
flexDirection: "row", |
|
|
|
justifyContent:"space-between", |
|
|
|
paddingVertical:15, |
|
|
|
flexDirection: "row", |
|
|
|
justifyContent: "space-between", |
|
|
|
paddingVertical: 15, |
|
|
|
}, |
|
|
|
datepickerStyle: { |
|
|
|
borderRadius: 25, |
|
|
@ -154,14 +149,14 @@ const styles = StyleSheet.create({ |
|
|
|
backgroundColor: "#f8f4f4", |
|
|
|
}, |
|
|
|
dateIcon: { |
|
|
|
marginRight:15, |
|
|
|
marginRight: 15, |
|
|
|
}, |
|
|
|
labelStyle:{ |
|
|
|
fontSize: 16, |
|
|
|
fontWeight: "bold", |
|
|
|
textAlign: "left", |
|
|
|
color: "#1976D2", |
|
|
|
marginBottom: 5, |
|
|
|
labelStyle: { |
|
|
|
fontSize: 16, |
|
|
|
fontWeight: "bold", |
|
|
|
textAlign: "left", |
|
|
|
color: "#1976D2", |
|
|
|
marginBottom: 5, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|