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

feat(keyboard): Add keyboardAnimationDuration to KeyboardInfo #523

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

Conversation

viablecell
Copy link

  1. Add keyboardAnimationDuration to KeyboardInfo
  2. iOS, Android, notifyListeners keyboardWillShow and keyboardDidShow with keyboardAnimationDuration

Copy link
Author

@viablecell viablecell left a comment

Choose a reason for hiding this comment

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

Reviewed

@@ -75,9 +75,11 @@ void onKeyboardEvent(String event, int size) {
switch (event) {
case Keyboard.EVENT_KB_WILL_SHOW:
case Keyboard.EVENT_KB_DID_SHOW:
String data = "{ 'keyboardHeight': " + size + " }";
// Convert Handler().postDelayed() 350ms to 0.35s
String data = "{ 'keyboardHeight': " + size + ", 'keyboardAnimationDuration': " + 0.35 + " }";

Choose a reason for hiding this comment

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

Thanks so much for contributing this. Is 350 a constant on Android?

Copy link
Author

Choose a reason for hiding this comment

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

@PluginMethod
    public void show(final PluginCall call) {
        execute(
            () ->
                new Handler()
                    .postDelayed(
                        () -> {
                            implementation.show();
                            call.resolve();
                        },
                        350
                    )
        );
    }

350 is method param long delayMillis

Choose a reason for hiding this comment

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

I'm sorry, I meant: on Android, is 350 milliseconds always the time it takes for the keyboard animation to complete. I'm wondering why that number is hard-coded.

Thank you.

Choose a reason for hiding this comment

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

I may be speaking out of ignorance here, but is this value only useful on iOS? Perhaps the android part of this should be removed, and the docs should specify this as an iOS only value for the plugin?

@dtzxporter
Copy link

Is there any chance we can merge this soon? This is extremely useful for adapting the keyboard on iOS.

We should probably match react native and do 0 for android. (It's been implemented in react for years).

https://github.com/facebook/react-native/blob/8cdc9e7f04e2dd3026d15dcd5765952bfb2c5c08/Libraries/Components/Keyboard/Keyboard.d.ts#L50

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