Skip to content

Commit

Permalink
added README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ifechukwu committed Jun 17, 2022
1 parent e7d276c commit 566b5a9
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,152 +60,153 @@ fun DetailScreen(
.background(OffWhite)
.padding(bottom = 50.dp)
) {
Column {
detailScreenState.mealDetail?.let { mealDetail ->
val ingredients = viewModel.extractIngredientsFromDetails(mealDetail)
detailScreenState.mealDetail?.let { mealDetail ->
val ingredients = viewModel.extractIngredientsFromDetails(mealDetail)

LazyColumn(modifier = Modifier
LazyColumn(
modifier = Modifier
.fillMaxSize(),
content = {
item {
AsyncImage(
model = mealDetail.strMealThumb,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(250.dp),
contentScale = ContentScale.Crop
)
}
item {
Spacer(modifier = Modifier.height(10.dp))
Text(
text = mealDetail.strMeal,
style = MaterialTheme.typography.h1,
fontSize = 20.sp,
color = Black,
modifier = Modifier.padding(horizontal = 15.dp)
)

Spacer(modifier = Modifier.height(5.dp))
Text(
text = "Category: ${mealDetail.strCategory}",
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(horizontal = 15.dp)
)
}

item {
Spacer(modifier = Modifier.height(20.dp))

IngredientSection(ingredients)
}
content = {
item {
AsyncImage(
model = mealDetail.strMealThumb,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(250.dp),
contentScale = ContentScale.Crop
)
}
item {
Spacer(modifier = Modifier.height(10.dp))
Text(
text = mealDetail.strMeal,
style = MaterialTheme.typography.h1,
fontSize = 20.sp,
color = Black,
modifier = Modifier.padding(horizontal = 15.dp)
)

Spacer(modifier = Modifier.height(5.dp))
Text(
text = "Category: ${mealDetail.strCategory}",
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(horizontal = 15.dp)
)
}

item {
Spacer(modifier = Modifier.height(20.dp))

IngredientSection(ingredients)
}

// item {
// Spacer(modifier = Modifier.height(20.dp))
// InstructionSection(mealDetail)
// }

item {
Button(
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = Red,
contentColor = White
item {
Spacer(modifier = Modifier.height(20.dp))

Button(
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = Red,
contentColor = White
),
modifier = Modifier
.fillMaxWidth()
.padding(
top = 20.dp,
bottom = 10.dp,
start = 15.dp,
end = 15.dp
),
modifier = Modifier
.fillMaxWidth()
.padding(
top = 20.dp,
bottom = 10.dp,
start = 15.dp,
end = 15.dp
),
shape = RoundedCornerShape(5.dp),
onClick = {
watchYoutubeVideo(context, mealDetail.strYoutube)
}) {
Text(
text = "Watch Video",
style = MaterialTheme.typography.body1,
color = White
)
}
shape = RoundedCornerShape(5.dp),
onClick = {
watchYoutubeVideo(context, mealDetail.strYoutube)
}) {
Text(
text = "Watch Video",
style = MaterialTheme.typography.body1,
color = White
)
}
})
}
}
})
}

if (detailScreenState.error.isNotBlank()) {
Text(
text = detailScreenState.error,
color = MaterialTheme.colors.error,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
.align(Alignment.Center)
)
}
if (detailScreenState.error.isNotBlank()) {
Text(
text = detailScreenState.error,
color = MaterialTheme.colors.error,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
.align(Alignment.Center)
)
}

if (detailScreenState.isLoading) {
CircularProgressIndicator(
color = Red,
modifier = Modifier.align(Alignment.Center)
)
}
if (detailScreenState.isLoading) {
CircularProgressIndicator(
color = Red,
modifier = Modifier.align(Alignment.Center)
)
}
}

}

@Composable
fun InstructionSection(mealDetail: MealDetail) {
Column(
horizontalAlignment = Alignment.Start,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
) {
Text(
text = "Instructions",
style = MaterialTheme.typography.h2,
fontSize = 20.sp,
color = Black
)

Text(
text = mealDetail.strInstructions,
style = MaterialTheme.typography.body1,
)
}
}

@Composable
fun InstructionSection(mealDetail: MealDetail) {
Column(
horizontalAlignment = Alignment.Start,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
) {
Text(
text = "Instructions",
style = MaterialTheme.typography.h2,
fontSize = 20.sp,
color = Black
)

Text(
text = mealDetail.strInstructions,
style = MaterialTheme.typography.body1,
)
}
}

@Composable
fun IngredientSection(ingredients: MutableList<String>) {
Column(
horizontalAlignment = Alignment.Start,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
.height(300.dp)
) {
Text(
text = "Ingredients",
style = MaterialTheme.typography.h2,
fontSize = 20.sp,
color = Black
)
LazyVerticalGrid(
verticalArrangement = Arrangement.spacedBy(20.dp),
horizontalArrangement = Arrangement.SpaceBetween,
columns = GridCells.Fixed(2),
content = {
items(ingredients) { ingredient ->
IngredientsItem(ingredient = ingredient)
}
})
}
@Composable
fun IngredientSection(ingredients: MutableList<String>) {
Column(
horizontalAlignment = Alignment.Start,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 15.dp)
.height(300.dp)
) {
Text(
text = "Ingredients",
style = MaterialTheme.typography.h2,
fontSize = 20.sp,
color = Black
)
LazyVerticalGrid(
verticalArrangement = Arrangement.spacedBy(20.dp),
horizontalArrangement = Arrangement.SpaceBetween,
columns = GridCells.Fixed(2),
content = {
items(ingredients) { ingredient ->
IngredientsItem(ingredient = ingredient)
}
})
}
}


Binary file modified images/app_screens.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 566b5a9

Please sign in to comment.