mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {useKeyboardHandler} from 'react-native-keyboard-controller'
3import Animated, {
4 useAnimatedStyle,
5 useSharedValue,
6} from 'react-native-reanimated'
7
8export function KeyboardPadding({maxHeight}: {maxHeight?: number}) {
9 const keyboardHeight = useSharedValue(0)
10
11 useKeyboardHandler(
12 {
13 onMove: e => {
14 'worklet'
15
16 if (maxHeight && e.height > maxHeight) {
17 keyboardHeight.value = maxHeight
18 } else {
19 keyboardHeight.value = e.height
20 }
21 },
22 },
23 [maxHeight],
24 )
25
26 const animatedStyle = useAnimatedStyle(() => ({
27 height: keyboardHeight.value,
28 }))
29
30 return <Animated.View style={animatedStyle} />
31}