import React, { useState } from "react"; import { StyleSheet, Text, View, Image, ScrollView, Modal, Platform } 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 { 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"; import moment from 'moment'; import colors from "../config/colors"; import { scaleDimsFromWidth } from "../config/dimensions"; 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(10000).label("pluviometer"), data: Yup.string().min(1, "Por favor preencha a data"), images: Yup.array(), }); function PluviometerSharingDataScreen(props) { const location = useLocation(); let dateTime = new Date().toString(); /*-------------------------------------------DATETIMEPICKER------------------------------------------------ const { textStyle, defaultDate } = props; const [date, setDate] = useState(moment(defaultDate)) const [show, setShow] = useState(false); //---------------ios------------------------ const onChange = (e, selectedDate) => { setDate(moment(selectedDate)); dateTime = moment(selectedDate).format("DD/MM/YYYY").toString(); } const onCancelPress = () => { setDate(moment(defaultDate)); setShow(false); } const onDonePress = () => { setShow(false); } //------------------------------------------- const onAndroidChange = (e, selectedDate) => { setShow(false); if (selectedDate) { setDate(moment(selectedDate)); dateTime = moment(selectedDate).format("DD/MM/YYYY").toString(); //props.onDateChange(selectedDate); } } const renderDatePicker = () => { return ( ) } ---------------------------------------------------------------------------------------------------------*/ return ( Pluviômetro
{ insertPluviometerData({ ...values, dateTime, location }); showMessage({ message: "Informação enviada!", duration: 3000, icon: "success", type: "success", }); props.navigation.goBack(null); }} validationSchema={validationSchema} > Quantidade de chuva: Data da coleta: {/* setShow(true)}> {date.format('DD/MM/YYYY')} {Platform.OS !== 'ios' && show && renderDatePicker()} {Platform.OS === 'ios' && show && ( setShow(false)}> setShow(false)}> console.log('Datepicker press')}> {renderDatePicker()} Cancelar Ok )} */}
); } const styles = StyleSheet.create({ container: { padding: 10, flex: 1 }, image: { width: dims.width * 0.8, height: dims.height * 0.8, justifyContent: "center", alignItems: "center", }, datePickerView: { width: 280, flexDirection: "row", justifyContent: "space-between", paddingVertical: 15, }, datepickerStyle: { borderRadius: 25, width: 280, backgroundColor: "#f8f4f4", }, dateIcon: { marginTop: 25, marginLeft: 15, }, labelStyle: { fontSize: 16, fontWeight: "bold", textAlign: "left", color: "#1976D2", marginBottom: 5, }, btnText: { position: "absolute", top: 0, height: 42, paddingHorizontal: 20, flexDirection: "row", alignItems: "center", justifyContent: "center", color: colors.primary, }, btnCancel: { left: 0, }, btnDone: { right: 0, }, }); export default PluviometerSharingDataScreen;