Skip to content

Commit

Permalink
feat: added handling for keyboard height change (#656)(by @Ferossgp)
Browse files Browse the repository at this point in the history
* React on keyboard height change

* Handle null previous state android
  • Loading branch information
Ferossgp committed Sep 23, 2021
1 parent 38b635e commit 3c5fc57
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,15 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
* @alias OnKeyboardStateChange
*/
useAnimatedReaction(
() => animatedKeyboardState.value,
(_keyboardState, _previousKeyboardState) => {
() => ({
_keyboardState: animatedKeyboardState.value,
_keyboardHeight: animatedKeyboardHeight.value,
}),
(result, _previousResult) => {
const { _keyboardState, _keyboardHeight } = result;
const _previousKeyboardState = _previousResult?._keyboardState;
const _previousKeyboardHeight = _previousResult?._keyboardHeight;

const hasActiveGesture =
animatedContentGestureState.value === State.ACTIVE ||
animatedContentGestureState.value === State.BEGAN ||
Expand All @@ -1345,7 +1352,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
/**
* if keyboard state is equal to the previous state, then exit the method
*/
_keyboardState === _previousKeyboardState ||
(_keyboardState === _previousKeyboardState &&
_keyboardHeight === _previousKeyboardHeight) ||
/**
* if user is interacting with sheet, then exit the method
*/
Expand Down Expand Up @@ -1374,6 +1382,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
method: 'useAnimatedReaction::OnKeyboardStateChange',
params: {
keyboardState: _keyboardState,
keyboardHeight: _keyboardHeight,
},
});

Expand Down

0 comments on commit 3c5fc57

Please sign in to comment.