From 456f87c6d556c1c527d5279787206c08039fefca Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Thu, 9 Sep 2021 15:18:12 -0300 Subject: [PATCH] Refactoring all uses of PickEventDateLocation --- src/app/components/PickEventDateLocation.js | 7 +- src/app/screens/PluviometerRegisterScreen.js | 209 ++++++++---------- .../screens/PluviometerSharingDataScreen.js | 6 +- src/app/screens/RainSharingDataScreen.js | 2 + .../screens/RiverFloodSharingDataScreen.js | 2 + src/app/screens/SharingFloodZonesScreen.js | 2 + 6 files changed, 105 insertions(+), 123 deletions(-) diff --git a/src/app/components/PickEventDateLocation.js b/src/app/components/PickEventDateLocation.js index ce524b3..7f56ec2 100644 --- a/src/app/components/PickEventDateLocation.js +++ b/src/app/components/PickEventDateLocation.js @@ -8,7 +8,9 @@ import FormLocationPicker from "../components/forms/FormLocationPicker"; export default function PickEventDateLocation({ setDate = () => {}, + date = undefined, setTime = () => {}, + time = undefined, navigation = () => {}, location = true, }) { @@ -21,7 +23,8 @@ export default function PickEventDateLocation({ }} > + // paddingBottom={24} + > setDate(value)} + date={date} onTimeChange={(value) => setTime(value)} + time={time} /> {location && ( diff --git a/src/app/screens/PluviometerRegisterScreen.js b/src/app/screens/PluviometerRegisterScreen.js index 338b265..bd5fb3e 100644 --- a/src/app/screens/PluviometerRegisterScreen.js +++ b/src/app/screens/PluviometerRegisterScreen.js @@ -1,9 +1,7 @@ import React, { useState, useContext, useEffect } from "react"; 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 { showMessage } from "react-native-flash-message"; import { dimensions, scaleDimsFromWidth } from "../config/dimensions"; @@ -14,137 +12,108 @@ import FormLocationPicker from "../components/forms/FormLocationPicker"; import { EventLocationContext } from "../context/EventLocationContext"; import SchoolPicker from "../components/SchoolPicker"; import { TouchableOpacity } from "react-native-gesture-handler"; - - +import DatePicker from "../components/DatePicker"; const dims = scaleDimsFromWidth(85, 85, 25); function PluviometerRegisterScreen(props) { - const context = useContext(EventLocationContext); - - useEffect(() => { - context.defaultLocation(); - }, []); + const context = useContext(EventLocationContext); - const location = context.eventCoordinates; - const address = context.eventLocation; - const [dateTime, setDateTime] = useState(moment()); - const [school, setSchool] = useState(); + useEffect(() => { + context.defaultLocation(); + }, []); - return ( - -
{ - //insertRainData({ ...values, rain, location, date, time, address }); - showMessage({ - message: "Ainda não implementado", - duration: 1950, - icon: "warning", - type: "warning", - onPress: () => { }, - }); - //props.navigation.navigate("Home"); - }}> + return ( + + { + showMessage({ + message: "Ainda não implementado", + duration: 1950, + icon: "warning", + type: "warning", + onPress: () => {}, + }); + }} + > + + Cadastro do Pluviômetro - - - Cadastro do Pluviômetro - + + + Data do cadastro:{" "} + - {/* Escola: */} - - Escola: - setSchool(value)} /> - + setDate(value)} + onTimeChange={(value) => setTime(value)} + date={date} + time={time} + /> + - - - - {/*Local do pluvioômetro:*/} - - props.navigation.navigate("FormMap")}> - - Endereço do pluviômetro: - - - - + {/* */} + {/* Escola: */} + {/* setSchool(value)} /> */} + {/* */} - {/*Data de cadastro:*/} - - Data do cadastro: - setDateTime(value)} - onTimeChange={(value) => setTime(value)} - /> - + {/* props.navigation.navigate("FormMap")} */} + {/* > */} + {/* */} + {/* Endereço do pluviômetro: */} + {/* */} + {/* */} + {/* */} - - - - - - - - -
- ); + + + + + ); } const styles = StyleSheet.create({ - container: { - padding: 10, - flex: 1 - }, - image: { - width: dims.width * 0.8, - height: dims.height * 0.8, - justifyContent: "center", - alignItems: "center", - }, - label: { - fontSize: dimensions.text.secondary, - fontWeight: "bold", - textAlign: "left", - color: colors.lightBlue, - }, - title: { - fontSize: 20, - fontWeight: "bold", - textAlign: "center", - color: colors.primary, - }, + container: { + padding: 10, + }, + image: { + width: dims.width * 0.8, + height: dims.height * 0.8, + justifyContent: "center", + alignItems: "center", + }, + label: { + fontSize: dimensions.text.secondary, + fontWeight: "bold", + textAlign: "left", + color: colors.lightBlue, + }, + title: { + fontSize: 16, + fontWeight: "bold", + textAlign: "center", + color: colors.primary, + }, }); export default PluviometerRegisterScreen; diff --git a/src/app/screens/PluviometerSharingDataScreen.js b/src/app/screens/PluviometerSharingDataScreen.js index cfaedc7..0ff6374 100644 --- a/src/app/screens/PluviometerSharingDataScreen.js +++ b/src/app/screens/PluviometerSharingDataScreen.js @@ -27,7 +27,7 @@ const validationSchema = Yup.object().shape({ function PluviometerSharingDataScreen(props) { const context = useContext(EventLocationContext); - const [dateTime, setDateTime] = useState(moment()); + const [date, setDate] = useState(moment()); const [time, setTime] = useState(moment()); useEffect(() => { @@ -71,7 +71,9 @@ function PluviometerSharingDataScreen(props) {