Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with screen size #1093

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package androidx.compose.ui.platform

import androidx.compose.ui.input.pointer.PointerKeyboardModifiers
import androidx.compose.ui.uikit.systemDensity
import androidx.compose.ui.toDpRect
import androidx.compose.ui.uikit.systemDensity
import androidx.compose.ui.unit.IntRect
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.roundToIntRect
import kotlinx.cinterop.cValue
import kotlinx.cinterop.useContents
import platform.CoreGraphics.CGRectMake
import platform.UIKit.UIView

/**
Expand Down Expand Up @@ -66,10 +68,15 @@ internal class PlatformWindowContext {
fun boundsInWindow(container: UIView): IntRect {
val density = container.systemDensity
return if (_windowContainer != null && _windowContainer != container) {
container.convertRect(
rect = container.bounds,
val convertedPoint = container.convertPoint(
point = cValue { container.bounds.useContents { origin } },
toView = _windowContainer,
)
//TODO split boundsInWindow and size in ComposeSceneLayer
// https://youtrack.jetbrains.com/issue/COMPOSE-964
val (x, y) = convertedPoint.useContents { x to y }
val (w, h) = container.bounds.useContents { size.width to size.height }
CGRectMake(x, y, w, h)
} else {
container.bounds
}.useContents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,8 @@ internal class ComposeSceneMediator(

fun viewWillLayoutSubviews() {
val density = container.systemDensity
//TODO: Current code updates layout based on rootViewController size.
// Maybe we need to rewrite it for SingleLayerComposeScene.

val boundsInWindow = windowContext.boundsInWindow(container)
scene.density = density // TODO: Maybe it is wrong to set density to scene here?
dima-avdeev-jb marked this conversation as resolved.
Show resolved Hide resolved
val boundsInWindow: IntRect = windowContext.boundsInWindow(container)
scene.density = density
scene.boundsInWindow = boundsInWindow
dima-avdeev-jb marked this conversation as resolved.
Show resolved Hide resolved
onComposeSceneInvalidate()
}
Expand Down