Browse Source

Refactoring all uses of PickEventDateLocation

master
GabrielTrettel 3 years ago
parent
commit
456f87c6d5
  1. 7
      src/app/components/PickEventDateLocation.js
  2. 109
      src/app/screens/PluviometerRegisterScreen.js
  3. 6
      src/app/screens/PluviometerSharingDataScreen.js
  4. 2
      src/app/screens/RainSharingDataScreen.js
  5. 2
      src/app/screens/RiverFloodSharingDataScreen.js
  6. 2
      src/app/screens/SharingFloodZonesScreen.js

7
src/app/components/PickEventDateLocation.js

@ -8,7 +8,9 @@ import FormLocationPicker from "../components/forms/FormLocationPicker";
export default function PickEventDateLocation({ export default function PickEventDateLocation({
setDate = () => {}, setDate = () => {},
date = undefined,
setTime = () => {}, setTime = () => {},
time = undefined,
navigation = () => {}, navigation = () => {},
location = true, location = true,
}) { }) {
@ -21,7 +23,8 @@ export default function PickEventDateLocation({
}} }}
> >
<View <View
paddingBottom={24}>
// paddingBottom={24}
>
<FormDatePicker <FormDatePicker
textStyle={{ textStyle={{
borderColor: colors.gray, borderColor: colors.gray,
@ -29,7 +32,9 @@ export default function PickEventDateLocation({
}} }}
defaultDate={new Date()} defaultDate={new Date()}
onDateChange={(value) => setDate(value)} onDateChange={(value) => setDate(value)}
date={date}
onTimeChange={(value) => setTime(value)} onTimeChange={(value) => setTime(value)}
time={time}
/> />
</View> </View>
{location && ( {location && (

109
src/app/screens/PluviometerRegisterScreen.js

@ -1,9 +1,7 @@
import React, { useState, useContext, useEffect } from "react"; import React, { useState, useContext, useEffect } from "react";
import { StyleSheet, Text, View, ScrollView } from "react-native"; import { StyleSheet, Text, View, ScrollView } from "react-native";
import {
Form,
SubmitButton,
} from "../components/forms";
import { MaterialCommunityIcons, FontAwesome } from "@expo/vector-icons";
import { Form, SubmitButton } from "../components/forms";
import Screen from "../components/Screen"; 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";
@ -14,8 +12,7 @@ import FormLocationPicker from "../components/forms/FormLocationPicker";
import { EventLocationContext } from "../context/EventLocationContext"; import { EventLocationContext } from "../context/EventLocationContext";
import SchoolPicker from "../components/SchoolPicker"; import SchoolPicker from "../components/SchoolPicker";
import { TouchableOpacity } from "react-native-gesture-handler"; import { TouchableOpacity } from "react-native-gesture-handler";
import DatePicker from "../components/DatePicker";
const dims = scaleDimsFromWidth(85, 85, 25); const dims = scaleDimsFromWidth(85, 85, 25);
@ -28,104 +25,76 @@ function PluviometerRegisterScreen(props) {
const location = context.eventCoordinates; const location = context.eventCoordinates;
const address = context.eventLocation; const address = context.eventLocation;
const [dateTime, setDateTime] = useState(moment());
const [date, setDate] = useState(moment());
const [time, setTime] = useState(moment());
const [school, setSchool] = useState(); const [school, setSchool] = useState();
return ( return (
<Screen style={styles.container}>
<View style={styles.container}>
<Form <Form
initialValues={{
}}
initialValues={{}}
onSubmit={() => { onSubmit={() => {
//insertRainData({ ...values, rain, location, date, time, address });
showMessage({ showMessage({
message: "Ainda não implementado", message: "Ainda não implementado",
duration: 1950, duration: 1950,
icon: "warning", icon: "warning",
type: "warning", type: "warning",
onPress: () => { },
onPress: () => {},
}); });
//props.navigation.navigate("Home");
}}>
}}
>
<View <View
style={{ style={{
flexDirection: "column",
alignContent: "flex-start", alignContent: "flex-start",
justifyContent: "space-evenly",
flex: 1
}} }}
> >
<View style={{ flex: 0.10 }}>
<Text style={styles.title}>Cadastro do Pluviômetro</Text> <Text style={styles.title}>Cadastro do Pluviômetro</Text>
</View>
{/* Escola: */}
<View style={{ flex: 0.25, marginTop: 5}}>
<Text style={styles.label}>Escola: </Text>
<SchoolPicker
itemSelected={(value) => setSchool(value)} />
</View>
<View style={{
flex: 0.60, flexDirection: "column"
}}>
<ScrollView contentContainerStyle={{
flexGrow: 1
}}>
<View style={{
flex: 1,
flexDirection: "column",
justifyContent: "space-between"
}}>
{/*Local do pluvioômetro:*/}
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => props.navigation.navigate("FormMap")}>
<View style={{ flex: 1 }}>
<Text style={styles.label}>Endereço do pluviômetro: </Text>
<FormLocationPicker subtitle="Defina o endereço do pluviômetro" />
</View>
</TouchableOpacity>
</View>
{/*Data de cadastro:*/}
<View style={{ flex: 1 }}>
<Text style={{
<View>
<Text
style={{
marginTop: 24,
fontSize: dimensions.text.secondary, fontSize: dimensions.text.secondary,
fontWeight: "bold", fontWeight: "bold",
textAlign: "left", textAlign: "left",
color: colors.lightBlue,
}}>Data do cadastro: </Text>
<FormDatePicker
disabled={true}
textStyle={{
borderColor: colors.gray,
borderWidth: 3,
color: colors.primary,
}} }}
subtitle=" "
defaultDate={new Date()}
onDateChange={(value) => setDateTime(value)}
>
Data do cadastro:{" "}
</Text>
<FormDatePicker
onDateChange={(value) => setDate(value)}
onTimeChange={(value) => setTime(value)} onTimeChange={(value) => setTime(value)}
date={date}
time={time}
/> />
</View> </View>
<View style={{ flex: 0.05, marginTop: 15 }}>
{/* <View style={{ marginTop: 5 }}> */}
{/* <Text style={styles.label}>Escola: </Text> */}
{/* <SchoolPicker itemSelected={(value) => setSchool(value)} /> */}
{/* </View> */}
{/* <TouchableOpacity */}
{/* onPress={() => props.navigation.navigate("FormMap")} */}
{/* > */}
{/* <View> */}
{/* <Text style={styles.label}>Endereço do pluviômetro: </Text> */}
{/* <FormLocationPicker subtitle="Defina o endereço do pluviômetro" /> */}
{/* </View> */}
{/* </TouchableOpacity> */}
<SubmitButton title="Cadastrar" alignContent="flex-end" /> <SubmitButton title="Cadastrar" alignContent="flex-end" />
</View> </View>
</View>
</ScrollView>
</View>
</View>
</Form> </Form>
</Screen>
</View>
); );
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
padding: 10, padding: 10,
flex: 1
}, },
image: { image: {
width: dims.width * 0.8, width: dims.width * 0.8,
@ -140,7 +109,7 @@ const styles = StyleSheet.create({
color: colors.lightBlue, color: colors.lightBlue,
}, },
title: { title: {
fontSize: 20,
fontSize: 16,
fontWeight: "bold", fontWeight: "bold",
textAlign: "center", textAlign: "center",
color: colors.primary, color: colors.primary,

6
src/app/screens/PluviometerSharingDataScreen.js

@ -27,7 +27,7 @@ const validationSchema = Yup.object().shape({
function PluviometerSharingDataScreen(props) { function PluviometerSharingDataScreen(props) {
const context = useContext(EventLocationContext); const context = useContext(EventLocationContext);
const [dateTime, setDateTime] = useState(moment());
const [date, setDate] = useState(moment());
const [time, setTime] = useState(moment()); const [time, setTime] = useState(moment());
useEffect(() => { useEffect(() => {
@ -71,7 +71,9 @@ function PluviometerSharingDataScreen(props) {
<FormImagePicker backgroundColor={colors.primary} name="images" /> <FormImagePicker backgroundColor={colors.primary} name="images" />
<PickEventDateLocation <PickEventDateLocation
setDate={setDateTime}
date={date}
time={time}
setDate={setDate}
setTime={setTime} setTime={setTime}
navigation={props.navigation} navigation={props.navigation}
location={false} location={false}

2
src/app/screens/RainSharingDataScreen.js

@ -115,6 +115,8 @@ function RainSharingDataScreen(props) {
<FormImagePicker backgroundColor={colors.primary} name="images" /> <FormImagePicker backgroundColor={colors.primary} name="images" />
<PickEventDateLocation <PickEventDateLocation
date={date}
time={time}
setDate={setDate} setDate={setDate}
setTime={setTime} setTime={setTime}
navigation={props.navigation} navigation={props.navigation}

2
src/app/screens/RiverFloodSharingDataScreen.js

@ -127,6 +127,8 @@ function RiverFloodSharingDataScreen(props) {
<FormImagePicker backgroundColor={colors.primary} name="images" /> <FormImagePicker backgroundColor={colors.primary} name="images" />
<PickEventDateLocation <PickEventDateLocation
date={date}
time={time}
setDate={setDate} setDate={setDate}
setTime={setTime} setTime={setTime}
navigation={props.navigation} navigation={props.navigation}

2
src/app/screens/SharingFloodZonesScreen.js

@ -93,6 +93,8 @@ function SharingFloodZonesScreen(props) {
<FormImagePicker name="images" height={10} /> <FormImagePicker name="images" height={10} />
<PickEventDateLocation <PickEventDateLocation
date={date}
time={time}
setDate={setDate} setDate={setDate}
setTime={setTime} setTime={setTime}
navigation={props.navigation} navigation={props.navigation}

Loading…
Cancel
Save