DragAndDropKit allows you to implement drag and drop functionality easily in your SwiftUI projects without any effort.
![](https://private-user-images.githubusercontent.com/85481204/311944288-fa0b1cec-6294-47f1-bff2-94c1a953fb07.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTYzMTMsIm5iZiI6MTczOTE5NjAxMywicGF0aCI6Ii84NTQ4MTIwNC8zMTE5NDQyODgtZmEwYjFjZWMtNjI5NC00N2YxLWJmZjItOTRjMWE5NTNmYjA3LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDE0MDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ0ZGM3MjJlMTAyMWE2Y2Y0NmMyMjIzY2Y1ZDQ5NTZiM2NiMjE0MzA0MGYyMTI5NTg1NDE3YzRlMjJiZGE4NjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8kDU14AuwzwUDFX2nF4DDpbyAVC4UllYI5fp-UxQLMo)
import SwiftUI
import DragAndDropKit
struct DragAndDropPractice: View {
@State var items: [Item] = Array(1...20).map { Item(id: $0) }
@State var currentDragging: Item? = nil
var body: some View {
ScrollView {
LazyVStack(content: {
ForEach(items, id: \.self) { item in
Text("Placeholder \(item.id)")
.padding()
.frame(maxWidth: .infinity)
.frame(height: 100)
.background(Color.gray.opacity(0.6))
.dragAndDrop(
item: item,
items: $items,
currentDragging: $currentDragging)
}
})
}
}
}
struct Item: Identifiable, Hashable {
let id: Int
}