Created
December 5, 2023 15:31
-
-
Save bmc08gt/fec88e5caab41011a3a065101c7e35e3 to your computer and use it in GitHub Desktop.
M.measured {}
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
import androidx.compose.ui.unit.Density | |
import androidx.compose.ui.unit.DpSize | |
import androidx.compose.ui.unit.IntSize | |
fun IntSize.toDp(density: Density): DpSize = with(density) { DpSize(width = width.toDp(), height = height.toDp()) } |
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
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.composed | |
import androidx.compose.ui.layout.onPlaced | |
import androidx.compose.ui.platform.LocalDensity | |
import androidx.compose.ui.unit.DpSize | |
import dev.bmcreations.leftovers.utils.toDp | |
fun Modifier.measured(block: (DpSize) -> Unit): Modifier = composed { | |
val density = LocalDensity.current | |
onPlaced { block(it.size.toDp(density)) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment