Support pass in compsable with support Modifier.align
@Composablefun PhotoItem(modifier: Modifier = Modifier, data: Any? = null, content: (@Composable BoxScope.() -> Unit)? = null) { val painter = rememberImagePainter( data = idata ?: R.drawable.error, builder = { // size(64) placeholder(R.drawable.placeholder) // transition when placeholder -> image crossfade(true) error(R.drawable.error) } ) Box(modifier) { Image( painter = painter, contentDescription = null, modifier = Modifier.aspectRatio(1.0f), contentScale = ContentScale.Crop ) if (content != null) { content() } }}
Usage
PhotoItem(data = "https://picsum.photos/id/237/200/300") { Text(modifier = Modifier.padding(8.dp).align(Alignment.BottomCenter, text = "Hello")}