Rohit Neel
06/26/2024, 10:59 AMAsyncImage
composable to load images, a green line appears on the edges of images. However, this issue does not occur when I use GlideImage
. For more reference, the issue image and code are added in this chat thread 🧵.
Could anyone help, why this green line might be appearing and how to fix it?Rohit Neel
06/26/2024, 10:59 AMRohit Neel
06/26/2024, 11:01 AMRohit Neel
06/27/2024, 10:06 AMAlexandru Gheorghe
06/27/2024, 2:51 PMRohit Neel
06/27/2024, 2:53 PMAlexandru Gheorghe
06/27/2024, 2:53 PMcustomAsyncImageDisplay
?Rohit Neel
06/27/2024, 2:54 PMAlexandru Gheorghe
06/27/2024, 2:55 PMRohit Neel
06/27/2024, 3:17 PMconst val CATEGORY_CARD_ASPECT_RATIO = 1f
@Composable
fun CommonImage(
modifier: Modifier = Modifier,
eciImageVideoModel: EciImageVideoDisplay,
) {
val screenWidth = LocalDensity.current.run { LocalConfiguration.current.screenWidthDp.dp }
val widthByType = screenWidth / eciImageVideoModel.mediaElements
val dynamicAspect =
modifier
.width(widthByType)
.aspectRatio(eciImageVideoModel.aspectRatio)
Box(
modifier =
dynamicAspect
.clickable {
eciImageVideoModel.onClick()
},
) {
if (eciImageVideoModel.backgroundVideo == null && eciImageVideoModel.backgroundImage != null) {
CustomAsyncImage(
customAsyncImageDisplay =
CusAsyncImageDisplay(
aspectRatio = eciImageVideoModel.aspectRatio,
imageUrl = eciImageVideoModel.backgroundImage,
contentScale = if (eciImageVideoModel.aspectRatio > FULL_ASPECT_RATIO) ContentScale.FillWidth else ContentScale.FillHeight,
contentDescription = eciImageVideoModel.imageContentDescription,
),
)
@Composable
fun *OnMediaType*(
navigationItem: NavigationModel,
mediaElements: Int,
aspectRatio: Float = _CATEGORY_CARD_ASPECT_RATIO_,
) {
val backgroundColor = _parseColorOrNull_(navigationItem.background) ?: Color.Transparent
val modifier =
Modifier
._background_(backgroundColor)
CommonImage(
customImageVideoModel =
CustomImageVideoDisplay(
mediaElements = mediaElements,
backgroundImage = navigationItem.picture?.source,
label = navigationItem.label?.text,
labelColor = navigationItem.label?.color,
backgroundColor = navigationItem.background,
position = navigationItem.label?.position?.let { fromPositionName(it.positionName) },
backgroundVideo = navigationItem.video?.source,
resizeMode = AspectRatioFrameLayout._RESIZE_MODE_FILL_,
onClick = {
handleOnClick(navigationItem)
},
aspectRatio = aspectRatio,
),
modifier = modifier,
)
}
@Composable
fun *OnRowType*(navigationChildList: ListNavigationModel?) {
navigationChildList?.let { navChildList ->
val mediaElements = navChildList.size
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
modifier = Modifier,
) {
navChildList.forEach { item ->
OnMediaType(item, mediaElements, _CATEGORY_CARD_ASPECT_RATIO_)
}
}
}
}.
data class CustomAsyncImageDisplay(
val imageUrl: String,
val contentDescription: String = BLANK_SPACE,
val contentScale: ContentScale = ContentScale.Fit,
val aspectRatio: Float? = null,
val shape: Shape? = null,
@DrawableRes val loadingPlaceholder: Int = R.color.warm_gray_20,
@DrawableRes val errorPlaceholder: Int = R.drawable.product_error_placeholder,
)