|
|
@ -1,5 +1,5 @@ |
|
|
|
import React, { useState, useContext, useEffect } from "react"; |
|
|
|
import { StyleSheet, Text, View, ScrollView, PixelRatio, SafeAreaView } from "react-native"; |
|
|
|
import { StyleSheet, Text, View, ScrollView, PixelRatio, SafeAreaView, KeyboardAvoidingView, Platform } from "react-native"; |
|
|
|
import * as Yup from "yup"; |
|
|
|
import { |
|
|
|
Form, |
|
|
@ -17,9 +17,11 @@ import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
|
import colors from "../config/colors/"; |
|
|
|
import moment from "moment"; |
|
|
|
import FormLocationPicker from "../components/forms/FormLocationPicker"; |
|
|
|
import { TouchableOpacity } from "react-native-gesture-handler"; |
|
|
|
import { TextInput, TouchableOpacity } from "react-native-gesture-handler"; |
|
|
|
import { EventLocationContext } from "../context/EventLocationContext"; |
|
|
|
import SchoolPicker from "../components/SchoolPicker"; |
|
|
|
import { KeyboardAwareFlatList, KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dims = scaleDimsFromWidth(85, 85, 25); |
|
|
@ -27,69 +29,79 @@ const dims = scaleDimsFromWidth(85, 85, 25); |
|
|
|
function PluviometerRegisterScreen(props) { |
|
|
|
const context = useContext(EventLocationContext); |
|
|
|
|
|
|
|
const amount = 2; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
context.defaultLocation(); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const location = context.eventCoordinates; |
|
|
|
const address = context.eventLocation; |
|
|
|
|
|
|
|
const [dateTime, setDateTime] = useState(moment()); |
|
|
|
const [time, setTime] = useState(moment()); |
|
|
|
const [school, setSchool] = useState(); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Screen style={styles.container}> |
|
|
|
<Form> |
|
|
|
<View style={{ flex: 1 }}> |
|
|
|
<View |
|
|
|
style={{ |
|
|
|
flex: 1, |
|
|
|
flexDirection: "column", |
|
|
|
justifyContent: "space-between", |
|
|
|
alignContent: "flex-start", |
|
|
|
}} |
|
|
|
<Form |
|
|
|
initialValues={{ |
|
|
|
|
|
|
|
> |
|
|
|
}} |
|
|
|
onSubmit={() => { |
|
|
|
//insertRainData({ ...values, rain, location, date, time, address });
|
|
|
|
showMessage({ |
|
|
|
message: "Ainda não implementado", |
|
|
|
duration: 1950, |
|
|
|
icon: "warning", |
|
|
|
type: "warning", |
|
|
|
onPress: () => { }, |
|
|
|
}); |
|
|
|
//props.navigation.navigate("Home");
|
|
|
|
}}> |
|
|
|
|
|
|
|
<View style={{ flex: 1 }}> |
|
|
|
<Text style={styles.title}> Cadastro do Pluviômetro </Text> |
|
|
|
</View> |
|
|
|
{/*Data da coleta:*/} |
|
|
|
|
|
|
|
<View |
|
|
|
style={{ flex: 2 }} |
|
|
|
> |
|
|
|
<Text style={styles.label}> Data do cadastro: </Text> |
|
|
|
<View |
|
|
|
style={{ |
|
|
|
flexDirection: "column", |
|
|
|
justifyContent: "space-between", |
|
|
|
alignContent: "flex-start", |
|
|
|
flex: 0.9, |
|
|
|
}} |
|
|
|
> |
|
|
|
<View style={{ flex: 0.8 }}> |
|
|
|
<Text style={styles.title}> Cadastro do Pluviômetro </Text> |
|
|
|
</View> |
|
|
|
<View style={{ flex: 2 }}> |
|
|
|
<Text style={styles.label}>Escola: </Text> |
|
|
|
<SchoolPicker |
|
|
|
itemSelected={(value) => setSchool(value)} /> |
|
|
|
</View> |
|
|
|
|
|
|
|
<FormDatePicker |
|
|
|
textStyle={{ |
|
|
|
borderColor: colors.gray, |
|
|
|
borderWidth: 3, |
|
|
|
}} |
|
|
|
defaultDate={new Date()} |
|
|
|
onDateChange={(value) => setDateTime(value)} |
|
|
|
onTimeChange={(value) => setTime(value)} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
<View style={{ flex: 2 }}> |
|
|
|
{/*Local do evento:*/} |
|
|
|
<View style={{ flex: 2 }}> |
|
|
|
<ScrollView> |
|
|
|
<Text style={styles.label}> Endereço do pluviômetro: </Text> |
|
|
|
<TouchableOpacity |
|
|
|
onPress={() => props.navigation.navigate("FormMap")} |
|
|
|
> |
|
|
|
<FormLocationPicker /> |
|
|
|
</TouchableOpacity> |
|
|
|
</ScrollView> |
|
|
|
</View> |
|
|
|
<View style={{ flex: 4 }}> |
|
|
|
<Text style={styles.label}> Escola: </Text> |
|
|
|
<SchoolPicker /> |
|
|
|
</View> |
|
|
|
<Text style={styles.label}>Endereço do pluviômetro: </Text> |
|
|
|
<ScrollView> |
|
|
|
<FormLocationPicker subtitle="Defina o endereço do pluviômetro" /> |
|
|
|
</ScrollView> |
|
|
|
</View> |
|
|
|
{/*Data da coleta:*/} |
|
|
|
<View style={{ flex: 2 }}> |
|
|
|
<Text style={{ |
|
|
|
fontSize: dimensions.text.secondary, |
|
|
|
fontWeight: "bold", |
|
|
|
textAlign: "left", |
|
|
|
color: colors.lightBlue, marginBottom: 10 |
|
|
|
}}>Data do cadastro: </Text> |
|
|
|
<FormDatePicker |
|
|
|
disabled={true} |
|
|
|
textStyle={{ |
|
|
|
borderColor: colors.gray, |
|
|
|
borderWidth: 3, |
|
|
|
}} |
|
|
|
subtitle=" " |
|
|
|
defaultDate={new Date()} |
|
|
|
onDateChange={(value) => setDateTime(value)} |
|
|
|
onTimeChange={(value) => setTime(value)} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
<SubmitButton title="Enviar" style={{ marginBottom: 100 }} /> |
|
|
|
</View> |
|
|
|
<SubmitButton title="Cadastrar" style={{ marginBottom: 100 }} /> |
|
|
|
</Form> |
|
|
|
</Screen> |
|
|
|
); |
|
|
@ -98,7 +110,7 @@ function PluviometerRegisterScreen(props) { |
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
padding: 10, |
|
|
|
flex: 1, |
|
|
|
flex: 1 |
|
|
|
}, |
|
|
|
image: { |
|
|
|
width: dims.width * 0.8, |
|
|
|