|
|
@ -4,116 +4,141 @@ import { StyleSheet, Text, View, Image } from "react-native"; |
|
|
|
import * as Yup from "yup"; |
|
|
|
|
|
|
|
import { |
|
|
|
Form, |
|
|
|
FormField, |
|
|
|
FormPicker as Picker, |
|
|
|
SubmitButton, |
|
|
|
Form, |
|
|
|
FormField, |
|
|
|
FormPicker as Picker, |
|
|
|
SubmitButton, |
|
|
|
} from "../components/forms"; |
|
|
|
import Screen from "../components/Screen"; |
|
|
|
import DatePicker from 'react-native-datepicker'; |
|
|
|
import DatePicker from "react-native-datepicker"; |
|
|
|
import useLocation from "../hooks/useLocation"; |
|
|
|
import FormImagePicker from "../components/forms/FormImagePicker"; |
|
|
|
import { insertPluviometerData } from "../database/databaseLoader"; |
|
|
|
|
|
|
|
const validationSchema = Yup.object().shape({ |
|
|
|
pluviometer: Yup.number().required().min(1).max(10000).label("pluviometer"), |
|
|
|
images: Yup.array().min(1, "Por favor, selecione uma imagem."), |
|
|
|
pluviometer: Yup.number().required().min(1).max(10000).label("pluviometer"), |
|
|
|
images: Yup.array().min(1, "Por favor, selecione uma imagem."), |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function PluviometerSharingDataScreen() { |
|
|
|
const location = useLocation(); |
|
|
|
|
|
|
|
var day = new Date().getDate(); |
|
|
|
var month = new Date().getMonth() + 1; |
|
|
|
var year = new Date().getFullYear(); |
|
|
|
|
|
|
|
var currentDate = day + '/' + month + '/' + year |
|
|
|
|
|
|
|
const [date, setDate] = useState(currentDate); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
<Screen style={styles.container}> |
|
|
|
<View style={{ alignSelf: 'center' }}> |
|
|
|
<Image style={styles.image} source={require("../assets/pluviometro.png")} /> |
|
|
|
<Text style={{ fontSize: 18, fontWeight: 'bold', color: '#1976D2' }}>Pluviômetro</Text> |
|
|
|
</View> |
|
|
|
|
|
|
|
<Form |
|
|
|
initialValues={{ |
|
|
|
title: "", |
|
|
|
pluviometer: "", |
|
|
|
description: "", |
|
|
|
category: null, |
|
|
|
images: [], |
|
|
|
}} |
|
|
|
onSubmit={(values) => console.log(location)} |
|
|
|
validationSchema={validationSchema}> |
|
|
|
<View style={{ marginTop: 30 }}> |
|
|
|
<Text style={{ |
|
|
|
fontSize: 16, fontWeight: 'bold', textAlign: 'left', color: '#1976D2', marginTop: 10 |
|
|
|
}}>Quantidade de chuva:</Text> |
|
|
|
<FormField |
|
|
|
keyboardType="pluviometer" |
|
|
|
maxLength={200} |
|
|
|
name="pluviometer" |
|
|
|
placeholder="Digite a quantidade de chuva" |
|
|
|
width={280} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
|
|
|
|
<View style={{ marginTop: 10, width: 220, borderRadius: 25 }}> |
|
|
|
<Text style={{ fontSize: 16, fontWeight: 'bold', textAlign: 'left', color: '#1976D2', marginBottom: 5 }}>Data da coleta:</Text> |
|
|
|
<DatePicker |
|
|
|
style={styles.datePickerStyle} |
|
|
|
date={date} |
|
|
|
mode="date" // The enum of date, datetime and time
|
|
|
|
placeholder="Selecione a data da coleta" |
|
|
|
format="DD/MM/YYYY" |
|
|
|
minDate="01/01/2020" |
|
|
|
maxDate={currentDate} |
|
|
|
confirmBtnText="Confirmar" |
|
|
|
cancelBtnText="Cancelar" |
|
|
|
customStyles={{ |
|
|
|
dateIcon: { |
|
|
|
//display: 'none',
|
|
|
|
position: 'absolute', |
|
|
|
left: 0, |
|
|
|
top: 4, |
|
|
|
marginLeft: 0, |
|
|
|
}, |
|
|
|
dateInput: { |
|
|
|
marginLeft: 36, |
|
|
|
borderRadius: 18, |
|
|
|
}, |
|
|
|
}} |
|
|
|
onDateChange={(date) => { |
|
|
|
setDate(date); |
|
|
|
}} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
<FormImagePicker backgroundColor="#1976D2" name="images" styles={{ width: 50 }} /> |
|
|
|
|
|
|
|
<SubmitButton title="Enviar" /> |
|
|
|
</Form> |
|
|
|
</Screen> |
|
|
|
); |
|
|
|
const location = useLocation(); |
|
|
|
|
|
|
|
var day = new Date().getDate(); |
|
|
|
var month = new Date().getMonth() + 1; |
|
|
|
var year = new Date().getFullYear(); |
|
|
|
|
|
|
|
var currentDate = day + "/" + month + "/" + year; |
|
|
|
|
|
|
|
const [date, setDate] = useState(currentDate); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Screen style={styles.container}> |
|
|
|
<View style={{ alignSelf: "center" }}> |
|
|
|
<Image |
|
|
|
style={styles.image} |
|
|
|
source={require("../assets/pluviometro.png")} |
|
|
|
/> |
|
|
|
<Text style={{ fontSize: 18, fontWeight: "bold", color: "#1976D2" }}> |
|
|
|
Pluviômetro |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
|
|
|
|
<Form |
|
|
|
initialValues={{ |
|
|
|
pluviometer: "", |
|
|
|
images: [], |
|
|
|
}} |
|
|
|
onSubmit={(values) => |
|
|
|
insertPluviometerData({ ...values, date, location }) |
|
|
|
} |
|
|
|
validationSchema={validationSchema} |
|
|
|
> |
|
|
|
<View style={{ marginTop: 30 }}> |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
fontSize: 16, |
|
|
|
fontWeight: "bold", |
|
|
|
textAlign: "left", |
|
|
|
color: "#1976D2", |
|
|
|
marginTop: 10, |
|
|
|
}} |
|
|
|
> |
|
|
|
Quantidade de chuva: |
|
|
|
</Text> |
|
|
|
<FormField |
|
|
|
keyboardType="pluviometer" |
|
|
|
maxLength={200} |
|
|
|
name="pluviometer" |
|
|
|
placeholder="Digite a quantidade de chuva" |
|
|
|
width={280} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
|
|
|
|
<View style={{ marginTop: 10, width: 220, borderRadius: 25 }}> |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
fontSize: 16, |
|
|
|
fontWeight: "bold", |
|
|
|
textAlign: "left", |
|
|
|
color: "#1976D2", |
|
|
|
marginBottom: 5, |
|
|
|
}} |
|
|
|
> |
|
|
|
Data da coleta: |
|
|
|
</Text> |
|
|
|
<DatePicker |
|
|
|
style={styles.datePickerStyle} |
|
|
|
date={date} |
|
|
|
mode="date" // The enum of date, datetime and time
|
|
|
|
placeholder="Selecione a data da coleta" |
|
|
|
format="DD/MM/YYYY" |
|
|
|
minDate="01/01/2020" |
|
|
|
maxDate={currentDate} |
|
|
|
confirmBtnText="Confirmar" |
|
|
|
cancelBtnText="Cancelar" |
|
|
|
customStyles={{ |
|
|
|
dateIcon: { |
|
|
|
//display: 'none',
|
|
|
|
position: "absolute", |
|
|
|
left: 0, |
|
|
|
top: 4, |
|
|
|
marginLeft: 0, |
|
|
|
}, |
|
|
|
dateInput: { |
|
|
|
marginLeft: 36, |
|
|
|
borderRadius: 18, |
|
|
|
}, |
|
|
|
}} |
|
|
|
onDateChange={(date) => { |
|
|
|
setDate(date); |
|
|
|
}} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
<FormImagePicker |
|
|
|
backgroundColor="#1976D2" |
|
|
|
name="images" |
|
|
|
styles={{ width: 50 }} |
|
|
|
/> |
|
|
|
|
|
|
|
<SubmitButton title="Enviar" /> |
|
|
|
</Form> |
|
|
|
</Screen> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
paddingHorizontal: 10, |
|
|
|
}, |
|
|
|
image: { |
|
|
|
width: 85, |
|
|
|
height: 85, |
|
|
|
justifyContent: "center", |
|
|
|
alignItems: "center", |
|
|
|
|
|
|
|
}, |
|
|
|
datePickerStyle: { |
|
|
|
width: 180, |
|
|
|
} |
|
|
|
}) |
|
|
|
container: { |
|
|
|
paddingHorizontal: 10, |
|
|
|
}, |
|
|
|
image: { |
|
|
|
width: 85, |
|
|
|
height: 85, |
|
|
|
justifyContent: "center", |
|
|
|
alignItems: "center", |
|
|
|
}, |
|
|
|
datePickerStyle: { |
|
|
|
width: 180, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
export default PluviometerSharingDataScreen; |