Skip to content

Commit

Permalink
Fix the widthRatio dones't calculate properly in Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Oct 9, 2024
1 parent 80a2ef4 commit a9a41c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,18 @@ public fun Balloon(
.padding(start = paddingStart, end = paddingEnd)
.onGloballyPositioned { coordinates ->
val originalSize = coordinates.size
val calculatedWidth = if (originalSize.width > screenWidth) {
screenWidth
} else {
originalSize.width
}
val calculatedWidth =
if (screenWidth * builder.widthRatio != 0f) {
(
screenWidth * builder.widthRatio -
with(density) { builder.marginRight.dp.toPx() } -
with(density) { builder.marginLeft.dp.toPx() }
).toInt()
} else if (originalSize.width > screenWidth) {
screenWidth
} else {
originalSize.width
}
val size = IntSize(
width = calculatedWidth,
height = coordinates.size.height,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.7.0"
agp = "8.6.1"
dokka = "1.9.20"
kotlin = "2.0.20"
kotlinBinaryCompatibility = "0.16.3"
Expand Down

0 comments on commit a9a41c1

Please sign in to comment.