diff --git a/sample/file-upload/common/src/desktopMain/kotlin/io/github/jan/supabase/common/ui/utils/applyDragging.kt b/sample/file-upload/common/src/desktopMain/kotlin/io/github/jan/supabase/common/ui/utils/applyDragging.kt index 9c5cb0bd9..d7249f381 100644 --- a/sample/file-upload/common/src/desktopMain/kotlin/io/github/jan/supabase/common/ui/utils/applyDragging.kt +++ b/sample/file-upload/common/src/desktopMain/kotlin/io/github/jan/supabase/common/ui/utils/applyDragging.kt @@ -1,26 +1,29 @@ package io.github.jan.supabase.common.ui.utils +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.draganddrop.dragAndDropTarget import androidx.compose.runtime.MutableState -import androidx.compose.ui.DragData import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.composed -import androidx.compose.ui.onExternalDrag +import androidx.compose.ui.draganddrop.DragAndDropEvent +import androidx.compose.ui.draganddrop.DragAndDropTarget +import androidx.compose.ui.draganddrop.DragData +import androidx.compose.ui.draganddrop.dragData -@OptIn(ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class) actual fun Modifier.applyDragging(isDragging: MutableState, onSuccess: (List) -> Unit): Modifier { return composed { - onExternalDrag( - onDragStart = { - isDragging.value = true + dragAndDropTarget( + shouldStartDragAndDrop = { + it.dragData() is DragData.FilesList }, - onDragExit = { - isDragging.value = false - }, - onDrop = { - isDragging.value = false - if(it.dragData is DragData.FilesList) { - onSuccess((it.dragData as DragData.FilesList).readFiles()) + target = object : DragAndDropTarget { + override fun onDrop(event: DragAndDropEvent): Boolean { + isDragging.value = false + val dragData = event.dragData() as DragData.FilesList + onSuccess(dragData.readFiles()) + return true; } } )