Skip to content

Commit

Permalink
Provide padding and alignment from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
KovalevAndrey committed Oct 13, 2023
1 parent 0c01dfe commit 753e87c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ import kotlin.math.roundToInt
internal fun OptimisingLayout(
modifier: Modifier = Modifier,
optimalWidth: Dp,
paddingFraction: Float = 0.12f,
contentAlignment: Alignment = Alignment.Center,
content: @Composable @UiComposable () -> Unit
) {
Box(modifier = modifier) {
BoxWithConstraints(
modifier = Modifier
.fillMaxSize(0.84f)
.align(Alignment.Center)
.fillMaxSize((1f - paddingFraction).coerceIn(0f, 1f))
.align(contentAlignment)
) {
ScaledLayout(
scale = (this@BoxWithConstraints.maxWidth / optimalWidth).coerceIn(0.1f, 1f),
scale = (this@BoxWithConstraints.maxWidth / optimalWidth).coerceAtMost(1f),
content = content
)
}
Expand All @@ -34,7 +36,7 @@ internal fun OptimisingLayout(


@Composable
internal fun ScaledLayout(
private fun ScaledLayout(
modifier: Modifier = Modifier,
scale: Float = 1f,
content: @Composable @UiComposable () -> Unit
Expand Down

0 comments on commit 753e87c

Please sign in to comment.