diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index 87b97ea9c..3492146ba 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -45,6 +45,7 @@ import { SHEET_STATE, SCROLLABLE_STATE, KEYBOARD_BLUR_BEHAVIOR, + KEYBOARD_INPUT_MODE, } from '../../constants'; import { animate, @@ -68,6 +69,7 @@ import { DEFAULT_ENABLE_PAN_DOWN_TO_CLOSE, INITIAL_CONTAINER_OFFSET, DEFAULT_ANIMATION_CONFIGS, + DEFAULT_KEYBOARD_INPUT_MODE, } from './constants'; import { ScrollableRef, BottomSheetMethods, Insets } from '../../types'; import type { BottomSheetProps } from './types'; @@ -105,6 +107,7 @@ const BottomSheetComponent = forwardRef( // keyboard keyboardBehavior = DEFAULT_KEYBOARD_BEHAVIOR, keyboardBlurBehavior = DEFAULT_KEYBOARD_BLUR_BEHAVIOR, + android_keyboardInputMode = DEFAULT_KEYBOARD_INPUT_MODE, // layout handleHeight: _providedHandleHeight, @@ -253,6 +256,13 @@ const BottomSheetComponent = forwardRef( } = useKeyboard(); const getKeyboardHeightInContainer = useWorkletCallback(() => { 'worklet'; + /** + * if android software input mode is not `adjustPan`, than keyboard + * height will be 0 all the time. + */ + if (android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize) { + return 0; + } return $modal ? keyboardHeight.value - Math.abs(bottomInset - animatedContainerOffset.value.bottom) diff --git a/src/components/bottomSheet/constants.ts b/src/components/bottomSheet/constants.ts index 7e7042e83..6a35344fe 100644 --- a/src/components/bottomSheet/constants.ts +++ b/src/components/bottomSheet/constants.ts @@ -2,6 +2,7 @@ import Animated, { Easing } from 'react-native-reanimated'; import { KEYBOARD_BEHAVIOR, KEYBOARD_BLUR_BEHAVIOR, + KEYBOARD_INPUT_MODE, WINDOW_HEIGHT, } from '../../constants'; import { exp } from '../../utilities/easingExp'; @@ -28,6 +29,7 @@ const DEFAULT_ENABLE_PAN_DOWN_TO_CLOSE = false; const DEFAULT_ANIMATE_ON_MOUNT = false; const DEFAULT_KEYBOARD_BEHAVIOR = KEYBOARD_BEHAVIOR.none; const DEFAULT_KEYBOARD_BLUR_BEHAVIOR = KEYBOARD_BLUR_BEHAVIOR.none; +const DEFAULT_KEYBOARD_INPUT_MODE = KEYBOARD_INPUT_MODE.adjustPan; // initial values const INITIAL_SNAP_POINT = -999; @@ -55,6 +57,7 @@ export { DEFAULT_ANIMATE_ON_MOUNT, DEFAULT_KEYBOARD_BEHAVIOR, DEFAULT_KEYBOARD_BLUR_BEHAVIOR, + DEFAULT_KEYBOARD_INPUT_MODE, // initial INITIAL_POSITION, INITIAL_CONTAINER_HEIGHT, diff --git a/src/components/bottomSheet/types.d.ts b/src/components/bottomSheet/types.d.ts index 15d9b7ce5..4d8795f3e 100644 --- a/src/components/bottomSheet/types.d.ts +++ b/src/components/bottomSheet/types.d.ts @@ -8,6 +8,7 @@ import type { BottomSheetBackgroundProps } from '../bottomSheetBackground'; import type { KEYBOARD_BEHAVIOR, KEYBOARD_BLUR_BEHAVIOR, + KEYBOARD_INPUT_MODE, } from '../../constants'; export interface BottomSheetProps @@ -139,6 +140,13 @@ export interface BottomSheetProps * - `restore`: restore sheet position. */ keyboardBlurBehavior?: keyof typeof KEYBOARD_BLUR_BEHAVIOR; + /** + * Defines keyboard input mode for Android only. + * @link {https://developer.android.com/guide/topics/manifest/activity-element#wsoft} + * @type `adjustPan` | `adjustResize` + * @default `adjustPan` + */ + android_keyboardInputMode?: keyof typeof KEYBOARD_INPUT_MODE; //#endregion /** diff --git a/src/constants.ts b/src/constants.ts index 565f7103c..e2a71ff01 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -65,6 +65,11 @@ const KEYBOARD_BLUR_BEHAVIOR = { const KEYBOARD_DISMISS_THRESHOLD = 12.5; +const KEYBOARD_INPUT_MODE = { + adjustPan: 'adjustPan', + adjustResize: 'adjustResize', +}; + export { GESTURE, SHEET_STATE, @@ -79,4 +84,5 @@ export { KEYBOARD_BEHAVIOR, KEYBOARD_BLUR_BEHAVIOR, KEYBOARD_DISMISS_THRESHOLD, + KEYBOARD_INPUT_MODE, };