|
| 1 | +// source https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view |
| 2 | +/** |
| 3 | + * This component is used to handle the keyboard in a modal. |
| 4 | + * It is a wrapper around the `KeyboardAwareScrollView` component from `react-native-keyboard-controller`. |
| 5 | + * It is used to handle the keyboard in a modal. |
| 6 | + * example usage: |
| 7 | + export function Example() { |
| 8 | + return ( |
| 9 | + <Modal> |
| 10 | + <BottomSheetKeyboardAwareScrollView> |
| 11 | + </BottomSheetKeyboardAwareScrollView> |
| 12 | + </Modal> |
| 13 | + ); |
| 14 | + } |
| 15 | + */ |
| 16 | +import { |
| 17 | + type BottomSheetScrollViewMethods, |
| 18 | + createBottomSheetScrollableComponent, |
| 19 | + SCROLLABLE_TYPE, |
| 20 | +} from '@gorhom/bottom-sheet'; |
| 21 | +import type { BottomSheetScrollViewProps } from '@gorhom/bottom-sheet/src/components/bottomSheetScrollable/types'; |
| 22 | +import { memo } from 'react'; |
| 23 | +import type { KeyboardAwareScrollViewProps } from 'react-native-keyboard-controller'; |
| 24 | +import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'; |
| 25 | +import Reanimated from 'react-native-reanimated'; |
| 26 | + |
| 27 | +const AnimatedScrollView = |
| 28 | + Reanimated.createAnimatedComponent<KeyboardAwareScrollViewProps>( |
| 29 | + KeyboardAwareScrollView |
| 30 | + ); |
| 31 | +const BottomSheetScrollViewComponent = createBottomSheetScrollableComponent< |
| 32 | + BottomSheetScrollViewMethods, |
| 33 | + BottomSheetScrollViewProps |
| 34 | +>(SCROLLABLE_TYPE.SCROLLVIEW, AnimatedScrollView); |
| 35 | +const BottomSheetKeyboardAwareScrollView = memo(BottomSheetScrollViewComponent); |
| 36 | + |
| 37 | +BottomSheetKeyboardAwareScrollView.displayName = |
| 38 | + 'BottomSheetKeyboardAwareScrollView'; |
| 39 | + |
| 40 | +export default BottomSheetKeyboardAwareScrollView as ( |
| 41 | + props: BottomSheetScrollViewProps & KeyboardAwareScrollViewProps |
| 42 | +) => ReturnType<typeof BottomSheetKeyboardAwareScrollView>; |
0 commit comments