Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DragAndDropSnippets to match the new documentation #445

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.annotation.RequiresApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.draganddrop.dragAndDropSource
import androidx.compose.foundation.draganddrop.dragAndDropTarget
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
Expand All @@ -41,39 +40,30 @@ private fun DragAndDropSnippet() {
val url = ""

// [START android_compose_drag_and_drop_1]
Modifier.dragAndDropSource {
detectTapGestures(onLongPress = {
// Transfer data here.
})
Modifier.dragAndDropSource { _ ->
// Transfer data here.
null
tiwiz marked this conversation as resolved.
Show resolved Hide resolved
}
// [END android_compose_drag_and_drop_1]

// [START android_compose_drag_and_drop_2]
Modifier.dragAndDropSource {
detectTapGestures(onLongPress = {
startTransfer(
DragAndDropTransferData(
ClipData.newPlainText(
"image Url", url
)
)
Modifier.dragAndDropSource { _ ->
DragAndDropTransferData(
ClipData.newPlainText(
"image Url", url
tiwiz marked this conversation as resolved.
Show resolved Hide resolved
)
})
)
}
// [END android_compose_drag_and_drop_2]

// [START android_compose_drag_and_drop_3]
Modifier.dragAndDropSource {
detectTapGestures(onLongPress = {
startTransfer(
DragAndDropTransferData(
ClipData.newPlainText(
"image Url", url
),
flags = View.DRAG_FLAG_GLOBAL
)
)
})
Modifier.dragAndDropSource { _ ->
DragAndDropTransferData(
ClipData.newPlainText(
"image Url", url
),
flags = View.DRAG_FLAG_GLOBAL
)
}
// [END android_compose_drag_and_drop_3]

Expand Down
Loading