Skip to content

Convert UIKit keyboard animation curve to UIViewAnimationOptions#3183

Open
Kyle (Kyle-Ye) wants to merge 1 commit into
JetBrains:jb-mainfrom
Kyle-Ye:patch-1
Open

Convert UIKit keyboard animation curve to UIViewAnimationOptions#3183
Kyle (Kyle-Ye) wants to merge 1 commit into
JetBrains:jb-mainfrom
Kyle-Ye:patch-1

Conversation

@Kyle-Ye

Copy link
Copy Markdown

Convert the UIKit keyboard animation curve from UIKeyboardAnimationCurveUserInfoKey
to UIViewAnimationOptions before passing it to UIView.animateWithDuration.

UIKeyboardAnimationCurveUserInfoKey contains a UIViewAnimationCurve raw value,
while UIViewAnimationOptions stores animation curve values in the curve option
bit field. Without shifting the value, non-default curves may be interpreted as
unrelated low-order animation options.

Source

SDK Header:

typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) {
    ...
    UIViewAnimationOptionCurveEaseInOut            = 0 << 16, // default
    UIViewAnimationOptionCurveEaseIn               = 1 << 16,
    UIViewAnimationOptionCurveEaseOut              = 2 << 16,
    UIViewAnimationOptionCurveLinear               = 3 << 16,  
    ...  
} API_AVAILABLE(ios(4.0)) API_UNAVAILABLE(watchos);

Apple Documentation:
https://developer.apple.com/documentation/uikit/uiresponder/keyboardanimationcurveuserinfokey

Testing

Not run; this is a small UIKit interop conversion fix and preserves the existing
fallback behavior for missing animation curve info.

Release Notes

Fixes - iOS

  • Fixed UIKit keyboard animation curve handling by converting UIKeyboardAnimationCurveUserInfoKey values to UIViewAnimationOptions.

Google CLA

Sign the Google Contributor's License Agreement at https://cla.developers.google.com to let us upstream your code to Google's AOSP repository

UIKeyboardAnimationCurveUserInfoKey stores a UIViewAnimationCurve raw value,
while UIView.animateWithDuration expects UIViewAnimationOptions.

Shift the curve value into the UIViewAnimationOptions curve bit field before
passing it to UIKit, matching the SDK header.
@Kyle-Ye

Copy link
Copy Markdown
Author

I checked the downstream usage of this value to make sure the code is not intentionally depending on the raw UIViewAnimationCurve values (0, 1, 2, 3).

The animationOptions value is only threaded through KeyboardVisibilityObserver. The only non-empty consumer is the keyboard frame change path:

keyboardWillChangeFrame -> adjustViewBounds -> animateKeyboard -> UIView.animateWithDuration(options = animationOptions)

keyboardWillShow and keyboardWillHide currently do not consume this parameter.

So the final call site expects UIViewAnimationOptions, not a raw UIViewAnimationCurve. I do not see an intermediate Compose-side dependency on the unshifted 0/1/2/3 values.

cc Andrei Salavei (@ASalavei)

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.

1 participant