diff --git a/assets/activity.jpg b/assets/activity.jpg
index 5ce37b3..ecf8be1 100644
Binary files a/assets/activity.jpg and b/assets/activity.jpg differ
diff --git a/assets/chairs.jpg b/assets/chairs.jpg
index 2bf3fa2..554a574 100644
Binary files a/assets/chairs.jpg and b/assets/chairs.jpg differ
diff --git a/assets/home.jpg b/assets/home.jpg
index 99ba51f..b48d664 100644
Binary files a/assets/home.jpg and b/assets/home.jpg differ
diff --git a/assets/presentation.jpg b/assets/presentation.jpg
index 165f3a7..0d3a294 100644
Binary files a/assets/presentation.jpg and b/assets/presentation.jpg differ
diff --git a/component/NewEvent.js b/component/NewEvent.js
index 2a3c60a..806200f 100644
--- a/component/NewEvent.js
+++ b/component/NewEvent.js
@@ -1,28 +1,31 @@
import React, { useState } from 'react'
import {
StyleSheet,
- ScrollView,
View,
Text,
TextInput,
Pressable,
KeyboardAvoidingView,
+ FlatList
} from 'react-native'
import MapContainer from './MapContainer'
-// Accepter la fonction childToParent passée en prop
-function NewEvent({ childToParent }) {
- // BOX SHADOW QUI FONCTIONNE SEULEMENT SUR MOBILE ???
- // generateBoxShadowStyle(-2, 4, '#000000', 0.25, 3, 4, '#000000');
+// Accepter la fonction CloseModal passée en prop
+function NewEvent({ CloseModal }) {
+
+ generateBoxShadowStyle(-2, 4, '#000000', 0.25, 3, 4, '#000000');
const [touchY, setTouchY] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
- const [address, setAddress] = useState([2.337179, 48.846836])
+ const [address, setAddress] = useState('')
+ const [coord, setCoord] = useState([2.337179, 48.846836])
+ const [ListAddresses, setList] = useState([]);
const apitoken =
'pk.eyJ1IjoiZWxvcG4iLCJhIjoiY2t3dnRsNm5zMjNwcTJ3cDNjdjB1cWNldCJ9.tH301UpWotwarxl8l7w9HA'
- let timeout
+ let timeout;
+
const getCoord = (input) => {
clearTimeout(timeout)
timeout = setTimeout(() => {
@@ -34,47 +37,61 @@ function NewEvent({ childToParent }) {
apitoken
).then((response) => {
response.json().then((value) => {
- setAddress(value.features[0].center)
+
+ // Insérer dans un tableau toutes les adresses correspondantes
+ let tab = [];
+
+ value.features.forEach(address => {
+ tab.push({
+ name: address.place_name,
+ coord: address.center
+ })
+ })
+
+ // Set le state qui sera lu par la Flatlist
+ setList(tab)
})
})
+ } else {
+ setList([])
}
}, 600)
}
- const onSubmit = () => {
- let data = { name: name, description: description, lat: address[1], long: address[0] }
-
- fetch('https://perso-etudiant.u-pem.fr/~elodie.pan/api/Surroundings.php?action=addEvent',
- {
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- method: "POST",
- body: JSON.stringify(data)
- })
- .then(() => {
- childToParent();
- })
- }
+ const onSubmit = () => {
+ let data = { name: name, description: description, lat: coord[1], long: coord[0] }
+
+ fetch('https://perso-etudiant.u-pem.fr/~elodie.pan/api/Surroundings.php?action=addEvent',
+ {
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ method: "POST",
+ body: JSON.stringify(data)
+ })
+ .then(() => {
+ CloseModal();
+ })
+ }
return (
- {/* Drag vers le bas -> déclencher l'évènement childToParent qui sera détectée par le component parent */}
+ {/* Drag vers le bas -> déclencher l'évènement CloseModal qui sera détectée par le component parent */}
setTouchY(e.nativeEvent.pageY)}
onTouchEnd={(e) => {
if (e.nativeEvent.pageY - touchY > 20) {
- childToParent()
+ CloseModal()
}
}}
>
-
-
+
+
Nom
getCoord(insertedAddress)}
defaultValue={address}
/>
+
+ item.id}
+ renderItem={({item}) =>
+ // Au clic sur une adresse, la map s'actualise, la valeur de l'input et la liste des adresses est vide pour que la Flatlist soit vide et invisible
+ {
+ setCoord(item.coord);
+ setList([]);
+ setAddress(item.name);
+ }}>
+
+ {item.name}
+
+
+ }
+ />
+
+
{/* Localisation correspondant à l'adresse saisie */}
@@ -115,36 +151,36 @@ function NewEvent({ childToParent }) {
Partager
-
+
)
}
// Box Shadow en fonction de l'OS de l'appareil (SEULEMENT SUR MOBILE ??)
-// const generateBoxShadowStyle = (
-// xOffset,
-// yOffset,
-// shadowColorIos,
-// shadowOpacity,
-// shadowRadius,
-// elevation,
-// shadowColorAndroid,
-// ) => {
-// if (Platform.OS === 'ios') {
-// styles.boxShadow = {
-// shadowColor: shadowColorIos,
-// shadowOffset: {width: xOffset, height: yOffset},
-// shadowOpacity,
-// shadowRadius,
-// };
-// } else if (Platform.OS === 'android') {
-// styles.boxShadow = {
-// elevation,
-// shadowColor: shadowColorAndroid,
-// };
-// }
-// };
+const generateBoxShadowStyle = (
+ xOffset,
+ yOffset,
+ shadowColorIos,
+ shadowOpacity,
+ shadowRadius,
+ elevation,
+ shadowColorAndroid,
+ ) => {
+ if (Platform.OS === 'ios') {
+ styles.boxShadow = {
+ shadowColor: shadowColorIos,
+ shadowOffset: {width: xOffset, height: yOffset},
+ shadowOpacity,
+ shadowRadius,
+ };
+ } else if (Platform.OS === 'android') {
+ styles.boxShadow = {
+ elevation,
+ shadowColor: shadowColorAndroid,
+ };
+ }
+};
const styles = StyleSheet.create({
popup: {
@@ -170,6 +206,22 @@ const styles = StyleSheet.create({
padding: 5,
borderBottomWidth: 1,
},
+ list: {
+ width: '100%',
+ maxHeight: 280,
+ backgroundColor: '#FFFFFF',
+ borderColor: '#C4C4C4',
+ position: 'absolute',
+ top: 55,
+ margin: 'auto',
+ zIndex: 5
+ },
+ listItem: {
+ paddingVertical: 15,
+ paddingHorizontal: 5,
+ borderColor: '#C4C4C4',
+ borderBottomColor: "#C4C4C4"
+ },
map: {
height: 200,
backgroundColor: '#DCFFCB',
diff --git a/component/Surroundings.js b/component/Surroundings.js
index 1c2f495..ee10204 100644
--- a/component/Surroundings.js
+++ b/component/Surroundings.js
@@ -1,4 +1,3 @@
-import { render } from 'react-dom';
import React, { useState, useEffect } from 'react';
import { StyleSheet, View, Text, FlatList, Pressable, Image, Modal, SafeAreaView } from 'react-native'
import Item from './Item'
@@ -6,14 +5,13 @@ import NewEvent from './NewEvent'
function Surroundings() {
- // BOX SHADOW QUI FONCTIONNE SEULEMENT SUR MOBILE ???
- // generateBoxShadowStyle(-2, 4, '#000000', 0.25, 3, 4, '#000000');
+ generateBoxShadowStyle(-2, 4, '#000000', 0.25, 3, 4, '#000000');
const [modalVisible, setModalVisible] = useState(false);
const [data, setData] = useState('');
- const childToParent = () => {
+ const CloseModal = () => {
setModalVisible(false)
fetchData()
}
@@ -48,14 +46,14 @@ function Surroundings() {
renderItem={({item}) => - }
/>
{/* Faire apparaitre la popup au clic */}
- {
+ {
setModalVisible(true);
}}>
- {/* Popup */}
+
{/* Passer une prop au component enfant et recevoir l'évènement créé par l'enfant */}
-
+
@@ -73,29 +71,29 @@ function Surroundings() {
}
// Box Shadow en fonction de l'OS de l'appareil (SEULEMENT SUR MOBILE ??)
-// const generateBoxShadowStyle = (
-// xOffset,
-// yOffset,
-// shadowColorIos,
-// shadowOpacity,
-// shadowRadius,
-// elevation,
-// shadowColorAndroid,
-// ) => {
-// if (Platform.OS === 'ios') {
-// styles.boxShadow = {
-// shadowColor: shadowColorIos,
-// shadowOffset: {width: xOffset, height: yOffset},
-// shadowOpacity,
-// shadowRadius,
-// };
-// } else if (Platform.OS === 'android') {
-// styles.boxShadow = {
-// elevation,
-// shadowColor: shadowColorAndroid,
-// };
-// }
-// };
+const generateBoxShadowStyle = (
+ xOffset,
+ yOffset,
+ shadowColorIos,
+ shadowOpacity,
+ shadowRadius,
+ elevation,
+ shadowColorAndroid,
+ ) => {
+ if (Platform.OS === 'ios') {
+ styles.boxShadow = {
+ shadowColor: shadowColorIos,
+ shadowOffset: {width: xOffset, height: yOffset},
+ shadowOpacity,
+ shadowRadius,
+ };
+ } else if (Platform.OS === 'android') {
+ styles.boxShadow = {
+ elevation,
+ shadowColor: shadowColorAndroid,
+ };
+ }
+};
const styles = StyleSheet.create({
title: {