Jetpack Compose Support Pass in Composable with Modifier.align (BoxScope DSL)

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")}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.