Skip to content

Commit

Permalink
Merge pull request #759 from supabase-community/jan-tennert-patch-1
Browse files Browse the repository at this point in the history
Update Compose to 1.7.0
  • Loading branch information
jan-tennert authored Oct 19, 2024
2 parents ffb0ab2 + 4acdd8f commit 854b303
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean>, onSuccess: (List<String>) -> 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;
}
}
)
Expand Down

0 comments on commit 854b303

Please sign in to comment.