import React from "react"; import { FlatListProps, LayoutChangeEvent, StyleProp, ViewStyle, } from "react-native"; import { useAnimatedValues } from "./context/animatedValueContext"; import { FlatList } from "react-native-gesture-handler"; import Animated, { AnimateProps, WithSpringConfig, } from "react-native-reanimated"; import { DEFAULT_PROPS } from "./constants"; export type DragEndParams = { data: T[]; from: number; to: number; }; type Modify = Omit & R; type DefaultProps = Readonly; export type DraggableFlatListProps = Modify< FlatListProps, { data: T[]; activationDistance?: number; animationConfig?: Partial; autoscrollSpeed?: number; autoscrollThreshold?: number; containerStyle?: StyleProp; debug?: boolean; dragItemOverflow?: boolean; keyExtractor: (item: T, index: number) => string; onDragBegin?: (index: number) => void; onDragEnd?: (params: DragEndParams) => void; onPlaceholderIndexChange?: (placeholderIndex: number) => void; onRelease?: (index: number) => void; onScrollOffsetChange?: (scrollOffset: number) => void; renderItem: RenderItem; renderPlaceholder?: RenderPlaceholder; simultaneousHandlers?: React.Ref | React.Ref[]; outerScrollOffset?: Animated.SharedValue; onAnimValInit?: (animVals: ReturnType) => void; itemEnteringAnimation?: AnimateProps["entering"]; itemExitingAnimation?: AnimateProps["exiting"]; itemLayoutAnimation?: AnimateProps["layout"]; enableLayoutAnimationExperimental?: boolean; onContainerLayout?: (params: { layout: LayoutChangeEvent["nativeEvent"]["layout"]; containerRef: React.RefObject; }) => void; } & Partial >; export type RenderPlaceholder = (params: { item: T; index: number; }) => JSX.Element; export type RenderItemParams = { item: T; getIndex: () => number | undefined; // This is technically a "last known index" since cells don't necessarily rerender when their index changes drag: () => void; isActive: boolean; }; export type RenderItem = (params: RenderItemParams) => React.ReactNode; export type AnimatedFlatListType = ( props: Animated.AnimateProps< FlatListProps & { ref: React.Ref>; simultaneousHandlers?: React.Ref | React.Ref[]; } > ) => React.ReactElement; export type CellData = { measurements: { size: number; offset: number; }; };