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

Animate compose content size transitions #1691

Open
wants to merge 2 commits into
base: jb-main
Choose a base branch
from

Conversation

ASalavei
Copy link
Collaborator

@ASalavei ASalavei commented Nov 12, 2024

Animate the size transition of Compose scenes and platform windows when the size of the ComposeUIViewController changes.
Example: https://github.com/user-attachments/assets/0054014c-fc8e-419d-8ffb-eaf6497dfb5e

Fixes https://youtrack.jetbrains.com/issue/CMP-1491/Fix-interop-views-animation-while-rotating-screen

Testing

Features - iOS

  • Animate the size transition of Compose content when the screen is rotated or other ComposeUIViewController size changes

Comment on lines 24 to 28
internal fun easeInOutTimingFunction(progress: Float) = if (progress < 0.5) {
2 * progress * progress
} else {
(-2 * progress * progress) + (4 * progress) - 1
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing ints, doubles and floats. Let's align that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -88,14 +88,29 @@ internal class ComposeHostingViewController(
private val lifecycleOwner = ViewControllerBasedLifecycleOwner()
private val hapticFeedback = CupertinoHapticFeedback()

private val metalView = MetalView(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear what view it is. for the initial mediator? for Popups?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to rootMetalView

@@ -243,7 +232,7 @@ internal class ComposeSceneMediator(
/**
* View wrapping the hierarchy managed by this Mediator.
*/
private val view = ComposeSceneMediatorView(
val view = ComposeSceneMediatorView(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep it private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, reverted

@@ -64,7 +62,7 @@ internal class UIKitComposeSceneLayer(
isInterceptingOutsideEvents = { focusable }
)

private val mediator = ComposeSceneMediator(
val mediator = ComposeSceneMediator(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it private

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, reverted.

right = size.width,
bottom = size.height,
right = Float.MAX_VALUE,
bottom = Float.MAX_VALUE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was it changed? Did it affect the performance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the animation, canvas can be greater than layer's view. And because of aync scene updates. schirm may have glitches on edges.
This solution does not degrade performance, but I found another one with getting bounds of MetalView, PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants