import React, { useState } from "react"; import { StyleSheet, View } from "react-native"; import * as Yup from "yup"; import { Form, FormPicker as Picker, SubmitButton, FormField, } from "../components/forms"; import Screen from "../components/Screen"; import FormImagePicker from "../components/forms/FormImagePicker"; import useLocation from "../hooks/useLocation"; import { Image, Text } from "react-native"; import colors from "../config/colors"; import { TouchableNativeFeedback } from "react-native-gesture-handler"; import { insertRiverData } from "../database/databaseLoader"; import { showMessage } from "react-native-flash-message"; import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; import assets from "../config/assets"; import { scaleDimsFromWidth, dimensions } from "../config/dimensions"; import moment from "moment"; import FormDatePicker from "../components/forms/FormDatePicker"; const validationSchema = Yup.object().shape({ images: Yup.array(), description: Yup.string().label("Description"), }); const borderWidth = 4; function RiverFloodSharingDataScreen(props) { const [riverScale, setRiverScale] = useState(-1); const location = useLocation(); const [error, setError] = useState(false); const [dateTime, setDateTime] = useState(moment()); const [time, setTime] = useState(moment()); return ( Nível da água do rio
{ if (riverScale == -1) { setError(true); return; } insertRiverData({ ...values, riverScale, location }); showMessage({ message: "Informação enviada!", duration: 1950, icon: "success", type: "success", }); props.navigation.navigate("Home"); }} validationSchema={validationSchema} > setRiverScale(0)}> Baixo setRiverScale(1)}> Rio normal setRiverScale(2)}> Alto setRiverScale(3)}> Transbordando {error && riverScale == -1 && ( Selecione o nível do rio )} {/*Data da coleta:*/} setDateTime(value)} onTimeChange={(value) => setTime(value)} />
); } const dims = scaleDimsFromWidth(85, 85, 42); const styles = StyleSheet.create({ container: { padding: 10, backgroundColor: colors.white, }, img_block: { borderRadius: 5, padding: 10, borderStyle: "dotted", borderColor: colors.white, borderWidth: borderWidth, alignItems: "center", width: dims.width, }, floodingLogo: { width: dims.width * 0.8, height: dims.height * 0.8, }, imgs_row: { flexDirection: "row", justifyContent: "space-between", }, text: { fontSize: dimensions.text.default, textAlign: "center", marginTop: 10, }, error_txt: { fontSize: 18, color: colors.danger, }, }); export default RiverFloodSharingDataScreen;