diff --git a/apps/expo/src/component/CustomMarker.js b/apps/expo/src/component/CustomMarker.js new file mode 100644 index 0000000..c3d8c81 --- /dev/null +++ b/apps/expo/src/component/CustomMarker.js @@ -0,0 +1,16 @@ +import React from 'react'; +import { Marker } from 'react-native-maps'; + +const CustomMarker = ({ coordinate, title, description, onPress, pinColor = "red" }) => { + return ( + + ); +}; + +export default CustomMarker; diff --git a/apps/expo/src/pages/EventScreen.js b/apps/expo/src/pages/EventScreen.js index a8ee580..388065d 100644 --- a/apps/expo/src/pages/EventScreen.js +++ b/apps/expo/src/pages/EventScreen.js @@ -13,7 +13,6 @@ const EventScreen = () => { showsVerticalScrollIndicator={false} > EVENEMENTS - {/* Génère plusieurs cartes d'événements */} {Array(7).fill(0).map((_, index) => ( { const [region, setRegion] = useState({ @@ -12,41 +16,41 @@ const MapScreen = () => { }); const [userLocation, setUserLocation] = useState(null); const [loading, setLoading] = useState(true); + const [selectedMarker, setSelectedMarker] = useState(null); // État pour gérer la sélection du marqueur useEffect(() => { const getLocation = async () => { - // Demander la permission const { status } = await Location.requestForegroundPermissionsAsync(); - if (status === 'granted') { - // Obtenir la position const location = await Location.getCurrentPositionAsync({ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000, }); - setUserLocation({ - latitude: location.coords.latitude, - longitude: location.coords.longitude, - }); - setRegion({ - ...region, - latitude: location.coords.latitude, - longitude: location.coords.longitude, - }); - setLoading(false); - } else { - // Permission refusée - setLoading(false); + const { latitude, longitude } = location.coords; + setUserLocation({ latitude, longitude }); + setRegion((prevRegion) => ({ + ...prevRegion, + latitude, + longitude, + })); } + setLoading(false); }; - getLocation(); }, []); + const handleMarkerPress = (markerData) => { + setSelectedMarker(markerData); // Mettre à jour l'état avec les informations du marqueur sélectionné + }; + + const closeModal = () => { + setSelectedMarker(null); // Fermer la modale + }; + if (loading) { return ( - + ); @@ -60,14 +64,70 @@ const MapScreen = () => { onRegionChangeComplete={setRegion} > {userLocation && ( - handleMarkerPress({ + title: "Votre position actuelle", + description: "Vous êtes ici", + image: null, + })} /> )} + + handleMarkerPress({ + title: "Exo", + description: "Heures : 17h", + image: PopupImage, + })} + /> + + handleMarkerPress({ + title: "Poab", + description: "Heures : 18h", + image: PopupImage, + })} + /> + + {selectedMarker && ( + + + + {/* Image au-dessus du titre */} + {selectedMarker.image && ( + + )} + {selectedMarker.title} + {selectedMarker.description} + + Fermer + + + + + )} ); }; @@ -81,4 +141,46 @@ const styles = StyleSheet.create({ map: { ...StyleSheet.absoluteFillObject, }, + loadingContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + }, + modalContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: 'rgba(0, 0, 0, 0.5)', + }, + modalContent: { + width: 300, + padding: 10, + backgroundColor: 'white', + borderRadius: 10, + alignItems: 'center', + }, + modalTitle: { + fontSize: 18, + fontWeight: 'bold', + marginBottom: 10, + }, + modalDescription: { + fontSize: 16, + marginBottom: 20, + }, + modalImage: { + width: 150, + height: 150, + marginBottom: 10, + resizeMode: 'contain', + }, + closeButton: { + backgroundColor: '#1B1464', + padding: 10, + borderRadius: 5, + }, + closeButtonText: { + color: 'white', + fontSize: 16, + }, });