|
@ -1,41 +1,98 @@ |
|
|
import React, { useState, useContext, useEffect } from "react"; |
|
|
|
|
|
import { StyleSheet, Text, View, ScrollView } from "react-native"; |
|
|
|
|
|
import { MaterialCommunityIcons, FontAwesome } from "@expo/vector-icons"; |
|
|
|
|
|
|
|
|
import React, { useState, useContext } from "react"; |
|
|
|
|
|
import { MaterialIcons } from "@expo/vector-icons"; |
|
|
|
|
|
import { StyleSheet, Text, View } from "react-native"; |
|
|
import { Form, SubmitButton } from "../components/forms"; |
|
|
import { Form, SubmitButton } from "../components/forms"; |
|
|
import Screen from "../components/Screen"; |
|
|
|
|
|
import { showMessage } from "react-native-flash-message"; |
|
|
import { showMessage } from "react-native-flash-message"; |
|
|
import { dimensions, scaleDimsFromWidth } from "../config/dimensions"; |
|
|
import { dimensions, scaleDimsFromWidth } from "../config/dimensions"; |
|
|
import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
import FormDatePicker from "../components/forms/FormDatePicker"; |
|
|
import colors from "../config/colors/"; |
|
|
import colors from "../config/colors/"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
import FormLocationPicker from "../components/forms/FormLocationPicker"; |
|
|
|
|
|
import { EventLocationContext } from "../context/EventLocationContext"; |
|
|
|
|
|
import SchoolPicker from "../components/SchoolPicker"; |
|
|
|
|
|
import { TouchableOpacity } from "react-native-gesture-handler"; |
|
|
import { TouchableOpacity } from "react-native-gesture-handler"; |
|
|
import DatePicker from "../components/DatePicker"; |
|
|
|
|
|
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; |
|
|
|
|
|
|
|
|
import { FontAwesome5 } from "@expo/vector-icons"; |
|
|
|
|
|
import { AuthContext } from "../auth/context"; |
|
|
|
|
|
import { Shadow } from "react-native-shadow-2"; |
|
|
|
|
|
|
|
|
const dims = scaleDimsFromWidth(85, 85, 25); |
|
|
const dims = scaleDimsFromWidth(85, 85, 25); |
|
|
|
|
|
|
|
|
function PluviometerRegisterScreen(props) { |
|
|
|
|
|
const context = useContext(EventLocationContext); |
|
|
|
|
|
|
|
|
function Institution({ user }) { |
|
|
|
|
|
return ( |
|
|
|
|
|
<View style={{ marginTop: 24, marginBottom: 24 }}> |
|
|
|
|
|
<Text style={styles.label}>Tippo de instituição: </Text> |
|
|
|
|
|
<View style={{ flexDirection: "row", marginTop: 16 }}> |
|
|
|
|
|
<FontAwesome5 name="university" size={30} color={colors.primary} /> |
|
|
|
|
|
<Text style={styles.subText}>{user.institutionType}</Text> |
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
context.defaultLocation(); |
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
<Text style={[styles.label, { marginTop: 24 }]}> |
|
|
|
|
|
Nome da instituição: |
|
|
|
|
|
</Text> |
|
|
|
|
|
<View style={{ flexDirection: "row" }}> |
|
|
|
|
|
<FontAwesome5 name="university" size={30} color={colors.primary} /> |
|
|
|
|
|
<Text style={styles.subText}>{user.institutionName}</Text> |
|
|
|
|
|
</View> |
|
|
|
|
|
</View> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const location = context.eventCoordinates; |
|
|
|
|
|
const address = context.eventLocation; |
|
|
|
|
|
const [date, setDate] = useState(moment()); |
|
|
|
|
|
const [time, setTime] = useState(moment()); |
|
|
|
|
|
const [school, setSchool] = useState(); |
|
|
|
|
|
|
|
|
function LocationPicker({ navigation }) { |
|
|
|
|
|
const [location, setLocationAddr] = useState("Defina o endereço no mapa"); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<View |
|
|
<View |
|
|
style={{ |
|
|
style={{ |
|
|
padding: 16, |
|
|
|
|
|
|
|
|
flexDirection: "row", |
|
|
|
|
|
alignItems: "center", |
|
|
|
|
|
flexShrink: 1, |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<MaterialIcons name="location-on" size={30} color={colors.primary} /> |
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
marginLeft: 16, |
|
|
|
|
|
flex: 1, |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
|
|
|
<Shadow |
|
|
|
|
|
viewStyle={{ width: "100%", height: 48 }} |
|
|
|
|
|
offset={[0, 4]} |
|
|
|
|
|
distance={4} |
|
|
|
|
|
radius={4} |
|
|
|
|
|
startColor="rgba(0, 0, 0, 0.25)" |
|
|
|
|
|
paintInside={true} |
|
|
|
|
|
> |
|
|
|
|
|
<TouchableOpacity |
|
|
|
|
|
onPress={() => |
|
|
|
|
|
navigation.navigate("FormMap", { |
|
|
|
|
|
setLocationAddr: setLocationAddr, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
> |
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
paddingLeft: 16, |
|
|
|
|
|
backgroundColor: colors.white, |
|
|
|
|
|
height: 48, |
|
|
|
|
|
borderRadius: 5, |
|
|
|
|
|
flexDirection: "row", |
|
|
|
|
|
alignItems: "center", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<Text styles={styles.subText}>{location}</Text> |
|
|
|
|
|
</View> |
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
|
</Shadow> |
|
|
|
|
|
</View> |
|
|
|
|
|
</View> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function PluviometerRegisterScreen(props) { |
|
|
|
|
|
const [date, setDate] = useState(moment()); |
|
|
|
|
|
const [time, setTime] = useState(moment()); |
|
|
|
|
|
const { user, _ } = useContext(AuthContext); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
<View> |
|
|
<Form |
|
|
<Form |
|
|
initialValues={{}} |
|
|
initialValues={{}} |
|
|
onSubmit={() => { |
|
|
onSubmit={() => { |
|
@ -48,21 +105,13 @@ function PluviometerRegisterScreen(props) { |
|
|
}); |
|
|
}); |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
{/* <KeyboardAwareScrollView */} |
|
|
|
|
|
{/* keyboardShouldPersistTaps={"handled"} */} |
|
|
|
|
|
{/* > */} |
|
|
|
|
|
<View |
|
|
|
|
|
style={{ |
|
|
|
|
|
height: "100%", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
<View padding={16}> |
|
|
<Text style={styles.title}>Cadastro do Pluviômetro</Text> |
|
|
<Text style={styles.title}>Cadastro do Pluviômetro</Text> |
|
|
|
|
|
|
|
|
<View> |
|
|
|
|
|
<Text |
|
|
<Text |
|
|
style={{ |
|
|
style={{ |
|
|
marginTop: 24, |
|
|
marginTop: 24, |
|
|
marginBottom: 12, |
|
|
|
|
|
|
|
|
marginBottom: 16, |
|
|
fontSize: dimensions.text.secondary, |
|
|
fontSize: dimensions.text.secondary, |
|
|
fontWeight: "bold", |
|
|
fontWeight: "bold", |
|
|
textAlign: "left", |
|
|
textAlign: "left", |
|
@ -74,7 +123,7 @@ function PluviometerRegisterScreen(props) { |
|
|
|
|
|
|
|
|
<View |
|
|
<View |
|
|
style={{ |
|
|
style={{ |
|
|
marginBottom: 24 |
|
|
|
|
|
|
|
|
marginBottom: 24, |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<FormDatePicker |
|
|
<FormDatePicker |
|
@ -86,24 +135,13 @@ function PluviometerRegisterScreen(props) { |
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
<TouchableOpacity |
|
|
|
|
|
onPress={() => props.navigation.navigate("FormMap")} |
|
|
|
|
|
> |
|
|
|
|
|
<View> |
|
|
|
|
|
<Text style={styles.label}>Endereço do pluviômetro*: </Text> |
|
|
<Text style={styles.label}>Endereço do pluviômetro*: </Text> |
|
|
<FormLocationPicker subtitle="Defina o endereço do pluviômetro" /> |
|
|
|
|
|
</View> |
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
|
|
|
|
<LocationPicker navigation={props.navigation} /> |
|
|
|
|
|
|
|
|
<View style={{ marginTop: 24, marginBottom: 12 }}> |
|
|
|
|
|
<Text style={styles.label}>Instituição: </Text> |
|
|
|
|
|
<SchoolPicker itemSelected={(value) => setSchool(value)} /> |
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
{user.institutionType && <Institution user={user} />} |
|
|
|
|
|
|
|
|
<SubmitButton title="Cadastrar" paddingHorizontal={0} /> |
|
|
<SubmitButton title="Cadastrar" paddingHorizontal={0} /> |
|
|
</View> |
|
|
</View> |
|
|
{/* </KeyboardAwareScrollView> */} |
|
|
|
|
|
</View> |
|
|
|
|
|
</Form> |
|
|
</Form> |
|
|
</View> |
|
|
</View> |
|
|
); |
|
|
); |
|
@ -123,6 +161,13 @@ const styles = StyleSheet.create({ |
|
|
textAlign: "left", |
|
|
textAlign: "left", |
|
|
color: colors.secondary, |
|
|
color: colors.secondary, |
|
|
}, |
|
|
}, |
|
|
|
|
|
subText: { |
|
|
|
|
|
color: colors.subText, |
|
|
|
|
|
fontSize: 16, |
|
|
|
|
|
alignSelf: "center", |
|
|
|
|
|
fontWeight: "500", |
|
|
|
|
|
paddingLeft: 16, |
|
|
|
|
|
}, |
|
|
title: { |
|
|
title: { |
|
|
fontSize: 18, |
|
|
fontSize: 18, |
|
|
fontWeight: "bold", |
|
|
fontWeight: "bold", |
|
|