Browse Source

Cleaning user location data from context on render form

master
GabrielTrettel 4 years ago
parent
commit
2485cb5d73
  1. 10
      src/app/screens/PluviometerSharingDataScreen.js
  2. 10
      src/app/screens/RainSharingDataScreen.js
  3. 12
      src/app/screens/RiverFloodSharingDataScreen.js
  4. 12
      src/app/screens/SharingFloodZonesScreen.js

10
src/app/screens/PluviometerSharingDataScreen.js

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useContext, useEffect } from "react";
import { StyleSheet, Text, View, ScrollView } from "react-native";
import * as Yup from "yup";
import {
@ -18,6 +18,7 @@ import colors from "../config/colors/";
import moment from "moment";
import FormLocationPicker from "../components/forms/FormLocationPicker";
import { TouchableOpacity } from "react-native-gesture-handler";
import { EventLocationContext } from "../context/EventLocationContext";
const dims = scaleDimsFromWidth(85, 85, 25);
@ -32,9 +33,12 @@ const validationSchema = Yup.object().shape({
});
function PluviometerSharingDataScreen(props) {
const location = useLocation();
global.eventCoordinates = useLocation();
const context = useContext(EventLocationContext);
useEffect(() => {
context.defaultLocation();
}, []);
const location = context.eventCoordinates;
const [dateTime, setDateTime] = useState(moment());
const [time, setTime] = useState(moment());

10
src/app/screens/RainSharingDataScreen.js

@ -21,7 +21,6 @@ import assets from "../config/assets";
import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker";
import { CurrentLocationContext } from "../context/CurrentLocationContext";
import { EventLocationContext } from "../context/EventLocationContext";
const validationSchema = Yup.object().shape({
@ -34,15 +33,14 @@ const borderWidth = 4;
function RainSharingDataScreen(props) {
const [rain, setRain] = useState(-1);
const [error, setError] = useState(false);
const location = "useLocation()";
const dims = scaleDimsFromWidth(85, 85, 27);
const dims = scaleDimsFromWidth(85, 85, 27);
const [date, setDate] = useState(moment());
const [time, setTime] = useState(moment());
//======== testei aqui pra ver se atualiza a localização pro default quando abre o formulário ===========
const context = useContext(EventLocationContext);
useEffect(() => {
@ -50,6 +48,8 @@ function RainSharingDataScreen(props) {
}, []);
//========================================================================================================
const location = context.eventCoordinates;
return (
<Screen style={styles.container}>
<ScrollView>

12
src/app/screens/RiverFloodSharingDataScreen.js

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState, useContext } from "react";
import { StyleSheet, View, TouchableOpacity } from "react-native";
import * as Yup from "yup";
@ -22,6 +22,7 @@ import { scaleDimsFromWidth, dimensions } from "../config/dimensions";
import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker";
import { EventLocationContext } from "../context/EventLocationContext";
const validationSchema = Yup.object().shape({
images: Yup.array(),
@ -32,7 +33,14 @@ const borderWidth = 4;
function RiverFloodSharingDataScreen(props) {
const [riverScale, setRiverScale] = useState(-1);
const location = "useLocation()";
const context = useContext(EventLocationContext);
useEffect(() => {
context.defaultLocation();
}, []);
const location = context.eventCoordinates;
const [error, setError] = useState(false);
const [date, setDate] = useState(moment());

12
src/app/screens/SharingFloodZonesScreen.js

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useContext, useEffect } from "react";
import { StyleSheet, Text, Image, View } from "react-native";
import * as Yup from "yup";
@ -19,6 +19,7 @@ import assets from "../config/assets";
import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker";
import { EventLocationContext } from "../context/EventLocationContext";
function submitForm(props) {
console.log(props);
@ -33,11 +34,16 @@ const validationSchema = Yup.object().shape({
function SharingFloodZonesScreen(props) {
const [passable, setPassable] = useState(-1);
const [error, setError] = useState(false);
const location = "useLocation()";
const [date, setDate] = useState(moment());
const [time, setTime] = useState(moment());
const context = useContext(EventLocationContext);
useEffect(() => {
context.defaultLocation();
}, []);
const location = context.eventCoordinates;
return (
<Screen style={styles.container}>
<KeyboardAwareScrollView

Loading…
Cancel
Save