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

4
src/app/screens/RainSharingDataScreen.js

@ -21,7 +21,6 @@ import assets from "../config/assets";
import moment from "moment"; import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker"; import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker"; import FormLocationPicker from "../components/forms/FormLocationPicker";
import { CurrentLocationContext } from "../context/CurrentLocationContext";
import { EventLocationContext } from "../context/EventLocationContext"; import { EventLocationContext } from "../context/EventLocationContext";
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
@ -34,7 +33,6 @@ const borderWidth = 4;
function RainSharingDataScreen(props) { function RainSharingDataScreen(props) {
const [rain, setRain] = useState(-1); const [rain, setRain] = useState(-1);
const [error, setError] = useState(false); const [error, setError] = useState(false);
const location = "useLocation()";
const dims = scaleDimsFromWidth(85, 85, 27); const dims = scaleDimsFromWidth(85, 85, 27);
@ -50,6 +48,8 @@ function RainSharingDataScreen(props) {
}, []); }, []);
//======================================================================================================== //========================================================================================================
const location = context.eventCoordinates;
return ( return (
<Screen style={styles.container}> <Screen style={styles.container}>
<ScrollView> <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 { StyleSheet, View, TouchableOpacity } from "react-native";
import * as Yup from "yup"; import * as Yup from "yup";
@ -22,6 +22,7 @@ import { scaleDimsFromWidth, dimensions } from "../config/dimensions";
import moment from "moment"; import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker"; import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker"; import FormLocationPicker from "../components/forms/FormLocationPicker";
import { EventLocationContext } from "../context/EventLocationContext";
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
images: Yup.array(), images: Yup.array(),
@ -32,7 +33,14 @@ const borderWidth = 4;
function RiverFloodSharingDataScreen(props) { function RiverFloodSharingDataScreen(props) {
const [riverScale, setRiverScale] = useState(-1); 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 [error, setError] = useState(false);
const [date, setDate] = useState(moment()); 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 { StyleSheet, Text, Image, View } from "react-native";
import * as Yup from "yup"; import * as Yup from "yup";
@ -19,6 +19,7 @@ import assets from "../config/assets";
import moment from "moment"; import moment from "moment";
import FormDatePicker from "../components/forms/FormDatePicker"; import FormDatePicker from "../components/forms/FormDatePicker";
import FormLocationPicker from "../components/forms/FormLocationPicker"; import FormLocationPicker from "../components/forms/FormLocationPicker";
import { EventLocationContext } from "../context/EventLocationContext";
function submitForm(props) { function submitForm(props) {
console.log(props); console.log(props);
@ -33,11 +34,16 @@ const validationSchema = Yup.object().shape({
function SharingFloodZonesScreen(props) { function SharingFloodZonesScreen(props) {
const [passable, setPassable] = useState(-1); const [passable, setPassable] = useState(-1);
const [error, setError] = useState(false); const [error, setError] = useState(false);
const location = "useLocation()";
const [date, setDate] = useState(moment()); const [date, setDate] = useState(moment());
const [time, setTime] = useState(moment()); const [time, setTime] = useState(moment());
const context = useContext(EventLocationContext);
useEffect(() => {
context.defaultLocation();
}, []);
const location = context.eventCoordinates;
return ( return (
<Screen style={styles.container}> <Screen style={styles.container}>
<KeyboardAwareScrollView <KeyboardAwareScrollView

Loading…
Cancel
Save