Skip to content
Snippets Groups Projects
Commit 7ac5fb86 authored by Antoine Marquis's avatar Antoine Marquis
Browse files

working form for user to add a new place from postal address

parent bce1759c
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,13 @@ import React, {useEffect, useState} from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { Ionicons } from '@expo/vector-icons'
import { AuthUserContext } from './src/context/AuthContext'
import {callRefresh, manageExpoPushToken} from './src/utils/Axios'
import { Platform, Text, View } from 'react-native';
import mapHome from './src/pages/map/MapHome'
import NewPlace from './src/pages/newPlace/newPlace'
const Tab = createBottomTabNavigator()
......@@ -26,31 +23,14 @@ function HomeScreen() {
);
}
function SettingsScreen() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings!</Text>
</View>
);
}
function App() {
export default function App() {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Navigator screenOptions={{headerShown:false}}>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Settings" component={SettingsScreen} />
<Tab.Screen name="Ajouter un logement" component={NewPlace} />
<Tab.Screen name="maps" component={mapHome} />
</Tab.Navigator>
</NavigationContainer>
);
}
export default App
export const baseIPAddress = "";
export const newPlacePath = "";
\ No newline at end of file
import { View, Text } from "react-native"
export function SelectInput({list, onChangeText, style, value}) {
return (
<View style={{...style, flexDirection:"row"}}>
{list.map((item) => {
const fontColor = value == item ? "red" : "black"
return (
<Text
onPress={() => {onChangeText(item)}}
style={{color:fontColor, marginRight:15}}>
{item}
</Text>
)
})}
</View>
)
}
\ No newline at end of file
import { useState } from "react";
import { TextInput, View, Text, Button, StyleSheet, Dimensions, ScrollView, TouchableOpacity } from "react-native";
import { baseIPAddress } from "../../../constants/server";
import { window } from "../../../constants/Layout";
import { SelectInput } from "../../components/form/select";
export default function NewPlace() {
const [address, setaddress] = useState("");
const [city, setcity] = useState("Compiègne");
const [comp, setcomp] = useState("");
const [name, setname] = useState("");
const [placesRestantes, setplacesRestantes] = useState("");
const [prix, setprix] = useState("");
const [type, settype] = useState("");
function createPlace() {
if (!address || !city || !name || !prix || !type)
{
//Render error
return
}
console.log("Attente de la request")
}
const style = StyleSheet.create({
input: {
borderBottomWidth: 1,
fontSize: 15,
borderBottomColor: "grey",
width: Dimensions.get('window').width * (1/2)
},
titles: {
fontSize: 30,
fontWeight: "bold",
marginTop: 25,
marginBottom: 15
}
})
const cityList = ["Compiègne", "Margny", "Venette", "Autre"]
const typeList = ["Maison", "Appartement", "Studio", "Autre"]
const isMainCity = () => {
let is = false
cityList.forEach(element => {
if(city == element && city != cityList[cityList.length - 1]) is = true
});
return is
}
const isMainType = () => {
let is = false
typeList.forEach(element => {
if(type == element && type != typeList[typeList.length - 1]) is = true
});
return is
}
return (
<View style={{marginTop:20, backgroundColor:"white", height:"100%"}} >
<ScrollView style={{marginLeft:20, marginBottom: 20}}>
<Text style={style.titles}>Adresse</Text>
<TextInput style={style.input} onChangeText={setaddress} value={address} placeholder="Adresse"/>
<TextInput style={style.input} onChangeText={setcomp} value={comp} placeholder="Complément"/>
<SelectInput style={{fontSize:style.input.fontSize, marginTop:10, marginBottom:10}} onChangeText={setcity} value={city} list={cityList}/>
{isMainCity() ? null : <TextInput style={style.input} onChangeText={setcity} value={city}/>}
<Text style={style.titles}>Nom</Text>
<TextInput style={style.input} onChangeText={setname} value={name} placeholder="Nom"/>
<Text style={style.titles}>Places restantes</Text>
<TextInput style={style.input} onChangeText={setplacesRestantes} value={placesRestantes} placeholder="Places restantes"/>
<Text style={style.titles}>Prix</Text>
<TextInput style={style.input} onChangeText={setprix} value={prix} placeholder="Prix"/>
<Text style={style.titles}>Type de logement</Text>
<SelectInput style={{fontSize:style.input.fontSize, marginTop:10, marginBottom:10}} onChangeText={settype} value={type} list={typeList}/>
{isMainType() ? null : <TextInput style={{...style.input, marginBottom:25}} onChangeText={settype} value={type}/>}
<TouchableOpacity style={{borderRadius:1, backgroundColor:"black", padding:10, width:180}} onPress={createPlace}>
<Text style={{fontSize:16, color:"white", fontWeight:"bold", textAlign:"center"}}>Ajouter le logement</Text>
</TouchableOpacity>
</ScrollView>
</View>
)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment