|
@@ -83,6 +83,10 @@ import MapButton from 'src/components/MapButton';
|
|
import { useAvatarStore } from 'src/stores/avatarVersionStore';
|
|
import { useAvatarStore } from 'src/stores/avatarVersionStore';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
import ScaleBar from 'src/components/ScaleBar';
|
|
import ScaleBar from 'src/components/ScaleBar';
|
|
|
|
+import {
|
|
|
|
+ startBackgroundLocationUpdates,
|
|
|
|
+ stopBackgroundLocationUpdates
|
|
|
|
+} from 'src/utils/backgroundLocation';
|
|
|
|
|
|
const defaultUserAvatar = require('assets/icon-user-share-location-solid.png');
|
|
const defaultUserAvatar = require('assets/icon-user-share-location-solid.png');
|
|
const logo = require('assets/logo-ua.png');
|
|
const logo = require('assets/logo-ua.png');
|
|
@@ -621,9 +625,24 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
) {
|
|
) {
|
|
setShowNomads(false);
|
|
setShowNomads(false);
|
|
storage.set('showNomads', false);
|
|
storage.set('showNomads', false);
|
|
|
|
+ await stopBackgroundLocationUpdates();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
|
+ if (bgStatus.status !== 'granted') {
|
|
|
|
+ const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
|
+ if (status === Location.PermissionStatus.GRANTED) {
|
|
|
|
+ await startBackgroundLocationUpdates();
|
|
|
|
+ console.log('[Permissions] Background granted');
|
|
|
|
+ } else {
|
|
|
|
+ console.log('[Permissions] Background denied');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ await startBackgroundLocationUpdates();
|
|
|
|
+ console.log('[Permissions] Background already granted');
|
|
|
|
+ }
|
|
|
|
+
|
|
try {
|
|
try {
|
|
let currentLocation = await Location.getCurrentPositionAsync({
|
|
let currentLocation = await Location.getCurrentPositionAsync({
|
|
accuracy: Location.Accuracy.Balanced
|
|
accuracy: Location.Accuracy.Balanced
|
|
@@ -724,10 +743,10 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
animationDuration: 500
|
|
animationDuration: 500
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
- console.warn("Camera ref is not available.");
|
|
|
|
|
|
+ console.warn('Camera ref is not available.');
|
|
}
|
|
}
|
|
}, 500);
|
|
}, 500);
|
|
-
|
|
|
|
|
|
+
|
|
return () => clearTimeout(timeoutId);
|
|
return () => clearTimeout(timeoutId);
|
|
}
|
|
}
|
|
}, [initialRegion]);
|
|
}, [initialRegion]);
|
|
@@ -894,6 +913,19 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
if (status === 'granted' && isServicesEnabled) {
|
|
if (status === 'granted' && isServicesEnabled) {
|
|
await getLocation();
|
|
await getLocation();
|
|
|
|
+ const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
|
+ if (bgStatus.status !== 'granted') {
|
|
|
|
+ const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
|
+ if (status === Location.PermissionStatus.GRANTED) {
|
|
|
|
+ await startBackgroundLocationUpdates();
|
|
|
|
+ console.log('[Permissions] Background granted');
|
|
|
|
+ } else {
|
|
|
|
+ console.log('[Permissions] Background denied');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ await startBackgroundLocationUpdates();
|
|
|
|
+ console.log('[Permissions] Background already granted');
|
|
|
|
+ }
|
|
} else if (!canAskAgain || !isServicesEnabled) {
|
|
} else if (!canAskAgain || !isServicesEnabled) {
|
|
setOpenSettingsVisible(true);
|
|
setOpenSettingsVisible(true);
|
|
} else {
|
|
} else {
|
|
@@ -1397,12 +1429,18 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
'interpolate',
|
|
'interpolate',
|
|
['linear'],
|
|
['linear'],
|
|
['get', 'point_count'],
|
|
['get', 'point_count'],
|
|
- 0, 15,
|
|
|
|
- 10, 17,
|
|
|
|
- 20, 19,
|
|
|
|
- 50, 21,
|
|
|
|
- 75, 23,
|
|
|
|
- 100, 25
|
|
|
|
|
|
+ 0,
|
|
|
|
+ 15,
|
|
|
|
+ 10,
|
|
|
|
+ 17,
|
|
|
|
+ 20,
|
|
|
|
+ 19,
|
|
|
|
+ 50,
|
|
|
|
+ 21,
|
|
|
|
+ 75,
|
|
|
|
+ 23,
|
|
|
|
+ 100,
|
|
|
|
+ 25
|
|
],
|
|
],
|
|
circleColor: 'rgba(237, 147, 52, 1)',
|
|
circleColor: 'rgba(237, 147, 52, 1)',
|
|
circleStrokeWidth: 2,
|
|
circleStrokeWidth: 2,
|
|
@@ -1421,9 +1459,12 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
'interpolate',
|
|
'interpolate',
|
|
['linear'],
|
|
['linear'],
|
|
['get', 'point_count'],
|
|
['get', 'point_count'],
|
|
- 0, 13,
|
|
|
|
- 20, 14,
|
|
|
|
- 75, 15
|
|
|
|
|
|
+ 0,
|
|
|
|
+ 13,
|
|
|
|
+ 20,
|
|
|
|
+ 14,
|
|
|
|
+ 75,
|
|
|
|
+ 15
|
|
],
|
|
],
|
|
textColor: '#FFFFFF',
|
|
textColor: '#FFFFFF',
|
|
textHaloColor: '#000000',
|
|
textHaloColor: '#000000',
|
|
@@ -1443,11 +1484,16 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
'interpolate',
|
|
'interpolate',
|
|
['linear'],
|
|
['linear'],
|
|
['zoom'],
|
|
['zoom'],
|
|
- 0, 0.24,
|
|
|
|
- 5, 0.28,
|
|
|
|
- 10, 0.33,
|
|
|
|
- 15, 0.38,
|
|
|
|
- 20, 0.42
|
|
|
|
|
|
+ 0,
|
|
|
|
+ 0.24,
|
|
|
|
+ 5,
|
|
|
|
+ 0.28,
|
|
|
|
+ 10,
|
|
|
|
+ 0.33,
|
|
|
|
+ 15,
|
|
|
|
+ 0.38,
|
|
|
|
+ 20,
|
|
|
|
+ 0.42
|
|
],
|
|
],
|
|
iconAllowOverlap: true
|
|
iconAllowOverlap: true
|
|
}}
|
|
}}
|
|
@@ -1483,7 +1529,12 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
</MapLibreGL.MapView>
|
|
</MapLibreGL.MapView>
|
|
|
|
|
|
{center ? (
|
|
{center ? (
|
|
- <ScaleBar zoom={zoom} latitude={center[1]} isVisible={isZooming} bottom={tabBarHeight + 80} />
|
|
|
|
|
|
+ <ScaleBar
|
|
|
|
+ zoom={zoom}
|
|
|
|
+ latitude={center[1]}
|
|
|
|
+ isVisible={isZooming}
|
|
|
|
+ bottom={tabBarHeight + 80}
|
|
|
|
+ />
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{regionPopupVisible && regionData ? (
|
|
{regionPopupVisible && regionData ? (
|
|
@@ -1569,7 +1620,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
userInfoData?.avatar ? (
|
|
userInfoData?.avatar ? (
|
|
<Image
|
|
<Image
|
|
style={styles.avatar}
|
|
style={styles.avatar}
|
|
- source={{ uri: API_HOST + '/img/avatars/' + userInfoData?.avatar + '?v=' + avatarVersion }}
|
|
|
|
|
|
+ source={{
|
|
|
|
+ uri: API_HOST + '/img/avatars/' + userInfoData?.avatar + '?v=' + avatarVersion
|
|
|
|
+ }}
|
|
/>
|
|
/>
|
|
) : (
|
|
) : (
|
|
<AvatarWithInitials
|
|
<AvatarWithInitials
|
|
@@ -1622,7 +1675,11 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
<ScrollView
|
|
<ScrollView
|
|
horizontal
|
|
horizontal
|
|
showsHorizontalScrollIndicator={false}
|
|
showsHorizontalScrollIndicator={false}
|
|
- contentContainerStyle={{ paddingHorizontal: 12, gap: isSmallScreen ? 8 : 12, flexDirection: 'row' }}
|
|
|
|
|
|
+ contentContainerStyle={{
|
|
|
|
+ paddingHorizontal: 12,
|
|
|
|
+ gap: isSmallScreen ? 8 : 12,
|
|
|
|
+ flexDirection: 'row'
|
|
|
|
+ }}
|
|
>
|
|
>
|
|
<MapButton
|
|
<MapButton
|
|
onPress={() => {
|
|
onPress={() => {
|