diff --git a/app/src/main/java/com/juceliodev/fooddeliverymyapplication/data/ProductFlaworData.kt b/app/src/main/java/com/juceliodev/fooddeliverymyapplication/data/ProductFlaworData.kt new file mode 100644 index 0000000..10fefbb --- /dev/null +++ b/app/src/main/java/com/juceliodev/fooddeliverymyapplication/data/ProductFlaworData.kt @@ -0,0 +1,28 @@ +package com.juceliodev.fooddeliverymyapplication.data + +import androidx.annotation.DrawableRes +import com.juceliodev.fooddeliverymyapplication.R + +data class ProductFlavorState( + val name: String, + val price: String, + @DrawableRes val imgRes: Int +) + +val ProductFlavorsData = listOf( + ProductFlavorState( + imgRes = R.drawable.img_cheese, + name = "Chedder", + price = "$0.79" + ), + ProductFlavorState( + imgRes = R.drawable.img_bacon, + name = "Bacon", + price = "$0.52" + ), + ProductFlavorState( + imgRes = R.drawable.img_onion, + name = "Onion", + price = "$0.28" + ) +) \ No newline at end of file diff --git a/app/src/main/java/com/juceliodev/fooddeliverymyapplication/ui/screen/ProductDetailsScreen.kt b/app/src/main/java/com/juceliodev/fooddeliverymyapplication/ui/screen/ProductDetailsScreen.kt new file mode 100644 index 0000000..ff51538 --- /dev/null +++ b/app/src/main/java/com/juceliodev/fooddeliverymyapplication/ui/screen/ProductDetailsScreen.kt @@ -0,0 +1,109 @@ +package com.juceliodev.fooddeliverymyapplication.ui.screen + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.juceliodev.fooddeliverymyapplication.ui.screen.components.OrderActionBar +import com.juceliodev.fooddeliverymyapplication.data.OrderData +import com.juceliodev.fooddeliverymyapplication.data.OrderState +import com.juceliodev.fooddeliverymyapplication.data.ProductDescriptionData +import com.juceliodev.fooddeliverymyapplication.data.ProductFlavorState +import com.juceliodev.fooddeliverymyapplication.data.ProductFlavorsData +import com.juceliodev.fooddeliverymyapplication.data.ProductNutritionData +import com.juceliodev.fooddeliverymyapplication.data.ProductNutritionState +import com.juceliodev.fooddeliverymyapplication.data.ProductPreviewState +import com.juceliodev.fooddeliverymyapplication.ui.screen.components.FlavorSection +import com.juceliodev.fooddeliverymyapplication.ui.screen.components.ProductDescriptionSection +import com.juceliodev.fooddeliverymyapplication.ui.screen.components.ProductNutritionSection +import com.juceliodev.fooddeliverymyapplication.ui.screen.components.ProductPreviewSection + + +@Composable +fun ProductDetailsScreen( + modifier: Modifier = Modifier, + productPreviewState: ProductPreviewState = ProductPreviewState(), + productFlavors: List = ProductFlavorsData, + productNutritionState: ProductNutritionState = ProductNutritionData, + productDescription: String = ProductDescriptionData, + orderState: OrderState = OrderData, + onAddItemClicked: () -> Unit = {}, + onRemoveItemClicked: () -> Unit = {}, + onCheckOutClicked: () -> Unit = {} +) { + Box( + modifier = modifier.fillMaxSize(), + contentAlignment = Alignment.BottomCenter + ) { + Content( + productDescription = productDescription, + productFlavors = productFlavors, + productNutritionState = productNutritionState, + productPreviewState = productPreviewState, + ) + OrderActionBar( + state = orderState, + onAddItemClicked = onAddItemClicked, + onRemoveItemClicked = onRemoveItemClicked, + onCheckOutClicked = onCheckOutClicked, + modifier = Modifier + .navigationBarsPadding() + .padding( + horizontal = 18.dp, + vertical = 8.dp + ) + ) + } +} + +@Composable +private fun Content( + modifier: Modifier = Modifier, + productPreviewState: ProductPreviewState, + productFlavors: List, + productNutritionState: ProductNutritionState, + productDescription: String +) { + val scrollState = rememberScrollState() + + Column( + modifier = modifier.verticalScroll(scrollState) + ) { + ProductPreviewSection( + state = productPreviewState + ) + Spacer( + modifier = Modifier.height(16.dp) + ) + FlavorSection( + data = productFlavors, + modifier = Modifier.padding(horizontal = 18.dp) + ) + Spacer( + modifier = Modifier.height(16.dp) + ) + ProductNutritionSection( + state = productNutritionState, + modifier = Modifier.padding(horizontal = 18.dp) + ) + Spacer( + modifier = Modifier.height(32.dp) + ) + ProductDescriptionSection( + productDescription = productDescription, + modifier = Modifier + .navigationBarsPadding() + .padding(horizontal = 18.dp) + .padding(bottom = 128.dp) + ) + } +} \ No newline at end of file