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

Merged
merged 4 commits into from
Nov 29, 2024

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

@@ -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

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.

@ASalavei ASalavei requested a review from MatkovIvan November 13, 2024 17:29
Copy link

@elijah-semyonov elijah-semyonov left a comment

Choose a reason for hiding this comment

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

LGTM!

# Conflicts:
#	compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeHostingViewController.uikit.kt
#	compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/UIKitComposeSceneLayersHolder.uikit.kt
@ASalavei ASalavei merged commit b163bf7 into jb-main Nov 29, 2024
2 checks passed
@ASalavei ASalavei deleted the andrei.salavei/animate-size-change branch November 29, 2024 09:49
@@ -107,6 +108,8 @@ internal class ComposeView(
try {
animations()
} finally {
// Delay mitigates rendering glitches that can occur at the end of the animation.
delay(50)
Copy link
Member

Choose a reason for hiding this comment

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

Adding delay is generally doesn't look good, so please avoid adding such questionable changes after review.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@MatkovIvan , kk. I faced an ugly issue after rebasing. For not I don't know other ways to fix it.

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.

4 participants