Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
amatanasovska committed Feb 12, 2024
1 parent 8708684 commit 91a3e75
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/components/MapWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { useLocationStore } from "@stores/locationStore";
import {Text, View} from "react-native"
import {WebView} from "react-native-webview"
import LoadingSpinner from "./LoadingSpinner";

const MapWidget = () => {
const latitude = useLocationStore((state) => state.latitude);
const longitude = useLocationStore((state) => state.longitude);

const prep_uri = 'www.google.com/maps/dir/'+latitude+','+longitude+'/Faculty+of+Computer+Science+%26+Engineering,+Rugjer+Boshkovikj,+Skopje/'+
'@44.8831698,13.6218345,4z/data=!3m1!4b1!4m9!4m8!1m1!4e1!1m5!1m1!1s0x13541443605aa4ab:0x33d56647e5b87264!2m2!1d21.4095479!2d42.0041182?entry=ttu'
return <WebView
source={{ uri: prep_uri}}
style = {{height: '100%'}} />
if(latitude != null && longitude != null)
{
const prep_uri = 'www.google.com/maps/dir/'+latitude+','+longitude+'/Faculty+of+Computer+Science+%26+Engineering,+Rugjer+Boshkovikj,+Skopje/'+
'@44.8831698,13.6218345,4z/data=!3m1!4b1!4m9!4m8!1m1!4e1!1m5!1m1!1s0x13541443605aa4ab:0x33d56647e5b87264!2m2!1d21.4095479!2d42.0041182?entry=ttu'
return <WebView
source={{ uri: prep_uri}}
style = {{height: '100%'}} />
}
else
{
return <LoadingSpinner/>
}
}

export default MapWidget;
8 changes: 4 additions & 4 deletions src/stores/locationStore.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { create } from "zustand";

type LocationStore = {
latitude: number,
longitude: number,
latitude: number | null,
longitude: number | null,
setLatitude: (latitude: number) => void;
setLongitude: (longitude: number) => void;
};

export const useLocationStore = create<LocationStore>((set) => ({
latitude: 0,
longitude: 0,
latitude: null,
longitude: null,
setLatitude: (latitude: number) => set({ latitude }),
setLongitude: (longitude: number) => set({ longitude })
}));
Expand Down

0 comments on commit 91a3e75

Please sign in to comment.