import React, { useState } from "react"; import { StyleSheet, Text, View, Image, ScrollView } from "react-native"; import * as Yup from "yup"; import { Form, FormField, FormPicker as Picker, SubmitButton, } from "../components/forms"; import Screen from "../components/Screen"; import useLocation from "../hooks/useLocation"; import FormImagePicker from "../components/forms/FormImagePicker"; import { insertPluviometerData } from "../database/databaseLoader"; import { showMessage } from "react-native-flash-message"; import { dimensions, scaleDimsFromWidth } from "../config/dimensions"; import FormDatePicker from "../components/forms/FormDatePicker"; import colors from "../config/colors/"; import moment from "moment"; const dims = scaleDimsFromWidth(85, 85, 25); const validationSchema = Yup.object().shape({ pluviometer: Yup.number() .required("Campo obrigatório") .min(0, "O valor deve ser maior ou igual a 0.") .max(999) .label("pluviometer"), //data: Yup.string().required("Campo obrigatório. Por favor, selecione a data"), images: Yup.array(), }); function PluviometerSharingDataScreen(props) { const location = useLocation(); const [dateTime, setDateTime] = useState(moment()); const [time, setTime] = useState(moment()); return ( Pluviômetro
{ insertPluviometerData({ ...values, dateTime, time, location }); console.log("DATA:" + dateTime); console.log("HORA:" + time); showMessage({ message: "Informação enviada!", duration: 3000, icon: "success", type: "success", }); props.navigation.navigate("Home"); }} validationSchema={validationSchema} > Quantidade de chuva (mm): {/*Data da coleta:*/} setDateTime(value)} onTimeChange={(value) => setTime(value)} />
); } const styles = StyleSheet.create({ container: { padding: 10, flex: 1, }, image: { width: dims.width * 0.8, height: dims.height * 0.8, justifyContent: "center", alignItems: "center", }, labelStyle: { fontSize: dimensions.text.secondary, fontWeight: "bold", textAlign: "left", color: colors.primary, marginBottom: 5, }, }); export default PluviometerSharingDataScreen;