@ -1,5 +1,5 @@
import React , { useContext } from 'react' ;
import React , { useContext , useState } from 'react' ;
import { StyleSheet , Pressable , Text , View , Image , ScrollView } from 'react-native' ;
import { StyleSheet , Pressable , Text , View , Image , ScrollView , ImageSourcePropType } from 'react-native' ;
import brochette from '../assets/images/brochette.png' ;
import brochette from '../assets/images/brochette.png' ;
import Union_left from '../assets/images/Union_left.png' ;
import Union_left from '../assets/images/Union_left.png' ;
import Union_right from '../assets/images/Union_right.png' ;
import Union_right from '../assets/images/Union_right.png' ;
@ -22,6 +22,8 @@ import riceFish from '../assets/images/rice_fish.png';
import riceEgg from '../assets/images/riceEgg.png' ;
import riceEgg from '../assets/images/riceEgg.png' ;
import pasta from '../assets/images/pasta.png' ;
import pasta from '../assets/images/pasta.png' ;
import ColorContext from '../theme/ColorContext' ;
import ColorContext from '../theme/ColorContext' ;
import fruit from '../assets/images/fruit.png' ;
import fruitCake from '../assets/images/fruitcake.png' ;
import Recipes from '../Models/Recipes' ;
import Recipes from '../Models/Recipes' ;
@ -44,13 +46,25 @@ function convertToHoursMinutes(totalMinutes: number): string {
export default function RecipeElement ( props : RecipeElementProps ) {
export default function RecipeElement ( props : RecipeElementProps ) {
const { colors } = useContext ( ColorContext )
const { colors } = useContext ( ColorContext )
const meatDictionary : string [ ] = [ "beef" , "chicken" , "turkey" , "steak" , "rabbit" , "duck" ]
const meatDictionary : string [ ] = [ "beef" , "chicken" , "turkey" , "steak" , "rabbit" , "duck" , "horse" ]
const porkDictionary : string [ ] = [ "pork" , "lardon" , "bacon" , "ham" ]
const porkDictionary : string [ ] = [ "pork" , "lardon" , "bacon" , "ham" , "pig" ]
const fishDictionary : string [ ] = [ "tuna" , "whiting" , "mullet" , "sardine" , "mackerel" , "salmon" , "monkfish" , "conger" , "bass" , "cod" , "hake" ]
const fishDictionary : string [ ] = [ "tuna" , "whiting" , "mullet" , "sardine" , "mackerel" , "salmon" , "monkfish" , "conger" , "bass" , "cod" , "hake" ]
const vegetablesDictionary : string [ ] = [ "vegan" , "vegetarian" , "lentil" , "artichoke" , "aubergine" , "beet" , "chard" , "broccoli" , "carrot" , "celery" , "cabbage" , "cauliflower" , "zucchini" , "spinach" , "fennel" , "curly" , "bean" , "lettuce" , "apple" , "corn" , "onion" , "parsnips" , "leek" , "pepper" , "potato" , "pumpkin" , "radish" , "scarole" , "tomato" ]
const vegetablesDictionary : string [ ] = [ "vegan" , "vegetarian" , "lentil" , "artichoke" , "aubergine" , "beet" , "chard" , "broccoli" , "carrot" , "celery" , "cabbage" , "cauliflower" , "zucchini" , "spinach" , "fennel" , "curly" , "bean" , "lettuce" , "apple" , "corn" , "onion" , "parsnips" , "leek" , "pepper" , "potato" , "pumpkin" , "radish" , "scarole" , "tomato" ]
const riceDictionary : string [ ] = [ "ric" , "quinoa" ]
const fruitDictionnary : string [ ] = [
"fruit" ,
"berries" ,
"apple" ,
"banana" ,
"orange" ,
"grapes" ,
"strawberry" ,
"pineapple" ,
"watermelon" ,
"kiwi"
] ;
const riceDictionary : string [ ] = [ "rice" , "quinoa" ]
const eggDictionary : string [ ] = [ "egg" , "omelette" ] ;
const eggDictionary : string [ ] = [ "egg" , "omelette" ] ;
const soupDictionary : string [ ] = [ "soup" ] ;
const soupDictionary : string [ ] = [ "soup" , "ragout" ];
const pizzaDictionary : string [ ] = [ "pizza" ] ;
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' , 'sugar' ] ;
const dessertDictionary : string [ ] = [ 'cake' , 'cupcake' , 'muffin' , 'cookie' , 'brownie' , 'pie' , 'tart' , 'macaron' , 'doughnut' , 'eclair' , 'pancake' , 'waffle' , 'crepe' , 'pudding' , 'gelato' , 'sorbet' , 'ice cream' , 'cheesecake' , 'sugar' ] ;
const pastaDictionary : string [ ] = [
const pastaDictionary : string [ ] = [
@ -83,6 +97,7 @@ export default function RecipeElement(props: RecipeElementProps) {
soup : soupDictionary ,
soup : soupDictionary ,
dessert : dessertDictionary ,
dessert : dessertDictionary ,
pasta : pastaDictionary ,
pasta : pastaDictionary ,
fruit : fruitDictionnary ,
unknown : [ ] ,
unknown : [ ] ,
} ;
} ;
@ -99,6 +114,7 @@ export default function RecipeElement(props: RecipeElementProps) {
soupMeat : [ 'soup' , 'meat' ] ,
soupMeat : [ 'soup' , 'meat' ] ,
soupVeggie : [ 'soup' , 'vegetables' ] ,
soupVeggie : [ 'soup' , 'vegetables' ] ,
soupFish : [ 'soup' , 'fish' ] ,
soupFish : [ 'soup' , 'fish' ] ,
fruitDessert : [ 'fruit' , 'dessert' ]
} ;
} ;
if ( categories . length == 1 ) {
if ( categories . length == 1 ) {
@ -168,6 +184,10 @@ export default function RecipeElement(props: RecipeElementProps) {
return soupMeat ;
return soupMeat ;
case 'soupFish' :
case 'soupFish' :
return soupFish ;
return soupFish ;
case 'fruitDessert' :
return fruitCake ;
case 'fruit' :
return fruit ;
default :
default :
return inconnu ;
return inconnu ;
}
}
@ -255,7 +275,7 @@ export default function RecipeElement(props: RecipeElementProps) {
< Text style = { styles . text } > Description < / Text >
< Text style = { styles . text } > Description < / Text >
< Image source = { Union_right } style = { { width : "27%" , marginLeft : "3%" , resizeMode : "contain" } } / >
< Image source = { Union_right } style = { { width : "27%" , marginLeft : "3%" , resizeMode : "contain" } } / >
< / View >
< / View >
< ScrollView style = { { marginTop : "3%" , overflow : "hidden" , maxHeight : 70 }} >
< ScrollView style = { { marginTop : "3%" , overflow : "hidden" }} >
< Text style = { styles . smallText } > { props . recipe . description } < / Text >
< Text style = { styles . smallText } > { props . recipe . description } < / Text >
< / ScrollView >
< / ScrollView >
< / View >
< / View >
@ -263,5 +283,7 @@ export default function RecipeElement(props: RecipeElementProps) {
< Text style = { styles . duration } > { convertToHoursMinutes ( props . recipe . time_to_cook ) } < / Text >
< Text style = { styles . duration } > { convertToHoursMinutes ( props . recipe . time_to_cook ) } < / Text >
< / View >
< / View >
< / Pressable >
< / Pressable >
) ;
) ;
}
}