Last active
April 5, 2022 10:23
-
-
Save cp-radhika-s/ebe2ab119c58d72fbcbb8b00766f2fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PersonCard(person: Person) { | |
val foodItems = remember { | |
mutableStateMapOf<Int, FoodItem>() | |
} | |
DropTarget<FoodItem>( | |
modifier = Modifier | |
.padding(6.dp) | |
.width(width = 120.dp) | |
.fillMaxHeight(0.8f) | |
) { isInBound, foodItem -> | |
val bgColor = if (isInBound) Color.Red else Color.White | |
foodItem?.let { | |
if (isInBound) | |
foodItems[foodItem.id] = foodItem | |
} | |
Column( | |
modifier = Modifier.background( bgColor, RoundedCornerShape(16.dp)), | |
) { | |
// ...User Image and name Text views | |
if (foodItems.isNotEmpty()) { | |
Text( | |
text = "$${foodItems.values.sumOf { it.price}}", | |
fontSize = 16.sp, | |
color = Color.Black, | |
fontWeight = FontWeight.ExtraBold | |
) | |
Text( | |
text = "${foodItems.size} Items", | |
fontSize = 14.sp, | |
color = Color.Black | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment