diff --git a/LeftOvers/assets/images/Carrot_Cake.png b/LeftOvers/assets/images/Carrot_Cake.png new file mode 100644 index 0000000..1b05ae8 Binary files /dev/null and b/LeftOvers/assets/images/Carrot_Cake.png differ diff --git a/LeftOvers/assets/images/Meat_and_Rice.png b/LeftOvers/assets/images/Meat_and_Rice.png new file mode 100644 index 0000000..4027f20 Binary files /dev/null and b/LeftOvers/assets/images/Meat_and_Rice.png differ diff --git a/LeftOvers/assets/images/Seafood_Rice.png b/LeftOvers/assets/images/Seafood_Rice.png new file mode 100644 index 0000000..a636688 Binary files /dev/null and b/LeftOvers/assets/images/Seafood_Rice.png differ diff --git a/LeftOvers/assets/images/cake.png b/LeftOvers/assets/images/cake.png new file mode 100644 index 0000000..652fc8c Binary files /dev/null and b/LeftOvers/assets/images/cake.png differ diff --git a/LeftOvers/assets/images/egg.png b/LeftOvers/assets/images/egg.png new file mode 100644 index 0000000..741e566 Binary files /dev/null and b/LeftOvers/assets/images/egg.png differ diff --git a/LeftOvers/assets/images/fish.png b/LeftOvers/assets/images/fish.png new file mode 100644 index 0000000..7fd29ae Binary files /dev/null and b/LeftOvers/assets/images/fish.png differ diff --git a/LeftOvers/assets/images/fish_meat.png b/LeftOvers/assets/images/fish_meat.png new file mode 100644 index 0000000..089ddd5 Binary files /dev/null and b/LeftOvers/assets/images/fish_meat.png differ diff --git a/LeftOvers/assets/images/inconnu.png b/LeftOvers/assets/images/inconnu.png new file mode 100644 index 0000000..ae701f4 Binary files /dev/null and b/LeftOvers/assets/images/inconnu.png differ diff --git a/LeftOvers/assets/images/meat_with_vegetables.png b/LeftOvers/assets/images/meat_with_vegetables.png new file mode 100644 index 0000000..c83cca6 Binary files /dev/null and b/LeftOvers/assets/images/meat_with_vegetables.png differ diff --git a/LeftOvers/assets/images/mushroom.png b/LeftOvers/assets/images/mushroom.png new file mode 100644 index 0000000..8f43efe Binary files /dev/null and b/LeftOvers/assets/images/mushroom.png differ diff --git a/LeftOvers/assets/images/noRecipes.jpg b/LeftOvers/assets/images/noRecipes.jpg new file mode 100644 index 0000000..d27b8a1 Binary files /dev/null and b/LeftOvers/assets/images/noRecipes.jpg differ diff --git a/LeftOvers/assets/images/pie.png b/LeftOvers/assets/images/pie.png new file mode 100644 index 0000000..7d45f3e Binary files /dev/null and b/LeftOvers/assets/images/pie.png differ diff --git a/LeftOvers/assets/images/pizza.png b/LeftOvers/assets/images/pizza.png new file mode 100644 index 0000000..45092ea Binary files /dev/null and b/LeftOvers/assets/images/pizza.png differ diff --git a/LeftOvers/assets/images/riceEgg.png b/LeftOvers/assets/images/riceEgg.png new file mode 100644 index 0000000..a8067f4 Binary files /dev/null and b/LeftOvers/assets/images/riceEgg.png differ diff --git a/LeftOvers/assets/images/rice_fish.png b/LeftOvers/assets/images/rice_fish.png new file mode 100644 index 0000000..4efa881 Binary files /dev/null and b/LeftOvers/assets/images/rice_fish.png differ diff --git a/LeftOvers/assets/images/rice_meat.png b/LeftOvers/assets/images/rice_meat.png new file mode 100644 index 0000000..4027f20 Binary files /dev/null and b/LeftOvers/assets/images/rice_meat.png differ diff --git a/LeftOvers/assets/images/rice_vegetables.png b/LeftOvers/assets/images/rice_vegetables.png new file mode 100644 index 0000000..a37a2fa Binary files /dev/null and b/LeftOvers/assets/images/rice_vegetables.png differ diff --git a/LeftOvers/assets/images/soupMeat.png b/LeftOvers/assets/images/soupMeat.png new file mode 100644 index 0000000..bba50ca Binary files /dev/null and b/LeftOvers/assets/images/soupMeat.png differ diff --git a/LeftOvers/assets/images/soupVeggie.png b/LeftOvers/assets/images/soupVeggie.png new file mode 100644 index 0000000..5d7e706 Binary files /dev/null and b/LeftOvers/assets/images/soupVeggie.png differ diff --git a/LeftOvers/assets/images/soupfish.png b/LeftOvers/assets/images/soupfish.png new file mode 100644 index 0000000..dd9c7fd Binary files /dev/null and b/LeftOvers/assets/images/soupfish.png differ diff --git a/LeftOvers/assets/images/vegan.png b/LeftOvers/assets/images/vegan.png new file mode 100644 index 0000000..8045ffd Binary files /dev/null and b/LeftOvers/assets/images/vegan.png differ diff --git a/LeftOvers/components/RecipeElement.tsx b/LeftOvers/components/RecipeElement.tsx index 4152ea1..929290d 100644 --- a/LeftOvers/components/RecipeElement.tsx +++ b/LeftOvers/components/RecipeElement.tsx @@ -1,12 +1,31 @@ -import React, {useContext} from 'react'; -import {StyleSheet, Pressable, Text, View, Image, ScrollView} from 'react-native'; +import React, {useContext, useState} from 'react'; +import {StyleSheet, Pressable, Text, View, Image, ScrollView, ImageSourcePropType} from 'react-native'; import brochette from '../assets/images/brochette.png'; import Union_left from '../assets/images/Union_left.png'; import Union_right from '../assets/images/Union_right.png'; import background from '../assets/images/Background.png'; +import cake from '../assets/images/cake.png'; +import Carrot_Cake from '../assets/images/Carrot_Cake.png'; +import inconnu from '../assets/images/inconnu.png'; +import fish from '../assets/images/fish.png'; +import fish_meat from '../assets/images/fish_meat.png'; +import vegan from '../assets/images/vegan.png'; +import egg from '../assets/images/egg.png'; +import pizza from '../assets/images/pizza.png'; +import soupVeggie from '../assets/images/soupVeggie.png'; +import soupFish from '../assets/images/soupfish.png' +import soupMeat from '../assets/images/soupMeat.png' +import meat_with_vegetable from '../assets/images/meat_with_vegetables.png'; +import riceVegetable from '../assets/images/rice_vegetables.png'; +import riceMeat from '../assets/images/Meat_and_Rice.png'; +import riceFish from '../assets/images/rice_fish.png'; +import riceEgg from '../assets/images/riceEgg.png'; import ColorContext from '../theme/ColorContext'; import Recipes from '../Models/Recipes'; + + + interface RecipeElementProps { recipe: Recipes navigateDetails: any @@ -24,6 +43,90 @@ function convertToHoursMinutes(totalMinutes: number): string { export default function RecipeElement(props: RecipeElementProps) { const {colors} = useContext(ColorContext) + const meatDictionary: string[] = ["beef", "chicken", "turkey", "steak", "rabbit", "duck"] + const porkDictionary: string[] = ["pork", "lardon", "bacon", "ham"] + const fishDictionary: string[] = ["tuna", "whiting", "mullet", "sardine", "mackerel", "salmon", "monkfish", "conger", "bass", "cod", "hake"] + const vegetablesDictionary: string[] = ["artichoke", "aubergine", "beet", "chard", "broccoli", "carrot", "celery", "cabbage", "cauliflower", "zucchini", "spinach", "fennel", "curly", "bean", "lettuce", "apple", "lettuce", "corn", "onion", "parsnips", "leek", "pepper", "potato", "pumpkin", "radish", "scarole", "tomato"] + const riceDictionary: string[] = ['rice', 'quinoa', 'barley'] + const eggDictionary: string[] = ['egg', 'omelette']; + const soupDictionary: string[] = ['soup']; + const pizzaDictionary: string[] = ['pizza']; + + const dessertDictionary: string[] = ['cake', 'cupcake', 'muffin', 'cookie', 'brownie', 'pie', 'tart', 'macaron', 'doughnut', 'eclair', 'pancake', 'waffle', 'crepe', 'pudding', 'gelato', 'sorbet', 'ice cream', 'cheesecake']; + + const imagesDictionary = { + meat: meatDictionary, + pork: porkDictionary, + fish: fishDictionary, + vegetables: vegetablesDictionary, + rice: riceDictionary, + MeatAndVegetables: [...meatDictionary, ...vegetablesDictionary], + FishAndMeat: [...fishDictionary, ...meatDictionary], + egg: eggDictionary, + dessertDictionary: dessertDictionary, + fruitCake : [...vegetablesDictionary, ...dessertDictionary], + riceEgg : [...riceDictionary, ...eggDictionary], + riceMeat : [...riceDictionary, ...meatDictionary], + riceFish : [...riceDictionary, ...fishDictionary], + riceVegetable : [...riceDictionary, ...vegetablesDictionary], + // pizzaMeat : [...pizzaDictionary, ...meatDictionary], + // pizzaVeggie : [...riceDictionary, ...vegetablesDictionary], + // pizzaFish : [...riceDictionary, ...fishDictionary], + pizza : pizzaDictionary, + soupMeat : [...soupDictionary, ...meatDictionary], + soupVeggie : [...soupDictionary, ...vegetablesDictionary], + soupFish : [...soupDictionary, ...fishDictionary], + unknown: [], + }; + + function getImageForRecipe(recipeName: string) { + for (const [category, words] of Object.entries(imagesDictionary)) { + const matchedWords = words.filter((word) => recipeName.toLowerCase().includes(word)); + if (matchedWords.length > 0) { + switch (category) { + case 'meat': + return meat_with_vegetable; + case 'pork': + return brochette; + case 'fish': + return fish; + case 'vegetables': + return vegan; + case 'MeatAndVegetables': + return meat_with_vegetable; // Choisis l'image appropriée + case 'FishAndMeat': + return fish_meat; // Choisis l'image appropriée + case 'egg': + return egg; // Choisis l'image appropriée + case 'dessert': + return cake; // Choisis l'image appropriée + case 'fruitCake': + return Carrot_Cake; // Choisis l'image appropriée + case 'riceEgg': + return riceEgg; // Choisis l'image appropriée + case 'riceMeat': + return riceMeat; // Choisis l'image appropriée + case 'riceFish': + return riceFish; // Choisis l'image appropriée + case 'riceVegetable': + return riceVegetable; // Choisis l'image appropriée + case 'pizza': + return pizza; + case 'soupVeggie': + return soupVeggie; + case 'soupMeat': + return soupMeat; + case 'soupFish': + return soupFish; + default: + return inconnu; + } + } + } + return inconnu; + } + + const styles = StyleSheet.create({ button: { @@ -87,7 +190,7 @@ export default function RecipeElement(props: RecipeElementProps) { {props.recipe.id} {props.recipe.name} - + Ingredients diff --git a/LeftOvers/screens/IngredientSelection.tsx b/LeftOvers/screens/IngredientSelection.tsx index e3ca9b9..f8f7461 100644 --- a/LeftOvers/screens/IngredientSelection.tsx +++ b/LeftOvers/screens/IngredientSelection.tsx @@ -14,6 +14,7 @@ import EventEmitter from './EventEmitter'; import plus from '../assets/images/plus.png'; import moins from '../assets/images/minus.png'; +import { ScrollView } from 'react-native-virtualized-view'; export default function IngredientSelection(props) { const colors = useContext(ColorContext).colors