-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# DragAndDropKit | ||
|
||
## What is DragAndDropKit? | ||
> DragAndDropKit allows you to implement drag and drop functionality easily in your SwiftUI projects without any effort. | ||
## ✔️ Result | ||
<img src="https://github.com/insub4067/DragAndDropKit/assets/85481204/fa0b1cec-6294-47f1-bff2-94c1a953fb07" width="300"> | ||
|
||
## ✔️ Example Code | ||
```swift | ||
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 | ||
} | ||
``` |