Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Marin2705/Jardin-ReactNative
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin2705 committed Mar 23, 2022
2 parents 62e9e56 + 1d06824 commit 28b11dc
Show file tree
Hide file tree
Showing 5 changed files with 4,942 additions and 4,778 deletions.
18 changes: 4 additions & 14 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StyleSheet, Text, View, TouchableOpacity, StatusBar, Pressable, Modal } from 'react-native'
import { StyleSheet, View, StatusBar, Modal } from 'react-native'
import Home from './component/Home'
import Quiz from './component/Quiz'
import Map from './component/Map'
import Info from './component/Info'
import People from './component/People'
import Form from './component/Form'
Expand All @@ -14,7 +13,7 @@ import * as React from 'react'
import { useState } from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { LinearGradient } from 'expo-linear-gradient'
import Pressable from 'react-native/Libraries/Components/Pressable/Pressable'

const Tab = createBottomTabNavigator();

Expand Down Expand Up @@ -94,16 +93,7 @@ export default function App() {
}}
style={styles.modal}
>
<ShareEvent childToParent={childToParent} />
{/* <View style={styles.modalShare}>
<Text style={styles.modalText}>Donnez-nous votre avis !</Text>
<Pressable
style={[styles.button, styles.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}
>
<Text style={styles.textStyle}>Hide Modal</Text>
</Pressable>
</View> */}
<ShareEvent childToParent={childToParent}/>
</Modal>
</View>
)
Expand All @@ -112,5 +102,5 @@ export default function App() {
const styles = StyleSheet.create({
container: {
flex: 1,
}
},
})
22 changes: 16 additions & 6 deletions component/NewEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ 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');

const [touchY, setTouchY] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const [address, setAddress] = useState('')
const [address, setAddress] = useState([2.337179, 48.846836])
const apitoken = "pk.eyJ1IjoiZWxvcG4iLCJhIjoiY2t3dnRsNm5zMjNwcTJ3cDNjdjB1cWNldCJ9.tH301UpWotwarxl8l7w9HA"

const getCoord = (input) => {
fetch("https://api.mapbox.com/geocoding/v5/mapbox.places/" + input + ".json?access_token=" + apitoken).then(response => {
response.json().then(value => {
setAddress(value.features[0].center)
})
})
}

const onSubmit = () => {
let data = { name: name, description: description, address: address }
Expand Down Expand Up @@ -56,27 +66,27 @@ function NewEvent({ childToParent }) {
<View>
<Text>Nom</Text>
<TextInput style={styles.input}
placeholder="Type here to translate!"
placeholder="Nom du lieu"
onChangeText={insertedName => setName(insertedName)}
defaultValue={name} />
</View>
<View>
<Text>Description</Text>
<TextInput style={styles.input}
placeholder="Type here to translate!"
placeholder="Description du lieu"
onChangeText={insertedDesc => setDescription(insertedDesc)}
defaultValue={description} />
</View>
<View>
<Text>Adresse</Text>
<TextInput style={styles.input}
placeholder="Type here to translate!"
onChangeText={insertedAddress => setAddress(insertedAddress)}
placeholder="Adresse du lieu"
onChangeText={insertedAddress => getCoord(insertedAddress)}
defaultValue={address} />
</View>
<View style={styles.map}>
{/* Localisation correspondant à l'adresse saisie */}
<MapContainer lat={48.846836} long={2.337179} />
<MapContainer lat={address[1]} long={address[0]} name={name} description={description} />
</View>

<Pressable style={styles.button} onPress={onSubmit}>
Expand Down
62 changes: 37 additions & 25 deletions component/ShareEvent.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useState } from 'react'
import {
StyleSheet,
ScrollView,
View,
Text,
Pressable,
KeyboardAvoidingView,
Linking,
} from 'react-native'
import Facebook from './Facebook';
Expand All @@ -18,32 +16,39 @@ function ShareEvent({ childToParent }) {
const [touchY, setTouchY] = useState(0);

return (
<KeyboardAvoidingView style={styles.popup}>
{/* Drag vers le bas -> déclencher l'évènement childToParent qui sera détectée par le component parent */}
<Pressable
style={{ paddingVertical: 15 }}
onTouchStart={(e) => setTouchY(e.nativeEvent.pageY)}
onTouchEnd={(e) => {
if (e.nativeEvent.pageY - touchY > 20) {
childToParent()
}
}}
>
<View style={styles.handle}></View>
</Pressable>
<View style={styles.containerPopup}>
<Pressable style={styles.outside}
onTouchEnd={(e) => {
childToParent()
}}>

<Pressable style={styles.containShare} onPress={() =>{
const quote = encodeURI(
`J'ai trouvé une application sur les jardins du Luxembourg !
Rejoignez-nous !`);
const link = encodeURI('https://zoey-app.fr');
const url = `https://www.facebook.com/sharer/sharer.php?u=${link}&quote=${quote}`;
Linking.openURL(url); }}>
<Text style={styles.title}>Donnez-nous votre avis !</Text>
<Facebook/>
</Pressable>
<View style={styles.popup}>
{/* Drag vers le bas -> déclencher l'évènement childToParent qui sera détectée par le component parent */}
<Pressable
style={{ paddingVertical: 15 }}
onTouchStart={(e) => setTouchY(e.nativeEvent.pageY)}
onTouchEnd={(e) => {
if (e.nativeEvent.pageY - touchY > 20) {
childToParent()
}
}}
>
<View style={styles.handle}></View>
</Pressable>

</KeyboardAvoidingView>
<Pressable style={styles.containShare} onPress={() =>{
const quote = encodeURI(
`J'ai trouvé une application sur les jardins du Luxembourg !
Rejoignez-nous !`);
const link = encodeURI('https://zoey-app.fr');
const url = `https://www.facebook.com/sharer/sharer.php?u=${link}&quote=${quote}`;
Linking.openURL(url); }}>
<Text style={styles.title}>Donnez-nous votre avis !</Text>
<Facebook/>
</Pressable>
</View>
</View>
)
}

Expand Down Expand Up @@ -73,6 +78,13 @@ function ShareEvent({ childToParent }) {
// };

const styles = StyleSheet.create({
containerPopup:{
flex: 1
},
outside: {
width: '100%',
height: "70%" ,
},
popup: {
width: '100%',
height: "30%" ,
Expand Down
52 changes: 52 additions & 0 deletions package-lock.json

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

Loading

0 comments on commit 28b11dc

Please sign in to comment.