forked from cemaden-educacao/WPD-MobileApp
analuizaff
4 years ago
9 changed files with 128 additions and 26 deletions
-
7src/App.js
-
18src/app/components/EventLocationInput.js
-
5src/app/components/forms/FormLocationPicker.js
-
4src/app/config/globals.js
-
22src/app/context/EventLocationContext.js
-
22src/app/hooks/getAddress.js
-
14src/app/screens/MapFeedScreen.js
-
50src/app/screens/MapFormScreen.js
-
4src/app/screens/PluviometerSharingDataScreen.js
@ -0,0 +1,18 @@ |
|||
import React, { useContext } from "react"; |
|||
import { EventLocationContext } from "../context/EventLocationContext"; |
|||
|
|||
import { Text } from "react-native"; |
|||
|
|||
const EventLocationInput = () => { |
|||
const context = useContext(EventLocationContext); |
|||
console.log("CONTEXTO: " + context.eventLocation); |
|||
|
|||
const data = context.eventLocation; |
|||
|
|||
return( |
|||
<Text> {context.eventLocation} </Text> |
|||
); |
|||
|
|||
} |
|||
|
|||
export default EventLocationInput; |
@ -1,2 +1,6 @@ |
|||
// FIXME: convert this to Context kkkkkkk
|
|||
global.userDataBase = undefined; |
|||
|
|||
//Endereço do evento
|
|||
global.eventAddress = " "; |
|||
global.eventCoordinates = undefined; |
@ -0,0 +1,22 @@ |
|||
import React, { useState, createContext } from "react" |
|||
|
|||
export const EventLocationContext = createContext(); |
|||
|
|||
const EventLocationProvider = ({ children }) => { |
|||
const [eventLocation, setEventLocation] = useState("endereço"); |
|||
|
|||
const saveNewLocation = (local) => { |
|||
setEventLocation(local); |
|||
console.log("NOVO LOCAL: " + local); |
|||
} |
|||
|
|||
return ( |
|||
<EventLocationContext.Provider value={{ |
|||
eventLocation, |
|||
saveNewLocation |
|||
}}> |
|||
{children} |
|||
</EventLocationContext.Provider> |
|||
) |
|||
} |
|||
export default EventLocationProvider; |
@ -0,0 +1,22 @@ |
|||
import React, { useEffect, useState } from "react"; |
|||
import * as Location from 'expo-location'; |
|||
|
|||
export default function getAddress(coordenadas) { |
|||
const [location, setLocation] = useState(coordenadas.x); |
|||
|
|||
const convert = async () => { |
|||
|
|||
Location.setGoogleApiKey("AIzaSyD_wuuokS3SVczc8qSASrsBq0E5qIpdyMc"); |
|||
|
|||
global.eventAddress = await Location.reverseGeocodeAsync(location); |
|||
console.log(global.eventAddress); |
|||
|
|||
global.eventCoordinates = coordenadas.x; |
|||
}; |
|||
|
|||
useEffect(() => { |
|||
convert(); |
|||
}, []); |
|||
|
|||
return location; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue