Skip to content

Commit

Permalink
set location work
Browse files Browse the repository at this point in the history
  • Loading branch information
Satora1 committed Oct 11, 2024
1 parent 506226b commit e224f9d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/(root)/(tabs)/home.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
import RideCard from '@/components/RideCard'
import * as Location from "expo-location"
import { useUser } from '@clerk/clerk-expo'
import { FlatList, View, Text, Image, ActivityIndicator, TouchableOpacity } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import { icons, images } from "@/constants";
import GoogleTextInput from '@/components/GoogleTextInput';
import Map from '@/components/map';
import { useEffect, useState } from 'react';
import { useLocationStore } from '@/store';

export default function Page() {
const { setUserLocation, setDestinationLocation } = useLocationStore()

; const [hasPermission, setHasPermission] = useState(false)

useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== "granted") {
setHasPermission(false);
return;
}

let location = await Location.getCurrentPositionAsync({});

const address = await Location.reverseGeocodeAsync({
latitude: location.coords?.latitude!,
longitude: location.coords?.longitude!,
});

setUserLocation({
latitude: location.coords?.latitude,
longitude: location.coords?.longitude,
address: `${address[0].name}, ${address[0].region}`,
});
})();
}, []);
const recentRides = [
[
{
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"expo-constants": "~16.0.2",
"expo-font": "~12.0.9",
"expo-linking": "~6.3.1",
"expo-location": "^17.0.1",
"expo-router": "~3.5.23",
"expo-secure-store": "^13.0.2",
"expo-splash-screen": "~0.27.5",
Expand Down

0 comments on commit e224f9d

Please sign in to comment.