From e43e04d4f8ab00df60fbf4573bf6f3065e2d02d4 Mon Sep 17 00:00:00 2001 From: Rayhan Hassou Date: Thu, 30 Nov 2023 13:24:34 +0100 Subject: [PATCH 1/7] add some changes --- LeftOvers/screens/IngredientSelection.tsx | 8 +- LeftOvers/screens/Profiles.tsx | 138 +++++++++++----------- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/LeftOvers/screens/IngredientSelection.tsx b/LeftOvers/screens/IngredientSelection.tsx index 9bfe6ca..0691f8d 100644 --- a/LeftOvers/screens/IngredientSelection.tsx +++ b/LeftOvers/screens/IngredientSelection.tsx @@ -3,8 +3,6 @@ import { View, StyleSheet, Text, Image, Pressable, ActivityIndicator, FlatList, import { SafeAreaProvider } from 'react-native-safe-area-context'; import { Searchbar } from 'react-native-paper'; import FoodElementText from '../components/FoodElementText'; -import CustomButton from '../components/CustomButton'; - import plus from '../assets/images/plus.png'; import moins from '../assets/images/minus.png'; import Ingredient from '../Models/Ingredient'; @@ -28,7 +26,6 @@ export default function IngredientSelection(props) { try { setIsLoading(true); if (query === '') { - // Si le query (prompt) est vide, charger tous les ingrédients loadIngredients(); } else { const filtered = await ingredientService.getfilteredIngredient(query); @@ -41,7 +38,6 @@ export default function IngredientSelection(props) { } }; - // Appelée à chaque changement de la recherche const handleSearch = (query) => { setSearchQuery(query); filterIngredients(query); @@ -179,7 +175,7 @@ const loadIngredients = async () => { Available - + ( @@ -192,7 +188,7 @@ const loadIngredients = async () => { - + diff --git a/LeftOvers/screens/Profiles.tsx b/LeftOvers/screens/Profiles.tsx index 4123c9a..b6f906f 100644 --- a/LeftOvers/screens/Profiles.tsx +++ b/LeftOvers/screens/Profiles.tsx @@ -1,7 +1,5 @@ -import React, { useContext, useState } from 'react'; -import { StyleSheet, View, Pressable, Text, Image, ScrollView, useWindowDimensions } from 'react-native'; - -import {Modal, Portal, PaperProvider} from 'react-native-paper'; +import React, { useContext, useEffect, useState } from 'react'; +import { StyleSheet, View, Modal, Pressable, Text, Image, ScrollView, useWindowDimensions } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import { SafeAreaProvider } from 'react-native-safe-area-context'; @@ -9,18 +7,18 @@ import { SafeAreaProvider } from 'react-native-safe-area-context'; import ProfileDetails from '../components/ProfileDetails'; import ProfileDelete from '../components/ProfileDelete'; import ColorContext from '../theme/ColorContext'; +import AsyncStorage from '@react-native-async-storage/async-storage'; export default function Profiles({navigation, props}) { - const { colors } = useContext(ColorContext) - - const allJohnny = [{value: "Coconut"}, {value: "Skimmed Milk"}, {value: "Nuts"}] - const dieJohnny = [{value: "Gluten free"}, {value: "Porkless"}, {value: "Pescatarian"}] + const { colors, toggleColors } = useContext(ColorContext) - const allJackie = [{value: "Tomato"}, {value: "Relic"}] - const dieJackie = [{value: "Porkless"}, {value: "Vegetarian"}] + const all = [] + const die = [{value: "Dairy free"}, {value: "Gluten free"}, {value: "Porkless"}, {value: "Vegan"}, {value: "Vegetarian"}, {value: "Pescatarian"}] const [visible, setVisible] = useState(false); const [opacity, setOpacity] = useState(1); + const [profiles, setProfiles] = useState([]); + const raisePopUp = () => { setVisible(true) setOpacity(0.3) @@ -30,28 +28,35 @@ export default function Profiles({navigation, props}) { setOpacity(1) } - const profiles = [ - { - name: "Johnny Silverhand", - avatar: "plus_small.png", - diets: dieJohnny, - allergies: allJohnny, - }, - { - name: "Jackie Welles", - avatar: "plus_small.png", - diets: dieJackie, - allergies: allJackie, - }, - // ... Ajoutez d'autres profils ici de la même manière - ]; + const handleDeleteProfiles = async () => { + try { + await AsyncStorage.removeItem('profiles'); + console.log('Données supprimées avec succès !'); + } catch (error) { + console.error('Erreur lors de la suppression des données :', error); + } + }; + + const handleGetProfiles = async () => { + try { + const existingProfiles = await AsyncStorage.getItem('profiles'); + return JSON.parse(existingProfiles) || []; + } catch (error) { + console.log("ça maaaaaaaaarche poaaaaaaaaaaaas"); + return []; + } + } + + useEffect(() => { + const fetchProfiles = async () => { + const existingProfiles = await handleGetProfiles(); + setProfiles(existingProfiles); + }; + + fetchProfiles(); + }, []); - const containerStyle = { - //minHeight: useWindowDimensions().height/2, - //width: useWindowDimensions().width, - height: "75%", - width: "100%", - }; + const styles = StyleSheet.create({ container: { @@ -104,13 +109,11 @@ export default function Profiles({navigation, props}) { borderRadius: 15, alignItems: "center", justifyContent: "center", - backgroundColor: colors.cardBackground, - borderWidth: 1, - borderColor: colors.blocBorder, + backgroundColor: "#F2F0E4", }, validationQuestion: { fontSize: 20, - color: colors.cardElementBorder, + color: '#ACA279', alignItems: 'center', justifyContent: 'center', flex: 0.3, @@ -133,7 +136,7 @@ export default function Profiles({navigation, props}) { borderRadius: 20, alignItems: "center", justifyContent: "center", - backgroundColor: colors.yesButton, + backgroundColor: "#59BDCD", }, yesText: { fontSize: 20, @@ -171,50 +174,51 @@ export default function Profiles({navigation, props}) { avatar={profile.avatar} diets={profile.diets} allergies={profile.allergies} - onDeleteProfile={raisePopUp}/> + onDeleteProfile={raisePopUp} + /> {index < profiles.length - 1 && } )); return ( - - + + {profileComponents} - - - - - - - - - - - Do you really want to delete this profile? - - - - - Yes + + + + + {/* */} + + + Do you really want to delete this profile? + + + + + Yes + + + + + + No + + - - - - - No - - + - + - - - + + + + ); - } + } \ No newline at end of file -- 2.36.3 From 227395ea14c283dba2e6697ba8d8cdbb062de926 Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Thu, 30 Nov 2023 14:42:48 +0100 Subject: [PATCH 2/7] Fix ListWithoutSelect component --- LeftOvers/components/ListSelect.tsx | 5 +++-- LeftOvers/components/ListWithoutSelect.tsx | 15 ++++++++++++++- LeftOvers/components/ProfileModification.tsx | 4 ++-- LeftOvers/theme/colors.ts | 3 +++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/LeftOvers/components/ListSelect.tsx b/LeftOvers/components/ListSelect.tsx index 12c1f93..8ed2aca 100644 --- a/LeftOvers/components/ListSelect.tsx +++ b/LeftOvers/components/ListSelect.tsx @@ -5,7 +5,7 @@ import ColorContext from '../theme/ColorContext'; type ListProps = { title: string - content : string[] + content : {value: string}[] } export default function ListSelect(props: ListProps) { @@ -74,7 +74,7 @@ export default function ListSelect(props: ListProps) { }, badgesText: { fontSize: 15, - color: colors.cardElementText, + color: colors.badgeText, }, box: { borderColor: "#3F3C42" @@ -98,6 +98,7 @@ export default function ListSelect(props: ListProps) { checkBoxStyles={styles.box} notFoundText="All Diets Already Selected" placeholder={props.title} + labelStyles={styles.title} label={props.title}/> ); } diff --git a/LeftOvers/components/ListWithoutSelect.tsx b/LeftOvers/components/ListWithoutSelect.tsx index 3885f1b..069534b 100644 --- a/LeftOvers/components/ListWithoutSelect.tsx +++ b/LeftOvers/components/ListWithoutSelect.tsx @@ -9,8 +9,15 @@ type ListProps = { } export default function ListWithoutSelect(props: ListProps) { + const [selected, setSelected] = React.useState([]); const { colors } = useContext(ColorContext); + let listContent = [] + + props.content.forEach((val) => { + listContent.push({value: val.value, disabled: true}) + }) + const styles = StyleSheet.create({ titleBar: { flexDirection: "row", @@ -58,6 +65,7 @@ export default function ListWithoutSelect(props: ListProps) { width: "100%", minWidth: 250, maxWidth: 250, + backgroundColor: colors.cardElementBackground, }, itemText: { fontSize: 13, @@ -71,12 +79,14 @@ export default function ListWithoutSelect(props: ListProps) { box: { borderWidth: 0, flex: 0, + backgroundColor: colors.cardElementBackground, } }); return ( setSelected(val)} + data={listContent} save="value" search={false} arrowicon={} @@ -84,8 +94,11 @@ export default function ListWithoutSelect(props: ListProps) { inputStyles={styles.title} dropdownStyles={styles.itemList} dropdownItemStyles={styles.itemCell} + disabledItemStyles={styles.itemCell} dropdownTextStyles={styles.itemText} + disabledTextStyles={styles.itemText} checkBoxStyles={styles.box} + disabledCheckBoxStyles={styles.box} notFoundText="None" placeholder={props.title} label={props.title}/> diff --git a/LeftOvers/components/ProfileModification.tsx b/LeftOvers/components/ProfileModification.tsx index 63b14f2..41e5831 100644 --- a/LeftOvers/components/ProfileModification.tsx +++ b/LeftOvers/components/ProfileModification.tsx @@ -9,8 +9,8 @@ import ColorContext from '../theme/ColorContext'; type ProfileProps = { name: string avatar: string - diets: string[] - allergies: string[] + diets: {value: string}[] + allergies: {value: string}[] } export default function ProfileModification(props: ProfileProps) { diff --git a/LeftOvers/theme/colors.ts b/LeftOvers/theme/colors.ts index e329e22..46eb4f6 100644 --- a/LeftOvers/theme/colors.ts +++ b/LeftOvers/theme/colors.ts @@ -37,6 +37,7 @@ export interface Theme { yesButton: string, letterFilter: string, foodElementBorder: string, + badgeText: string, } export const LightTheme : Theme = { @@ -66,6 +67,7 @@ export const LightTheme : Theme = { yesButton: Moonstone, letterFilter: Moonstone, foodElementBorder: Jet, + badgeText: Jet, } export const DarkTheme : Theme = { @@ -95,5 +97,6 @@ export const DarkTheme : Theme = { yesButton: CarolinaBlue, letterFilter: CarolinaBlue, foodElementBorder: CarolinaBlue, + badgeText: Alabaster, } -- 2.36.3 From c5ec8302b20c60b80746aeb5c15872e4fc7d9f9e Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Thu, 30 Nov 2023 14:46:13 +0100 Subject: [PATCH 3/7] Code Smells Fix --- LeftOvers/screens/IngredientSelection.tsx | 1 - LeftOvers/screens/RecipeDetails.tsx | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/LeftOvers/screens/IngredientSelection.tsx b/LeftOvers/screens/IngredientSelection.tsx index a5c1a24..8c60eeb 100644 --- a/LeftOvers/screens/IngredientSelection.tsx +++ b/LeftOvers/screens/IngredientSelection.tsx @@ -3,7 +3,6 @@ import { View, StyleSheet, Text, Image, Pressable, ActivityIndicator, FlatList, import { SafeAreaProvider } from 'react-native-safe-area-context'; import { Searchbar } from 'react-native-paper'; import FoodElementText from '../components/FoodElementText'; -import CustomButton from '../components/CustomButton'; import plus from '../assets/images/plus.png'; import moins from '../assets/images/minus.png'; diff --git a/LeftOvers/screens/RecipeDetails.tsx b/LeftOvers/screens/RecipeDetails.tsx index b79b2da..74905c8 100644 --- a/LeftOvers/screens/RecipeDetails.tsx +++ b/LeftOvers/screens/RecipeDetails.tsx @@ -14,7 +14,6 @@ export default function RecipeDetails(props) { const {colors} = useContext(ColorContext); const [isLoading, setIsLoading] = useState(true); - const [error, setError] = useState(); const [response, setResponse] = useState(undefined); const recipesService = new RecipesService(); @@ -23,7 +22,7 @@ export default function RecipeDetails(props) { const recipe = await recipesService.getRecipeById(props.id); setResponse(recipe); } catch (error) { - setError(error); + console.log(error); } finally { setIsLoading(false); } -- 2.36.3 From ebcbead91070f0d2bde1e1365679043a3385cb5a Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Fri, 1 Dec 2023 09:28:57 +0100 Subject: [PATCH 4/7] Kdo Rayhan pour merge --- LeftOvers/components/ProfileDetails.tsx | 9 ++++++--- LeftOvers/components/ProfileElement.tsx | 1 - LeftOvers/components/ProfileModification.tsx | 8 +------- LeftOvers/navigation/CookingStackScreen.tsx | 2 +- LeftOvers/navigation/ProfileStackScreen.tsx | 5 ++++- LeftOvers/screens/HomePage.tsx | 16 +++++++++++++--- LeftOvers/screens/ModifyProfile.tsx | 14 +++----------- LeftOvers/screens/Profiles.tsx | 5 +++-- 8 files changed, 31 insertions(+), 29 deletions(-) diff --git a/LeftOvers/components/ProfileDetails.tsx b/LeftOvers/components/ProfileDetails.tsx index bbfdb0a..c372b11 100644 --- a/LeftOvers/components/ProfileDetails.tsx +++ b/LeftOvers/components/ProfileDetails.tsx @@ -9,6 +9,7 @@ type ProfileProps = { avatar: string diets: string[] allergies: string[] + onModification: () => void onDeleteProfile: () => void } @@ -78,10 +79,10 @@ export default function ProfileDetails(props) { }, modify: { height: "100%", + width: "100%", tintColor: colors.cardElementBorder, resizeMode: 'contain', - flex: 0.1, - marginLeft: "3%", + flex: 1, }, delete: { height: "100%", @@ -128,7 +129,9 @@ export default function ProfileDetails(props) { {props.name} - + + + diff --git a/LeftOvers/components/ProfileElement.tsx b/LeftOvers/components/ProfileElement.tsx index af0c042..25b9383 100644 --- a/LeftOvers/components/ProfileElement.tsx +++ b/LeftOvers/components/ProfileElement.tsx @@ -33,7 +33,6 @@ export default function ProfileElement(props : Profile) { else{ setSeparator("none") } - console.log(waiting, separator, props.name) } let imageSource diff --git a/LeftOvers/components/ProfileModification.tsx b/LeftOvers/components/ProfileModification.tsx index 41e5831..d738e9a 100644 --- a/LeftOvers/components/ProfileModification.tsx +++ b/LeftOvers/components/ProfileModification.tsx @@ -60,7 +60,7 @@ export default function ProfileModification(props: ProfileProps) { }, textInput: { fontSize: 15, - color: colors.cardTitle, + color: colors.cardDetail, borderRadius: 10, borderWidth: 2, borderStyle: 'dashed', @@ -92,11 +92,6 @@ export default function ProfileModification(props: ProfileProps) { color: colors.cardElementBorder, flex: 1, }, - nbSelected: { - fontSize: 11, - color: colors.cardDetail, - textAlign: "right", - } }); return ( @@ -108,7 +103,6 @@ export default function ProfileModification(props: ProfileProps) { Filters - 0 diets selected diff --git a/LeftOvers/navigation/CookingStackScreen.tsx b/LeftOvers/navigation/CookingStackScreen.tsx index f043b31..bf1f075 100644 --- a/LeftOvers/navigation/CookingStackScreen.tsx +++ b/LeftOvers/navigation/CookingStackScreen.tsx @@ -19,7 +19,7 @@ export default function CookingStackScreen() { options={{ headerStyle: {backgroundColor: theme === 'light' ? '#F2F0E4' : '#3F3C42'}, headerTitle: () => ( - + ) }} /> diff --git a/LeftOvers/navigation/ProfileStackScreen.tsx b/LeftOvers/navigation/ProfileStackScreen.tsx index 654ddb6..2d6c455 100644 --- a/LeftOvers/navigation/ProfileStackScreen.tsx +++ b/LeftOvers/navigation/ProfileStackScreen.tsx @@ -34,7 +34,10 @@ export default function ProfilesStackScreen({ navigation }) { } }) - const _handleSearch = () => console.log('Searching'); + const _handleSearch = () => { + console.log('Searching'); + navigation.navigate('ProfileModification') + } const _handleHeaderAdd = () => navigation.navigate('ProfileCreation'); return ( diff --git a/LeftOvers/screens/HomePage.tsx b/LeftOvers/screens/HomePage.tsx index e985087..1b73cb1 100644 --- a/LeftOvers/screens/HomePage.tsx +++ b/LeftOvers/screens/HomePage.tsx @@ -70,7 +70,7 @@ export default function HomePage({ navigation, props }) { }, filters: { fontSize: 20, - color: colors.cardTitle, + color: colors.cardElementBorder, flex: 1, }, nbSelected: { @@ -121,6 +121,16 @@ export default function HomePage({ navigation, props }) { } }); + const nbActiveProfiles = () => { + let cpt = 0 + profiles.forEach((val) => { + if(val.isActive == "flex"){ + cpt += 1 + } + }) + return cpt + } + return ( @@ -130,7 +140,7 @@ export default function HomePage({ navigation, props }) { Welcome - Rayhân + Louison , Glad to see you again! @@ -140,7 +150,7 @@ export default function HomePage({ navigation, props }) { Profiles - 2 selected + {nbActiveProfiles()} selected diff --git a/LeftOvers/screens/ModifyProfile.tsx b/LeftOvers/screens/ModifyProfile.tsx index 12ecf88..49043ff 100644 --- a/LeftOvers/screens/ModifyProfile.tsx +++ b/LeftOvers/screens/ModifyProfile.tsx @@ -15,12 +15,12 @@ export default function ModifyProfile(props) { return ( - + - (console.log("Profile Modified"))}> - + (console.log("Profile Modified"))}> + @@ -28,14 +28,6 @@ export default function ModifyProfile(props) { } const styles = StyleSheet.create({ - container: { - height: "100%", - width: "100%", - flex: 1, - backgroundColor: '#3F3C42', - alignItems: 'center', - justifyContent: 'center', - }, linearGradient: { height: "100%", width: "100%", diff --git a/LeftOvers/screens/Profiles.tsx b/LeftOvers/screens/Profiles.tsx index e5f2059..7f88ca0 100644 --- a/LeftOvers/screens/Profiles.tsx +++ b/LeftOvers/screens/Profiles.tsx @@ -168,10 +168,11 @@ export default function Profiles({navigation, props}) { avatar={profile.avatar} diets={profile.diets} allergies={profile.allergies} + onModification={() => navigation.navigate('ProfileModification')} onDeleteProfile={raisePopUp}/> - {index < profiles.length - 1 && } + {index < profiles.length - 1 && } - )); + )); return ( -- 2.36.3 From 53e39501f4ce5e3ccf55218b793f92d9ce3bae5a Mon Sep 17 00:00:00 2001 From: Rayhan Hassou Date: Fri, 1 Dec 2023 09:45:07 +0100 Subject: [PATCH 5/7] add deleting profils but modal for confirmation dont work --- LeftOvers/screens/Profiles.tsx | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/LeftOvers/screens/Profiles.tsx b/LeftOvers/screens/Profiles.tsx index 3705fc7..41ab36f 100644 --- a/LeftOvers/screens/Profiles.tsx +++ b/LeftOvers/screens/Profiles.tsx @@ -20,6 +20,7 @@ export default function Profiles({navigation, props}) { const [visible, setVisible] = useState(false); const [opacity, setOpacity] = useState(1); const [profiles, setProfiles] = useState([]); + const [selectedProfileIndex, setSelectedProfileIndex] = useState(null); const raisePopUp = () => { setVisible(true) @@ -30,14 +31,20 @@ export default function Profiles({navigation, props}) { setOpacity(1) } - const handleDeleteProfiles = async () => { + const handleDeleteProfile = async (index) => { try { - await AsyncStorage.removeItem('profiles'); - console.log('Données supprimées avec succès !'); + const updatedProfiles = profiles.filter((profile, i) => i !== index); + await AsyncStorage.setItem('profiles', JSON.stringify(updatedProfiles)); + setSelectedProfileIndex(index); + raisePopUp(); // Afficher la boîte de dialogue de confirmation après la suppression } catch (error) { - console.error('Erreur lors de la suppression des données :', error); + console.error('Erreur lors de la suppression du profil :', error); } - }; + }; + + const confirmDelete = () => { + erasePopUp(); + }; const handleGetProfiles = async () => { try { @@ -59,7 +66,6 @@ export default function Profiles({navigation, props}) { }); useEffect(() => { - handleDeleteProfiles(); fetchProfiles(); }, []); @@ -181,7 +187,7 @@ export default function Profiles({navigation, props}) { avatar={profile.avatar} diets={profile.diets} allergies={profile.allergies} - onDeleteProfile={() => raisePopUp()} // <- Modification ici + onDeleteProfile={() => handleDeleteProfile(index)} /> {index < profiles.length - 1 && } @@ -199,14 +205,19 @@ export default function Profiles({navigation, props}) { - {/* */} + Do you really want to delete this profile? - + - + Yes -- 2.36.3 From 4f165411daeffaf7b146783c5f5b6cf559e48296 Mon Sep 17 00:00:00 2001 From: Rayhan Hassou Date: Fri, 1 Dec 2023 13:34:46 +0100 Subject: [PATCH 6/7] deleting profil works --- LeftOvers/components/ListWithoutSelect.tsx | 9 +- LeftOvers/screens/Profiles.tsx | 113 +++++++++++++-------- 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/LeftOvers/components/ListWithoutSelect.tsx b/LeftOvers/components/ListWithoutSelect.tsx index 069534b..1944867 100644 --- a/LeftOvers/components/ListWithoutSelect.tsx +++ b/LeftOvers/components/ListWithoutSelect.tsx @@ -5,18 +5,13 @@ import ColorContext from '../theme/ColorContext'; type ListProps = { title: string - content: {value: string}[] + content: string[] } export default function ListWithoutSelect(props: ListProps) { const [selected, setSelected] = React.useState([]); const { colors } = useContext(ColorContext); - let listContent = [] - - props.content.forEach((val) => { - listContent.push({value: val.value, disabled: true}) - }) const styles = StyleSheet.create({ titleBar: { @@ -86,7 +81,7 @@ export default function ListWithoutSelect(props: ListProps) { return ( setSelected(val)} - data={listContent} + data={props.content} save="value" search={false} arrowicon={} diff --git a/LeftOvers/screens/Profiles.tsx b/LeftOvers/screens/Profiles.tsx index 9cb7e02..0047ae7 100644 --- a/LeftOvers/screens/Profiles.tsx +++ b/LeftOvers/screens/Profiles.tsx @@ -10,6 +10,7 @@ import ColorContext from '../theme/ColorContext'; import AsyncStorage from '@react-native-async-storage/async-storage'; import EventEmitter from './EventEmitter'; import Profil from '../Models/Profil'; +import { PaperProvider, Portal } from 'react-native-paper'; export default function Profiles({navigation, props}) { const { colors, toggleColors } = useContext(ColorContext) @@ -22,19 +23,30 @@ export default function Profiles({navigation, props}) { const [profiles, setProfiles] = useState([]); const [selectedProfileIndex, setSelectedProfileIndex] = useState(null); - const raisePopUp = () => { + const raisePopUp = (index) => { + setSelectedProfileIndex(index) setVisible(true) } const erasePopUp = () => { setVisible(false) } + const handleDeleteProfiles = async () => { + try { + await AsyncStorage.removeItem('profiles'); + console.log('Données supprimées avec succès !'); + } catch (error) { + console.error('Erreur lors de la suppression des données :', error); + } + }; + const handleDeleteProfile = async (index) => { try { const updatedProfiles = profiles.filter((profile, i) => i !== index); await AsyncStorage.setItem('profiles', JSON.stringify(updatedProfiles)); + fetchProfiles(); setSelectedProfileIndex(index); - raisePopUp(); // Afficher la boîte de dialogue de confirmation après la suppression + erasePopUp(); } catch (error) { console.error('Erreur lors de la suppression du profil :', error); } @@ -65,11 +77,16 @@ export default function Profiles({navigation, props}) { useEffect(() => { fetchProfiles(); + console.log(profiles) }, []); - + const containerStyle = { + height: "75%", + width: "100%", + }; - const styles = StyleSheet.create({ + + const styles = StyleSheet.create({ container: { height: "100%", width: "100%", @@ -120,11 +137,13 @@ export default function Profiles({navigation, props}) { borderRadius: 15, alignItems: "center", justifyContent: "center", - backgroundColor: "#F2F0E4", + backgroundColor: colors.cardBackground, + borderWidth: 1, + borderColor: colors.blocBorder, }, validationQuestion: { fontSize: 20, - color: '#ACA279', + color: colors.cardElementBorder, alignItems: 'center', justifyContent: 'center', flex: 0.3, @@ -147,7 +166,7 @@ export default function Profiles({navigation, props}) { borderRadius: 20, alignItems: "center", justifyContent: "center", - backgroundColor: "#59BDCD", + backgroundColor: colors.yesButton, }, yesText: { fontSize: 20, @@ -185,56 +204,60 @@ export default function Profiles({navigation, props}) { avatar={profile.avatar} diets={profile.diets} allergies={profile.allergies} - onDeleteProfile={() => handleDeleteProfile(index)} + onDeleteProfile={() => raisePopUp(index)} /> - {index < profiles.length - 1 && } - - )); - - return ( - - - - - - {profileComponents} + + - - - - - + + + {/* - - - Do you really want to delete this profile? - - - - - Yes - - - - - - No - - + /> */} + + + Do you really want to delete this profile? + + handleDeleteProfile(selectedProfileIndex)} style={{flex:0.5}}> + + + Yes + + + + + + No - + - + + + + {index < profiles.length - 1 && } + + )); + + + + return ( + + + + + + {profileComponents} - - + + + ); } \ No newline at end of file -- 2.36.3 From dcb7cee05795b4aafecd6b693f855d09c8e04947 Mon Sep 17 00:00:00 2001 From: Rayhan Hassou Date: Fri, 1 Dec 2023 15:02:57 +0100 Subject: [PATCH 7/7] try to bind images but it dont work --- LeftOvers/components/ProfileElement.tsx | 10 ++++------ LeftOvers/screens/CreateProfile.tsx | 12 ++++++------ LeftOvers/screens/Profiles.tsx | 5 ++--- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/LeftOvers/components/ProfileElement.tsx b/LeftOvers/components/ProfileElement.tsx index 25b9383..f3ab359 100644 --- a/LeftOvers/components/ProfileElement.tsx +++ b/LeftOvers/components/ProfileElement.tsx @@ -36,14 +36,12 @@ export default function ProfileElement(props : Profile) { } let imageSource - if (props.avatar == "plus.png"){ - imageSource = require('../assets/images/plus.png') - } - else if (props.avatar == "plus_small.png"){ - imageSource = require('../assets/images/plus_small.png') + if(props.avatar == null){ + console.log("NUUUULLLLLE" + props.avatar) } else{ - imageSource = require('../assets/images/logo.png') + imageSource = { uri: props.avatar }; + console.log("MAAARCHHEEE" + props.avatar) } const styles = StyleSheet.create({ diff --git a/LeftOvers/screens/CreateProfile.tsx b/LeftOvers/screens/CreateProfile.tsx index 06e41aa..8e6a161 100644 --- a/LeftOvers/screens/CreateProfile.tsx +++ b/LeftOvers/screens/CreateProfile.tsx @@ -31,9 +31,9 @@ export default function CreateProfile(props) { aspect: [4, 3], quality: 1, }); - + console.log(result); - + if (!result.canceled) { setAvatar(result.assets[0].uri); } @@ -42,13 +42,13 @@ export default function CreateProfile(props) { let imageSource if (props.avatar == "plus.png"){ - imageSource = require('../assets/images/plus.png') + imageSource = {uri: avatar} } else if (props.avatar == "plus_small.png"){ - imageSource = require('../assets/images/plus_small.png') + imageSource = {uri: avatar} } else{ - imageSource = require('../assets/images/logo.png') + imageSource = {uri: avatar} } const handleCreateProfile = async () => { @@ -169,7 +169,7 @@ export default function CreateProfile(props) { Filters - 0 diets selected + "0 diets selected diff --git a/LeftOvers/screens/Profiles.tsx b/LeftOvers/screens/Profiles.tsx index 0047ae7..e4580f7 100644 --- a/LeftOvers/screens/Profiles.tsx +++ b/LeftOvers/screens/Profiles.tsx @@ -211,13 +211,12 @@ export default function Profiles({navigation, props}) { - - {/* */} + /> */} Do you really want to delete this profile? -- 2.36.3