From 4d72e26d8464b7da7354cac39e21715ada178dc3 Mon Sep 17 00:00:00 2001 From: Jan Tennert Date: Thu, 17 Oct 2024 13:07:02 +0200 Subject: [PATCH 1/2] Update Compose to 1.7.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 09cceb6e..48c336de 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ moshi = "1.15.1" jackson = "2.18.0" browser = "1.8.0" googleid = "1.1.1" -compose = "1.6.11" +compose = "1.7.0" androidsvg = "1.4" imageloader = "1.9.0" coil2 = "2.7.0" From 4acdd8f49634ff29aadae39cf3f098d4d4a5db00 Mon Sep 17 00:00:00 2001 From: Jan Tennert Date: Fri, 18 Oct 2024 09:59:02 +0200 Subject: [PATCH 2/2] migrate file upload sample --- .../supabase/common/ui/utils/applyDragging.kt | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) 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 9c5cb0bd..d7249f38 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; } } )