Last active
August 29, 2023 04:45
-
-
Save nimaiwalsh/4187d909d69bf32a4a3d9f366f318827 to your computer and use it in GitHub Desktop.
Composable helper extensions
This file contains 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
/** | |
* Modifies a layout to ignore irs parents horizontal padding. This is useful if you have an item in a column, such as | |
* a divider, that does not want to be constrained by the parents padding | |
*/ | |
fun Modifier.ignoreHorizontalParentPadding(horizontal: Dp): Modifier { | |
return this.layout { measurable, constraints -> | |
val overriddenWidth = constraints.maxWidth + 2 * horizontal.roundToPx() | |
val placeable = measurable.measure(constraints.copy(maxWidth = overriddenWidth)) | |
layout(placeable.width, placeable.height) { | |
placeable.place(0, 0) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment