From 715b591b8ae1a5834280a8999476ce34af054a81 Mon Sep 17 00:00:00 2001 From: ankitsaraf Date: Fri, 19 Dec 2025 21:20:13 +0530 Subject: [PATCH] Minor fixes --- .../ui/components/BuyAnimalCard.kt | 25 +++-- .../livingai_lg/ui/components/InfoTooltip.kt | 99 +++++++++++++++++++ .../example/livingai_lg/ui/models/Animal.kt | 4 + .../ui/navigation/AppNavigation.kt | 2 +- 4 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/example/livingai_lg/ui/components/InfoTooltip.kt diff --git a/app/src/main/java/com/example/livingai_lg/ui/components/BuyAnimalCard.kt b/app/src/main/java/com/example/livingai_lg/ui/components/BuyAnimalCard.kt index e3c7a0d..35f4fd5 100644 --- a/app/src/main/java/com/example/livingai_lg/ui/components/BuyAnimalCard.kt +++ b/app/src/main/java/com/example/livingai_lg/ui/components/BuyAnimalCard.kt @@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Info +import androidx.compose.material.icons.outlined.Info import androidx.compose.material.icons.outlined.LocationOn import androidx.compose.material.icons.outlined.Visibility import androidx.compose.material3.Icon @@ -153,12 +155,23 @@ fun BuyAnimalCard( horizontalArrangement = Arrangement.SpaceBetween ) { Column { - Text( - product.name ?: "", - fontSize = AppTypography.Body, - fontWeight = FontWeight.Medium - ) - Text( + Row { + Text( + product.breed ?: "", + fontSize = AppTypography.Body, + fontWeight = FontWeight.Medium + ) + Icon( + imageVector = Icons.Outlined.Info, + contentDescription = null, + Modifier.padding(horizontal = 4.dp).size(16.dp).align(Alignment.CenterVertically), + + ) + + //InfoIconWithOverlay(infoText = product.breedInfo ?: "") + } + + Text( formatPrice(product.price), fontSize = AppTypography.Body, fontWeight = FontWeight.Medium diff --git a/app/src/main/java/com/example/livingai_lg/ui/components/InfoTooltip.kt b/app/src/main/java/com/example/livingai_lg/ui/components/InfoTooltip.kt new file mode 100644 index 0000000..4f2a795 --- /dev/null +++ b/app/src/main/java/com/example/livingai_lg/ui/components/InfoTooltip.kt @@ -0,0 +1,99 @@ +package com.example.livingai_lg.ui.components + +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.offset +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Info +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.TooltipBox +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.filled.Info +import androidx.compose.material3.Text +import androidx.compose.material3.TooltipDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +import androidx.compose.ui.Modifier +import androidx.compose.ui.zIndex + +@Composable +fun InfoTooltipOverlay( + text: String, + visible: Boolean, + onDismiss: () -> Unit +) { + if (!visible) return + + Box( + modifier = Modifier + .fillMaxSize() + .zIndex(100f) // ensure it overlays everything + ) { + // Dimmed background + Box( + modifier = Modifier + .fillMaxSize() + .background(Color.Black.copy(alpha = 0.35f)) + .clickable( + indication = null, + interactionSource = remember { MutableInteractionSource() } + ) { + onDismiss() + } + ) + + // Tooltip card + Box( + modifier = Modifier + .align(Alignment.Center) + .background(Color.Black, RoundedCornerShape(12.dp)) + .padding(horizontal = 16.dp, vertical = 12.dp) + ) { + Text( + text = text, + color = Color.White, + fontSize = 13.sp, + lineHeight = 18.sp + ) + } + } +} + +@Composable +fun InfoIconWithOverlay( + infoText: String +) { + var showInfo by remember { mutableStateOf(false) } + + Box { + Icon( + imageVector = Icons.Default.Info, + contentDescription = "Info", + tint = Color.Gray, + modifier = Modifier + .size(18.dp) + .clickable { showInfo = true } + ) + + InfoTooltipOverlay( + text = infoText, + visible = showInfo, + onDismiss = { showInfo = false } + ) + } +} diff --git a/app/src/main/java/com/example/livingai_lg/ui/models/Animal.kt b/app/src/main/java/com/example/livingai_lg/ui/models/Animal.kt index b6d6df8..657dc4a 100644 --- a/app/src/main/java/com/example/livingai_lg/ui/models/Animal.kt +++ b/app/src/main/java/com/example/livingai_lg/ui/models/Animal.kt @@ -5,6 +5,7 @@ data class Animal( val name: String? = null, val age: Int? = null, val breed: String? = null, + val breedInfo: String? = null, val price: Long? = null, val isFairPrice: Boolean? = null, val imageUrl: List? = null, @@ -28,6 +29,7 @@ val sampleAnimals = listOf( name = "Rita", age = 45, breed = "Gir", + breedInfo = "The 2nd best in India", location = "Punjab", distance = 12000, imageUrl = listOf("https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2F4.bp.blogspot.com%2F_tecSnxaePMo%2FTLLVknW8dOI%2FAAAAAAAAACo%2F_kd1ZNBXU1o%2Fs1600%2FGIR%2CGujrat.jpg&f=1&nofb=1&ipt=da6ba1d040c396b64d3f08cc99998f66200dcd6c001e4a56def143ab3d1a87ea","https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcpimg.tistatic.com%2F4478702%2Fb%2F4%2Fgir-cow.jpg&f=1&nofb=1&ipt=19bf391461480585c786d01433d863a383c60048ac2ce063ce91f173e215205d"), @@ -49,6 +51,7 @@ val sampleAnimals = listOf( price = 95000, age = 35, breed = "Sahiwal", + breedInfo = "The 2nd best in India", location = "Punjab", isFairPrice = true, imageUrl = listOf("https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcdnbbsr.s3waas.gov.in%2Fs3a5a61717dddc3501cfdf7a4e22d7dbaa%2Fuploads%2F2020%2F09%2F2020091812-1024x680.jpg&f=1&nofb=1&ipt=bb426406b3747e54151e4812472e203f33922fa3b4e11c4feef9aa59a5733146"), @@ -67,6 +70,7 @@ val sampleAnimals = listOf( name = "Bessie", age = 48, breed = "Holstein Friesian", + breedInfo = "Not Indian", location = "Punjab", distance = 12000, imageUrl = listOf("https://api.builder.io/api/v1/image/assets/TEMP/885e24e34ede6a39f708df13dabc4c1683c3e976?width=786"), diff --git a/app/src/main/java/com/example/livingai_lg/ui/navigation/AppNavigation.kt b/app/src/main/java/com/example/livingai_lg/ui/navigation/AppNavigation.kt index 6db3550..20b7b92 100644 --- a/app/src/main/java/com/example/livingai_lg/ui/navigation/AppNavigation.kt +++ b/app/src/main/java/com/example/livingai_lg/ui/navigation/AppNavigation.kt @@ -96,7 +96,7 @@ object AppScreen { object Graph { const val AUTH = "auth" - const val MAIN = "main" + const val MAIN = "auth" fun auth(route: String)= "$AUTH/$route"