Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/components/ActionSheetAwareScrollView/index.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import React, {forwardRef, useCallback} from 'react';
import type {ScrollView, ScrollViewProps} from 'react-native';
import Reanimated, {useAnimatedRef, useScrollViewOffset} from 'react-native-reanimated';
import {Actions, ActionSheetAwareScrollViewContext, ActionSheetAwareScrollViewProvider} from './ActionSheetAwareScrollViewContext';
import ActionSheetKeyboardSpace from './ActionSheetKeyboardSpace';
import useActionSheetKeyboardSpace from './useActionSheetKeyboardSpace';

const ActionSheetAwareScrollView = forwardRef<ScrollView, PropsWithChildren<ScrollViewProps>>((props, ref) => {
const ActionSheetAwareScrollView = forwardRef<ScrollView, PropsWithChildren<ScrollViewProps>>(({style, children, ...rest}, ref) => {
const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();
const position = useScrollViewOffset(scrollViewAnimatedRef);

Expand All @@ -24,13 +24,16 @@ const ActionSheetAwareScrollView = forwardRef<ScrollView, PropsWithChildren<Scro
[ref, scrollViewAnimatedRef],
);

const {animatedStyle} = useActionSheetKeyboardSpace({position});

return (
<Reanimated.ScrollView
ref={onRef}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
{...rest}
style={[style, animatedStyle]}
>
<ActionSheetKeyboardSpace position={position}>{props.children}</ActionSheetKeyboardSpace>
{children}
</Reanimated.ScrollView>
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {useContext, useEffect} from 'react';
import {useContext, useEffect} from 'react';
import type {ViewProps} from 'react-native';
import {useKeyboardHandler} from 'react-native-keyboard-controller';
import Reanimated, {useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSequence, withSpring, withTiming} from 'react-native-reanimated';
import {useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSequence, withSpring, withTiming} from 'react-native-reanimated';
import type {SharedValue} from 'react-native-reanimated';
import useSafeAreaPaddings from '@hooks/useSafeAreaPaddings';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {Actions, ActionSheetAwareScrollViewContext, States} from './ActionSheetAwareScrollViewContext';

Expand Down Expand Up @@ -65,8 +64,7 @@ type ActionSheetKeyboardSpaceProps = ViewProps & {
position?: SharedValue<number>;
};

function ActionSheetKeyboardSpace(props: ActionSheetKeyboardSpaceProps) {
const styles = useThemeStyles();
function useActionSheetKeyboardSpace(props: ActionSheetKeyboardSpaceProps) {
const {
unmodifiedPaddings: {top: paddingTop = 0, bottom: paddingBottom = 0},
} = useSafeAreaPaddings();
Expand Down Expand Up @@ -253,15 +251,7 @@ function ActionSheetKeyboardSpace(props: ActionSheetKeyboardSpaceProps) {
paddingTop: translateY.get(),
}));

return (
<Reanimated.View
style={[styles.flex1, animatedStyle]}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
);
return {animatedStyle};
}

ActionSheetKeyboardSpace.displayName = 'ActionSheetKeyboardSpace';

export default ActionSheetKeyboardSpace;
export default useActionSheetKeyboardSpace;
Loading