|
@@ -7,7 +7,8 @@ import {
|
|
|
TouchableOpacity,
|
|
|
View,
|
|
|
Image,
|
|
|
- StatusBar
|
|
|
+ StatusBar,
|
|
|
+ ActivityIndicator
|
|
|
} from 'react-native';
|
|
|
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
|
|
|
@@ -319,6 +320,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
const [isEditSlowModalVisible, setIsEditSlowModalVisible] = useState<boolean>(false);
|
|
|
const [isEditModalVisible, setIsEditModalVisible] = useState(false);
|
|
|
const [isFilterVisible, setIsFilterVisible] = useState(false);
|
|
|
+ const [isLocationLoading, setIsLocationLoading] = useState(false);
|
|
|
|
|
|
const [modalState, setModalState] = useState({
|
|
|
selectedFirstYear: 2021,
|
|
@@ -800,14 +802,19 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
};
|
|
|
|
|
|
const handleGetLocation = async () => {
|
|
|
- let { status, canAskAgain } = await Location.getForegroundPermissionsAsync();
|
|
|
+ setIsLocationLoading(true);
|
|
|
+ try {
|
|
|
+ let { status, canAskAgain } = await Location.getForegroundPermissionsAsync();
|
|
|
|
|
|
- if (status === 'granted') {
|
|
|
- getLocation();
|
|
|
- } else if (!canAskAgain) {
|
|
|
- setOpenSettingsVisible(true);
|
|
|
- } else {
|
|
|
- setAskLocationVisible(true);
|
|
|
+ if (status === 'granted') {
|
|
|
+ await getLocation();
|
|
|
+ } else if (!canAskAgain) {
|
|
|
+ setOpenSettingsVisible(true);
|
|
|
+ } else {
|
|
|
+ setAskLocationVisible(true);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ setIsLocationLoading(false);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -817,6 +824,13 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
});
|
|
|
setLocation(currentLocation.coords);
|
|
|
|
|
|
+ if (currentLocation.coords) {
|
|
|
+ cameraRef.current?.flyTo(
|
|
|
+ [currentLocation.coords.longitude, currentLocation.coords.latitude],
|
|
|
+ 1000
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
if (showNomads && token) {
|
|
|
updateLocation({
|
|
|
token,
|
|
@@ -826,12 +840,6 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
refetchUsersLocation();
|
|
|
}
|
|
|
- if (currentLocation.coords) {
|
|
|
- cameraRef.current?.flyTo(
|
|
|
- [currentLocation.coords.longitude, currentLocation.coords.latitude],
|
|
|
- 1000
|
|
|
- );
|
|
|
- }
|
|
|
|
|
|
handleClosePopup();
|
|
|
};
|
|
@@ -1329,7 +1337,11 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
onPress={handleGetLocation}
|
|
|
style={[styles.cornerButton, styles.topRightButton, styles.bottomButton]}
|
|
|
>
|
|
|
- <LocationIcon />
|
|
|
+ {isLocationLoading ? (
|
|
|
+ <ActivityIndicator size="small" color={Colors.DARK_BLUE} />
|
|
|
+ ) : (
|
|
|
+ <LocationIcon />
|
|
|
+ )}
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
<RegionPopup
|
|
@@ -1452,7 +1464,11 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
onPress={handleGetLocation}
|
|
|
style={[styles.cornerButton, styles.bottomButton, styles.bottomRightButton]}
|
|
|
>
|
|
|
- <LocationIcon />
|
|
|
+ {isLocationLoading ? (
|
|
|
+ <ActivityIndicator size="small" color={Colors.DARK_BLUE} />
|
|
|
+ ) : (
|
|
|
+ <LocationIcon />
|
|
|
+ )}
|
|
|
</TouchableOpacity>
|
|
|
</>
|
|
|
)}
|