Skip to content

insub4067/DragAndDropKit

Repository files navigation

DragAndDropKit

License: MIT Static Badge Static Badge

What is DragAndDropKit?

DragAndDropKit allows you to implement drag and drop functionality easily in your SwiftUI projects without any effort.

✔️ Result

✔️ Example Code

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
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages