diff --git a/patches/react-native-draggable-flatlist+4.0.1.patch b/patches/react-native-draggable-flatlist+4.0.1.patch index bc70ea669..2d9cc982e 100644 --- a/patches/react-native-draggable-flatlist+4.0.1.patch +++ b/patches/react-native-draggable-flatlist+4.0.1.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/react-native-draggable-flatlist/lib/commonjs/context/animatedValueContext.js b/node_modules/react-native-draggable-flatlist/lib/commonjs/context/animatedValueContext.js -index 19eec62..5a7aae2 100644 +index 19eec62..ab919d8 100644 --- a/node_modules/react-native-draggable-flatlist/lib/commonjs/context/animatedValueContext.js +++ b/node_modules/react-native-draggable-flatlist/lib/commonjs/context/animatedValueContext.js @@ -1,2 +1,288 @@ @@ -326,6 +326,91 @@ index ab6d37c..8b7a9e1 100644 \ No newline at end of file +{"version":3,"names":["React","useMemo","useEffect","useCallback","useContext","useAnimatedReaction","useDerivedValue","useSharedValue","State","GestureState","useProps","AnimatedValueContext","createContext","undefined","AnimatedValueProvider","children","value","useSetupAnimatedValues","useAnimatedValues","Error","props","DEFAULT_VAL","containerSize","scrollViewSize","panGestureState","UNDETERMINED","touchTranslate","isTouchActiveNative","hasMoved","disabled","horizontalAnim","horizontal","activeIndexAnim","spacerIndexAnim","activeCellSize","activeCellOffset","scrollOffset","scrollInit","viewableIndexMin","viewableIndexMax","outerScrollOffset","outerScrollInit","cur","prev","placeholderOffset","isDraggingCell","autoScrollDistance","innerScrollDiff","outerScrollDiff","scrollDiff","touchPositionDiff","extraTranslate","touchPositionDiffConstrained","containerMinusActiveCell","offsetRelativeToScrollTop","constrained","Math","min","max","maxTranslateNegative","maxTranslatePositive","constrainedBase","hoverAnim","dragItemOverflow","hoverOffset","isHovering","resetTouchedCell","onAnimValInit"],"sources":["animatedValueContext.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useCallback, useContext } from \"react\";\nimport {\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { State as GestureState } from \"react-native-gesture-handler\";\nimport { useProps } from \"./propsContext\";\n\nconst AnimatedValueContext = React.createContext<\n ReturnType | undefined\n>(undefined);\n\nexport default function AnimatedValueProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const value = useSetupAnimatedValues();\n return (\n \n {children}\n \n );\n}\n\nexport function useAnimatedValues() {\n const value = useContext(AnimatedValueContext);\n if (!value) {\n throw new Error(\n \"useAnimatedValues must be called from within AnimatedValueProvider!\"\n );\n }\n return value;\n}\n\nfunction useSetupAnimatedValues() {\n const props = useProps();\n\n const DEFAULT_VAL = useSharedValue(0);\n\n const containerSize = useSharedValue(0);\n const scrollViewSize = useSharedValue(0);\n\n const panGestureState = useSharedValue(\n GestureState.UNDETERMINED\n );\n const touchTranslate = useSharedValue(0);\n\n const isTouchActiveNative = useSharedValue(false);\n\n const hasMoved = useSharedValue(0);\n const disabled = useSharedValue(false);\n\n const horizontalAnim = useSharedValue(!!props.horizontal);\n\n const activeIndexAnim = useSharedValue(-1); // Index of hovering cell\n const spacerIndexAnim = useSharedValue(-1); // Index of hovered-over cell\n\n const activeCellSize = useSharedValue(0); // Height or width of acctive cell\n const activeCellOffset = useSharedValue(0); // Distance between active cell and edge of container\n\n const scrollOffset = useSharedValue(0);\n const scrollInit = useSharedValue(0);\n\n const viewableIndexMin = useSharedValue(0);\n const viewableIndexMax = useSharedValue(0);\n\n // If list is nested there may be an outer scrollview\n const outerScrollOffset = props.outerScrollOffset || DEFAULT_VAL;\n const outerScrollInit = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n return activeIndexAnim.value;\n },\n (cur, prev) => {\n if (cur !== prev && cur >= 0) {\n scrollInit.value = scrollOffset.value;\n outerScrollInit.value = outerScrollOffset.value;\n }\n },\n [outerScrollOffset]\n );\n\n const placeholderOffset = useSharedValue(0);\n\n const isDraggingCell = useDerivedValue(() => {\n return isTouchActiveNative.value && activeIndexAnim.value >= 0;\n }, []);\n\n const autoScrollDistance = useDerivedValue(() => {\n if (!isDraggingCell.value) return 0;\n const innerScrollDiff = scrollOffset.value - scrollInit.value;\n // If list is nested there may be an outer scroll diff\n const outerScrollDiff = outerScrollOffset.value - outerScrollInit.value;\n const scrollDiff = innerScrollDiff + outerScrollDiff;\n return scrollDiff;\n }, []);\n\n const touchPositionDiff = useDerivedValue(() => {\n const extraTranslate = isTouchActiveNative.value\n ? autoScrollDistance.value\n : 0;\n return touchTranslate.value + extraTranslate;\n }, []);\n\n const touchPositionDiffConstrained = useDerivedValue(() => {\n const containerMinusActiveCell =\n containerSize.value - activeCellSize.value + scrollOffset.value;\n\n const offsetRelativeToScrollTop =\n touchPositionDiff.value + activeCellOffset.value;\n const constrained = Math.min(\n containerMinusActiveCell,\n Math.max(scrollOffset.value, offsetRelativeToScrollTop)\n );\n\n const maxTranslateNegative = -activeCellOffset.value;\n const maxTranslatePositive =\n scrollViewSize.value - (activeCellOffset.value + activeCellSize.value);\n\n // Only constrain the touch position while the finger is on the screen. This allows the active cell\n // to snap above/below the fold once let go, if the drag ends at the top/bottom of the screen.\n const constrainedBase = isTouchActiveNative.value\n ? constrained - activeCellOffset.value\n : touchPositionDiff.value;\n\n // Make sure item is constrained to the boundaries of the scrollview\n return Math.min(\n Math.max(constrainedBase, maxTranslateNegative),\n maxTranslatePositive\n );\n }, []);\n\n const hoverAnim = useDerivedValue(() => {\n if (activeIndexAnim.value < 0) return 0;\n return dragItemOverflow\n ? touchPositionDiff.value\n : touchPositionDiffConstrained.value;\n }, []);\n\n const hoverOffset = useDerivedValue(() => {\n return hoverAnim.value + activeCellOffset.value;\n }, [hoverAnim, activeCellOffset]);\n\n useDerivedValue(() => {\n // Reset spacer index when we stop hovering\n const isHovering = activeIndexAnim.value >= 0;\n if (!isHovering && spacerIndexAnim.value >= 0) {\n spacerIndexAnim.value = -1;\n }\n }, []);\n\n // Note: this could use a refactor as it combines touch state + cell animation\n const resetTouchedCell = useCallback(() => {\n activeCellOffset.value = 0;\n hasMoved.value = 0;\n }, []);\n\n const value = useMemo(\n () => ({\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n }),\n [\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n ]\n );\n\n useEffect(() => {\n props.onAnimValInit?.(value);\n }, [value]);\n\n return value;\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,SAAzB,EAAoCC,WAApC,EAAiDC,UAAjD,QAAmE,OAAnE;AACA,SACEC,mBADF,EAEEC,eAFF,EAGEC,cAHF,QAIO,yBAJP;AAKA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,8BAAtC;AACA,SAASC,QAAT,QAAyB,gBAAzB;AAEA,MAAMC,oBAAoB,gBAAGX,KAAK,CAACY,aAAN,CAE3BC,SAF2B,CAA7B;AAIA,eAAe,SAASC,qBAAT,OAIZ;EAAA,IAJ2C;IAC5CC;EAD4C,CAI3C;EACD,MAAMC,KAAK,GAAGC,sBAAsB,EAApC;EACA,oBACE,oBAAC,oBAAD,CAAsB,QAAtB;IAA+B,KAAK,EAAED;EAAtC,GACGD,QADH,CADF;AAKD;AAED,OAAO,SAASG,iBAAT,GAA6B;EAClC,MAAMF,KAAK,GAAGZ,UAAU,CAACO,oBAAD,CAAxB;;EACA,IAAI,CAACK,KAAL,EAAY;IACV,MAAM,IAAIG,KAAJ,CACJ,qEADI,CAAN;EAGD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,KAAjB,CAAL;EACD,CAFQ,EAEN,CAACA,KAAD,CAFM,CAAT;EAIA,OAAOA,KAAP;AACD"} \ No newline at end of file +diff --git a/node_modules/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx b/node_modules/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx +index d7b833b..e4e861a 100644 +--- a/node_modules/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx ++++ b/node_modules/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx +@@ -4,7 +4,6 @@ import { + LayoutChangeEvent, + MeasureLayoutOnSuccessCallback, + StyleProp, +- StyleSheet, + ViewStyle, + } from "react-native"; + import Animated, { +@@ -163,11 +162,7 @@ function CellRendererComponent(props: Props) { + ? itemLayoutAnimation + : undefined + } +- style={[ +- props.style, +- baseStyle, +- activeKey ? animStyle : styles.zeroTranslate, +- ]} ++ style={[props.style, baseStyle, animStyle]} + pointerEvents={activeKey ? "none" : "auto"} + > + {children} +@@ -177,12 +172,6 @@ function CellRendererComponent(props: Props) { + + export default typedMemo(CellRendererComponent); + +-const styles = StyleSheet.create({ +- zeroTranslate: { +- transform: [{ translateX: 0 }, { translateY: 0 }], +- }, +-}); +- + declare global { + namespace NodeJS { + interface Global { +diff --git a/node_modules/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx b/node_modules/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx +index d7d98c2..8882e03 100644 +--- a/node_modules/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx ++++ b/node_modules/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx +@@ -6,7 +6,12 @@ import React, { + useRef, + useState, + } from "react"; +-import { ListRenderItem, FlatListProps, LayoutChangeEvent } from "react-native"; ++import { ++ ListRenderItem, ++ FlatListProps, ++ LayoutChangeEvent, ++ InteractionManager, ++} from "react-native"; + import { + FlatList, + Gesture, +@@ -20,7 +25,7 @@ import Animated, { + withSpring, + } from "react-native-reanimated"; + import CellRendererComponent from "./CellRendererComponent"; +-import { DEFAULT_PROPS, isWeb } from "../constants"; ++import { DEFAULT_PROPS } from "../constants"; + import PlaceholderItem from "./PlaceholderItem"; + import RowItem from "./RowItem"; + import { DraggableFlatListProps } from "../types"; +@@ -114,6 +119,9 @@ function DraggableFlatListInner(props: DraggableFlatListProps) { + if (dataHasChanged) { + // When data changes make sure `activeKey` is nulled out in the same render pass + activeKey = null; ++ InteractionManager.runAfterInteractions(() => { ++ reset(); ++ }); + } + + useEffect(() => { +@@ -221,7 +229,8 @@ function DraggableFlatListInner(props: DraggableFlatListProps) { + } + + onDragEnd?.({ from, to, data: newData }); +- reset(); ++ ++ setActiveKey(null); + } + ); + diff --git a/node_modules/react-native-draggable-flatlist/src/context/animatedValueContext.tsx b/node_modules/react-native-draggable-flatlist/src/context/animatedValueContext.tsx index 6ff1ed5..5f7d9bc 100644 --- a/node_modules/react-native-draggable-flatlist/src/context/animatedValueContext.tsx