This commit is contained in:
trochas
2025-12-09 13:44:08 +01:00
9 changed files with 293 additions and 85 deletions

View File

@@ -7,10 +7,9 @@ import { HapticTab } from '@/components/haptic-tab';
import { IconSymbol } from '@/components/ui/icon-symbol';
import { Colors } from '@/constants/theme';
import { useColorScheme } from '@/hooks/use-color-scheme';
import TabTwoScreen from './index';
import HomeScreen from './explore';
import ListMateriel from './gestionnaire_ressource';
import BonjourScreen from './bonjourFL';
import ListMateriel from './gestionnaire_ressource';
import Home from './home';
import MapScreen from './mapScreen';
const Tabs = createBottomTabNavigator();
@@ -25,9 +24,18 @@ export default function TabLayout() {
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
headerShown: false,
tabBarButton: HapticTab,
}}>
<Tabs.Screen
}}>
<Tabs.Screen
name="home"
component={Home}
options={{
title: 'Home',
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="house.fill" color={color} />
),
}}
/>
<Tabs.Screen
name="gestionnaire_ressource"
component={ListMateriel}
options={{

View File

@@ -82,7 +82,7 @@ export default function BonjourScreen() {
<ThemedTextInput
lvl={0}
style={styles.input}
placeholder="Rechercher un groupe..."
placeholder="Rechercher un artisant..."
value={search}
onChangeText={setSearch}
/>
@@ -94,9 +94,7 @@ export default function BonjourScreen() {
}
/>
<ThemedView style={styles.footer}>
<Button title="Retour" onPress={() => router.push("/(tabs)/mapScreen") } />
</ThemedView>
<ThemedView style={{width:"100%", position: 'absolute', backgroundColor:'transparent',}}>
<SelectChantier ></SelectChantier>

View File

@@ -1,50 +1,73 @@
import { useRouter , useLocalSearchParams} from "expo-router";
import { useRouter, useLocalSearchParams } from "expo-router";
import { navigate } from "expo-router/build/global-state/routing";
import React, {useState} from 'react';
import { Button,FlatList,Image, Text, TextInput,View, StyleSheet } from 'react-native';
import React, { useEffect, useState } from "react";
import {
Button,
FlatList,
Image,
Text,
TextInput,
View,
StyleSheet,
} from "react-native";
import { getRessources, Ressource } from "../../services/ressourcesService";
export default function GestionnaireRessource() {
const { nom, prenom } = useLocalSearchParams(); // Recup data ecran precedent
const [search, setSearch] = useState('');
const [search, setSearch] = useState("");
const [ressource, setRessources] = useState<Ressource[]>([]);
const [loading, setLoading] = useState(true);
const router = useRouter();
type Ressource ={
id: number;
name: string;
type: string;
Image: string;
}
const data: Ressource[] = [
{ id: 1, name: 'Marteau', type: 'Outil', Image: '' },
{ id: 2, name: 'Scie', type: 'Outil' , Image: ''},
{ id: 3, name: 'Pelle', type: 'Outil' , Image: '' },
{ id: 4, name: 'Grue', type: 'Machine',Image: 'https://media.discordapp.net/attachments/1425108443571945644/1427207643180826757/raw.png?ex=68ee0632&is=68ecb4b2&hm=1efc51065c6abfb1af75b8382f9924c2eb177c7d7672f7ed9837e96ef3076d16&=&format=webp&quality=lossless&width=421&height=632'},
{ id: 5, name: 'Bulldozer', type: 'Machine', Image: ''},
];
const renderRessource = ({ item, index }: { item?: Ressource; index: number }) => {
if (!item) {
// optionnel : afficher un placeholder pour debug
// return <View style={styles.card}><Text>Item manquant</Text></View>;
return null;
useEffect(() => {
async function loadData() {
try {
const data = await getRessources();
setRessources(data);
} catch (error) {
console.error("Erreur lors du chargement des ressources :", error);
} finally {
setLoading(false);
}
return(
}
loadData();
}, []);
const filteredData = ressource.filter((r) =>
r.name.toLowerCase().includes(search.toLowerCase())
);
const renderRessource = ({
item,
index,
}: {
item?: Ressource;
index: number;
}) => {
if (!item) {
// optionnel : afficher un placeholder pour debug
// return <View style={styles.card}><Text>Item manquant</Text></View>;
return null;
}
return (
<View style={styles.card}>
<View style={styles.info}>
<Image source={{ uri: item.Image }} style={styles.image} />
<Text>{item.id}</Text>
<Text>{item.name}</Text>
<Text>{item.type}</Text>
<Text>{item.quantity}</Text>
<Text>{item.available_quantity}</Text>
</View>
</View>);
};
</View>
);
};
return(
return (
<View style={styles.container}>
<FlatList
data={data}
data={filteredData}
renderItem={renderRessource}
keyExtractor={(_, index) => index.toString()}
contentContainerStyle={{ paddingBottom: 40 }}
@@ -69,45 +92,48 @@ export default function GestionnaireRessource() {
/>
<View style={styles.footer}>
<Button title="Retour" onPress={() =>router.push('/(tabs)/bonjourFL')} />
<Button
title="Retour"
onPress={() => router.push("/(tabs)/bonjourFL")}
/>
</View>
</View>
)
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
backgroundColor: "#fff",
},
header: {
marginTop: 60,
marginBottom: 20,
alignItems: 'center',
alignItems: "center",
paddingHorizontal: 20,
},
text: {
fontSize: 22,
fontWeight: 'bold',
fontWeight: "bold",
marginBottom: 10,
},
input: {
width: '100%',
width: "100%",
borderWidth: 1,
borderColor: '#ccc',
borderColor: "#ccc",
borderRadius: 10,
padding: 10,
fontSize: 16,
},
card: {
flexDirection: 'row',
flexDirection: "row",
marginHorizontal: 20,
marginBottom: 15,
borderWidth: 1,
borderColor: '#ddd',
borderColor: "#ddd",
borderRadius: 10,
padding: 10,
backgroundColor: '#fafafa',
backgroundColor: "#fafafa",
},
image: {
width: 80,
@@ -117,10 +143,10 @@ const styles = StyleSheet.create({
},
info: {
flex: 1,
justifyContent: 'center',
justifyContent: "center",
},
group: {
fontWeight: 'bold',
fontWeight: "bold",
fontSize: 16,
marginBottom: 5,
},
@@ -128,8 +154,8 @@ const styles = StyleSheet.create({
padding: 20,
},
empty: {
textAlign: 'center',
textAlign: "center",
marginTop: 30,
color: '#888',
color: "#888",
},
});
});

39
app/(tabs)/home.tsx Normal file
View File

@@ -0,0 +1,39 @@
import SelectChantier from '@/components/selectChantier';
import SetStatus from '@/components/setStatus';
import { ThemedView, } from '@/components/themed-view';
import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
import React from 'react';
import { StyleSheet, View } from 'react-native';
export default function Home() {
return(
<ThemedView lvl={3} style={styles.container}>
<View style={styles.header}>
<View style={{position: 'absolute'}}>
<SelectChantier></SelectChantier>
</View>
<View style={{position: 'absolute'}}>
<SetStatus></SetStatus>
</View>
</View>
</ThemedView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
},
header: {
width:"100%"
},
});

View File

@@ -73,7 +73,7 @@ export default function SelectChantier() {
<AnimatedThemedView layout={LinearTransition.duration(200)} lvl={2} shadow={true} style={styles.window}>
<ThemedButton style={isOpen ? styles.buttonOpen : styles.buttonClose} lvl={isOpen ? 1 : 1} onPress={() => onPressOpen()}>
<ThemedText style={styles.buttonText}>{isOpen ? "Close" : "Open"}</ThemedText>
<ThemedText style={styles.buttonText}>{isOpen ? "Fermer" : "Chantiers"}</ThemedText>
</ThemedButton>
{isOpen &&
<View style={styles.menu}>

121
components/setStatus.tsx Normal file
View File

@@ -0,0 +1,121 @@
import { useChantier } from '@/app/ContextChantier';
import { useState } from 'react';
import { Dimensions, LayoutAnimation, Pressable, StyleSheet, View } from 'react-native';
import Animated, { LinearTransition } from 'react-native-reanimated';
import { ThemedButton } from './themed-button';
import { ThemedText } from './themed-text';
import { ThemedTextInput } from './themed-textinput';
import { ThemedView } from "./themed-view";
const screenHeight = Dimensions.get("window").height;
export default function SetStatus() {
const { chantier, setChantier} = useChantier();
const [currentSatus, setCurrentSearch] = useState("En cours");
const [isOpen,setIsOpen] = useState(false);
const AnimatedThemedView = Animated.createAnimatedComponent(ThemedView);
const AnimatedThemedText = Animated.createAnimatedComponent(ThemedText);
const AnimatedThemedButton = Animated.createAnimatedComponent(ThemedButton);
const AnimatedThemedTextInput = Animated.createAnimatedComponent(ThemedTextInput);
const choices = ["En cours","Interrompu","Terminé","Non réalisé"]
function onPressOpen(): void {
LayoutAnimation.configureNext(
LayoutAnimation.Presets.easeInEaseOut
);
setIsOpen(!isOpen);
}
function selectSatus(status: string): void {
setCurrentSearch(status);
setIsOpen(false);
}
const choice = (status:string, index: number) => {
return(
<Pressable key={index} onPress={() => selectSatus(status)}>
<View style={styles.satus}>
<ThemedText style={styles.centeredText}>{status}</ThemedText>
</View >
</Pressable>
);
};
return(
<Animated.View
layout={LinearTransition.duration(200)}
style={isOpen ? styles.windowOpean : styles.windowClose}>
<AnimatedThemedView layout={LinearTransition.duration(200)} lvl={2} shadow={true} style={styles.window}>
<ThemedButton style={styles.button} lvl={isOpen ? 1 : 1} onPress={() => onPressOpen()}>
<ThemedText style={styles.centeredText}>{currentSatus}</ThemedText>
</ThemedButton>
{isOpen &&
<View style={styles.menu}>
<View style={styles.list}>
{choices.map((str, index) => (
str!==currentSatus && choice(str, index)
))}
</View>
</View>
}
</AnimatedThemedView>
</Animated.View>
)
}
const styles = StyleSheet.create({
windowClose:{
//backgroundColor: '#00FFFF',
//borderRadius:10,
padding: 10,
width:"50%",
//height:60,
overflow: 'hidden',
},
windowOpean:{
width:"50%",
padding: 10,
},
window:{
borderRadius:15,
//backgroundColor: '#00FF00',
overflow: 'hidden',
},
menu:{
padding:0,
flex: 1,
//backgroundColor:'#FF00FF',
},
list:{
flex: 1,
overflow: 'hidden',
borderRadius:10,
},
satus:{
padding:10,
flexDirection: 'row',
},
button:{
width:'100%',
margin: 0,
borderRadius: 15,
padding: 10,
height:40,
},
centeredText:{
textAlign: 'center',
}
});

49
package-lock.json generated
View File

@@ -24,7 +24,7 @@
"expo-symbols": "~1.0.7",
"expo-system-ui": "~6.0.7",
"expo-web-browser": "~15.0.8",
"firebase": "^12.5.0",
"firebase": "^12.6.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-native": "0.81.4",
@@ -2266,10 +2266,9 @@
}
},
"node_modules/@firebase/ai": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@firebase/ai/-/ai-2.5.0.tgz",
"integrity": "sha512-OXv/jZLRjV9jTejWA4KOvW8gM1hNsLvQSCPwKhi2CEfe0Nap3rM6z+Ial0PGqXga0WgzhpypEvJOFvaAUFX3kg==",
"license": "Apache-2.0",
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@firebase/ai/-/ai-2.6.0.tgz",
"integrity": "sha512-NGyE7NQDFznOv683Xk4+WoUv39iipa9lEfrwvvPz33ChzVbCCiB69FJQTK2BI/11pRtzYGbHo1/xMz7gxWWhJw==",
"dependencies": {
"@firebase/app-check-interop-types": "0.3.3",
"@firebase/component": "0.7.0",
@@ -2324,11 +2323,9 @@
"license": "Apache-2.0"
},
"node_modules/@firebase/app": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.14.5.tgz",
"integrity": "sha512-zyNY77xJOGwcuB+xCxF8z8lSiHvD4ox7BCsqLEHEvgqQoRjxFZ0fkROR6NV5QyXmCqRLodMM8J5d2EStOocWIw==",
"license": "Apache-2.0",
"peer": true,
"version": "0.14.6",
"resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.14.6.tgz",
"integrity": "sha512-4uyt8BOrBsSq6i4yiOV/gG6BnnrvTeyymlNcaN/dKvyU1GoolxAafvIvaNP1RCGPlNab3OuE4MKUQuv2lH+PLQ==",
"dependencies": {
"@firebase/component": "0.7.0",
"@firebase/logger": "0.5.0",
@@ -2391,13 +2388,11 @@
"license": "Apache-2.0"
},
"node_modules/@firebase/app-compat": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.5.5.tgz",
"integrity": "sha512-lVG/nRnXaot0rQSZazmTNqy83ti9O3+kdwoaE0d5wahRIWNoDirbIMcGVjDDgdmf4IE6FYreWOMh0L3DV1475w==",
"license": "Apache-2.0",
"peer": true,
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.5.6.tgz",
"integrity": "sha512-YYGARbutghQY4zZUWMYia0ib0Y/rb52y72/N0z3vglRHL7ii/AaK9SA7S/dzScVOlCdnbHXz+sc5Dq+r8fwFAg==",
"dependencies": {
"@firebase/app": "0.14.5",
"@firebase/app": "0.14.6",
"@firebase/component": "0.7.0",
"@firebase/logger": "0.5.0",
"@firebase/util": "1.13.0",
@@ -2487,10 +2482,9 @@
}
},
"node_modules/@firebase/data-connect": {
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.3.11.tgz",
"integrity": "sha512-G258eLzAD6im9Bsw+Qm1Z+P4x0PGNQ45yeUuuqe5M9B1rn0RJvvsQCRHXgE52Z+n9+WX1OJd/crcuunvOGc7Vw==",
"license": "Apache-2.0",
"version": "0.3.12",
"resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.3.12.tgz",
"integrity": "sha512-baPddcoNLj/+vYo+HSJidJUdr5W4OkhT109c5qhR8T1dJoZcyJpkv/dFpYlw/VJ3dV66vI8GHQFrmAZw/xUS4g==",
"dependencies": {
"@firebase/auth-interop-types": "0.2.4",
"@firebase/component": "0.7.0",
@@ -7912,22 +7906,21 @@
}
},
"node_modules/firebase": {
"version": "12.5.0",
"resolved": "https://registry.npmjs.org/firebase/-/firebase-12.5.0.tgz",
"integrity": "sha512-Ak8JcpH7FL6kiv0STwkv5+3CYEROO9iFWSx7OCZVvc4kIIABAIyAGs1mPGaHRxGUIApFZdMCXA7baq17uS6Mow==",
"license": "Apache-2.0",
"version": "12.6.0",
"resolved": "https://registry.npmjs.org/firebase/-/firebase-12.6.0.tgz",
"integrity": "sha512-8ZD1Gcv916Qp8/nsFH2+QMIrfX/76ti6cJwxQUENLXXnKlOX/IJZaU2Y3bdYf5r1mbownrQKfnWtrt+MVgdwLA==",
"dependencies": {
"@firebase/ai": "2.5.0",
"@firebase/ai": "2.6.0",
"@firebase/analytics": "0.10.19",
"@firebase/analytics-compat": "0.2.25",
"@firebase/app": "0.14.5",
"@firebase/app": "0.14.6",
"@firebase/app-check": "0.11.0",
"@firebase/app-check-compat": "0.4.0",
"@firebase/app-compat": "0.5.5",
"@firebase/app-compat": "0.5.6",
"@firebase/app-types": "0.9.3",
"@firebase/auth": "1.11.1",
"@firebase/auth-compat": "0.6.1",
"@firebase/data-connect": "0.3.11",
"@firebase/data-connect": "0.3.12",
"@firebase/database": "1.1.0",
"@firebase/database-compat": "2.1.0",
"@firebase/firestore": "4.9.2",

View File

@@ -27,7 +27,7 @@
"expo-symbols": "~1.0.7",
"expo-system-ui": "~6.0.7",
"expo-web-browser": "~15.0.8",
"firebase": "^12.5.0",
"firebase": "^12.6.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-native": "0.81.4",

View File

@@ -0,0 +1,23 @@
import { collection, getDocs } from "firebase/firestore";
import { db } from "../firebase_config";
export type Ressource = {
id: number;
name: string;
type: string;
Image: string;
quantity: number;
available_quantity: number;
};
export async function getRessources(): Promise<Ressource[]> {
try {
const ressourcesCol = collection(db, "ressources");
const snapshot = await getDocs(ressourcesCol);
const list = snapshot.docs.map((doc) => doc.data() as Ressource);
return list;
} catch (err) {
console.log("Firestore Error:", err);
return [];
}
}