Browse Source

Fixing hard-coded variables and setting location zoom

master
GabrielTrettel 3 years ago
parent
commit
1f4e0c105a
  1. 4
      src/App.js
  2. 2
      src/app/components/map/OpenStreetMap.js
  3. 1
      src/app/config/globals.js
  4. 12
      src/app/screens/MapFeedScreen.js

4
src/App.js

@ -49,7 +49,7 @@ export default function App() {
const storageUser = await authStorage.getUser(); const storageUser = await authStorage.getUser();
if (storageUser) setUser(storageUser); if (storageUser) setUser(storageUser);
global.location = { lat: -9.97111566376452, long: -67.80984283755332 }; //await getLocation();
global.location = await getLocation();
}; };
if (!isReady && netInfo.isInternetReachable) { if (!isReady && netInfo.isInternetReachable) {
@ -61,7 +61,7 @@ export default function App() {
/> />
); );
} else if (netInfo.isInternetReachable) { } else if (netInfo.isInternetReachable) {
global.formsSockets = useFiltering(global.location);
global.formsSockets = useFiltering(global.location || global.defaultLocation);
return ( return (
<AuthContext.Provider <AuthContext.Provider

2
src/app/components/map/OpenStreetMap.js

@ -49,7 +49,7 @@ export default function OpenStreetMap({
const [mapRef, setMapRef] = useState(null); const [mapRef, setMapRef] = useState(null);
const webviewContent = html_content; const webviewContent = html_content;
const [markerListener, setMarkerListener] = useState(null); const [markerListener, setMarkerListener] = useState(null);
const viewFunction = setViewCode(global.location.lat, global.location.long);
const viewFunction = setViewCode(global.location.lat, global.location.long, global.location.zoom);
const markersList = MapMarkerList({ const markersList = MapMarkerList({
markers: markers, markers: markers,

1
src/app/config/globals.js

@ -2,6 +2,7 @@
global.userDataBase = undefined; global.userDataBase = undefined;
global.location = undefined; global.location = undefined;
global.formsSockets = undefined; global.formsSockets = undefined;
global.defaultLocation = { lat: -9.97111566376452, long: -54.80984283755332, zoom: 3 }
//Endereço do evento //Endereço do evento
//global.eventAddress = " "; //global.eventAddress = " ";
//global.eventCoordinates = undefined; //global.eventCoordinates = undefined;

12
src/app/screens/MapFeedScreen.js

@ -1,5 +1,5 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { StyleSheet, View } from "react-native";
import { StyleSheet, View, Text } from "react-native";
import OpenStreetMap from "../components/map/OpenStreetMap"; import OpenStreetMap from "../components/map/OpenStreetMap";
import attachFocusToQuery from "../hooks/useFocus"; import attachFocusToQuery from "../hooks/useFocus";
import HeaderBarMenu from "../components/HeaderBarMenu"; import HeaderBarMenu from "../components/HeaderBarMenu";
@ -9,8 +9,6 @@ import LoadingMarkersModal from "../components/LoadingMarkersModal";
export default function MapFeedScreen(props) { export default function MapFeedScreen(props) {
HeaderBarMenu(props.navigation); HeaderBarMenu(props.navigation);
const focusChanged = attachFocusToQuery();
const [dataOptionsToShow, setDataOptionsToShow] = useState({ const [dataOptionsToShow, setDataOptionsToShow] = useState({
oficial: { oficial: {
automaticPluviometer: false, automaticPluviometer: false,
@ -26,8 +24,11 @@ export default function MapFeedScreen(props) {
}); });
const markers = useSocketMarkers(); const markers = useSocketMarkers();
console.log("============= qtd markers " + markers.markers.size + " ================" )
// console.log("location: " + JSON.stringify(global.location))
return ( return (
(global.location) ? (
<View style={styles.container}> <View style={styles.container}>
<OpenStreetMap <OpenStreetMap
markers={markers} markers={markers}
@ -38,6 +39,11 @@ export default function MapFeedScreen(props) {
<LoadingMarkersModal <LoadingMarkersModal
show={markers.markers.size <= 0}/> show={markers.markers.size <= 0}/>
</View> </View>
):(
<View>
<Text>Apresentar um erro no futuro</Text>
</View>
)
); );
} }

Loading…
Cancel
Save