kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.4k stars 55 forks source link

refactor: use `KeyboardAnimation` as common interface for an animation driver #431

Closed kirillzyusko closed 2 months ago

kirillzyusko commented 2 months ago

πŸ“œ Description

Added KeyboardAnimation class (as common interface) which drives an animation of the keyboard.

πŸ’‘ Motivation and Context

Follow up for https://github.com/kirillzyusko/react-native-keyboard-controller/pull/412

Keyboard animation can be driven not only by CASpringAnimation class. What we want to achieve is to have a single interface that gives us all necessary properties (value for a particular timing, etc.), but will incapsulate calculations of these values internally.

So in this PR I added KeyboardAnimation abstract class that uses some common properties for all animations (from/to value, speed, init time), has universal method for finding a particular timing for a given value (since we use a binary search) and defines other publicly available functions.

And in this PR I also started to use this universal interface (KeyboardAnimation) in KeyboardMovementObserver (SpringAnimation inherits from KeyboardAnimation).

πŸ“’ Changelog

iOS

πŸ€” How Has This Been Tested?

Tested on iPhone 11 (iOS 17.4), real device.

πŸ“Έ Screenshots (if appropriate):

No visual changes.

πŸ“ Checklist

github-actions[bot] commented 2 months ago

πŸ“Š Package size report

Current size Target Size Difference
131465 bytes 131402 bytes 63 bytes πŸ“ˆ