Skip to content

Commit

Permalink
Fix iOS interop position conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
MatkovIvan committed Jan 9, 2024
1 parent 713c73b commit f2666e7
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasurePolicy
import androidx.compose.ui.layout.MeasureScope
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.IntOffset
Expand Down Expand Up @@ -97,7 +97,7 @@ fun <T : UIView> UIKitView(

Place(
modifier.onGloballyPositioned { coordinates ->
localToWindowOffset = coordinates.positionInWindow().round()
localToWindowOffset = coordinates.positionInRoot().round()
val newRectInPixels = IntRect(localToWindowOffset, coordinates.size)
if (rectInPixels != newRectInPixels) {
val rect = newRectInPixels / density
Expand Down Expand Up @@ -196,7 +196,7 @@ fun <T : UIViewController> UIKitViewController(

Place(
modifier.onGloballyPositioned { coordinates ->
localToWindowOffset = coordinates.positionInWindow().round()
localToWindowOffset = coordinates.positionInRoot().round()
val newRectInPixels = IntRect(localToWindowOffset, coordinates.size)
if (rectInPixels != newRectInPixels) {
val rect = newRectInPixels / density
Expand Down

0 comments on commit f2666e7

Please sign in to comment.