Update files

This commit is contained in:
Mohamed Boudra
2026-02-10 16:26:51 +07:00
parent 7e5537bcc5
commit ec7ea4b55a
15 changed files with 712 additions and 446 deletions
@@ -1,5 +1,5 @@
import { RefreshControl } from "react-native";
import { useCallback } from "react";
import { useCallback, useState } from "react";
import DraggableFlatList, {
type RenderItemParams,
} from "react-native-draggable-flatlist";
@@ -28,6 +28,7 @@ export function DraggableList<T>({
waitFor,
}: DraggableListProps<T>) {
const { theme } = useUnistyles();
const [isDragging, setIsDragging] = useState(false);
// Pass the ref directly to DraggableFlatList - it handles the gesture coordination
// The ref may not have .current set yet, but that's okay - DraggableFlatList will
@@ -50,11 +51,22 @@ export function DraggableList<T>({
const handleDragEnd = useCallback(
({ data: newData }: { data: T[] }) => {
setIsDragging(false);
onDragEnd(newData);
},
[onDragEnd]
);
const handleDragBegin = useCallback(() => {
setIsDragging(true);
}, []);
const handleRelease = useCallback(() => {
setIsDragging(false);
}, []);
const showRefreshControl = Boolean(onRefresh) && (!isDragging || Boolean(refreshing));
return (
<DraggableFlatList
data={data}
@@ -71,10 +83,12 @@ export function DraggableList<T>({
simultaneousHandlers={simultaneousHandlers}
// Higher activationDistance prevents drag from interfering with nested onLongPress handlers
activationDistance={20}
onDragBegin={handleDragBegin}
onRelease={handleRelease}
// @ts-expect-error - waitFor is supported by RNGH FlatList but not typed in DraggableFlatList
waitFor={waitFor}
refreshControl={
onRefresh ? (
showRefreshControl ? (
<RefreshControl
refreshing={refreshing ?? false}
onRefresh={onRefresh}