Skip to content

Commit

Permalink
feat: ✨ show all ingredients on the recipe page
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-software committed Nov 5, 2022
1 parent f6c80b1 commit 94e9de3
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/screens/recipe/recipe-ingredients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import React, { ReactElement } from 'react'
import { recipe_recipe_data_ingredients } from '@greeneggs/types/graphql'
import { View } from 'react-native'
import { Divider } from '@ui-kitten/components'
import { IngredientListItem, ViewMore } from '@greeneggs/ui'
import { useNavigation } from '@react-navigation/core'
import { LoggedInNavigationProp } from '@greeneggs/navigation/routes/logged-in-routes'
import { IngredientListItem } from '@greeneggs/ui'

interface IRecipeIngredients {
ingredients: recipe_recipe_data_ingredients[]
Expand All @@ -23,14 +20,13 @@ export function RecipeIngredients({
servingCount,
defaultServingCount,
}: IRecipeIngredients): ReactElement {
const navigation = useNavigation<LoggedInNavigationProp>()
let multiplier = 1
if (servingCount && defaultServingCount) {
multiplier = servingCount / defaultServingCount
}
return (
<View style={{ marginHorizontal: -16 }}>
{ingredients.slice(0, 5).map((ingredient: recipe_recipe_data_ingredients, index) => (
{ingredients.map((ingredient: recipe_recipe_data_ingredients, index) => (
<IngredientListItem
ingredient={{
...ingredient,
Expand All @@ -39,15 +35,6 @@ export function RecipeIngredients({
key={index.toString()}
/>
))}
<Divider />
<ViewMore
onPress={() =>
navigation.navigate('RecipeAllIngredients', {
ingredients,
multiplier,
})
}
/>
</View>
)
}

0 comments on commit 94e9de3

Please sign in to comment.