Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carson-katri/drag-and-drop
Simple drag and drop for SwiftUI
https://github.com/carson-katri/drag-and-drop
Last synced: about 2 months ago
JSON representation
Simple drag and drop for SwiftUI
- Host: GitHub
- URL: https://github.com/carson-katri/drag-and-drop
- Owner: carson-katri
- Created: 2019-08-28T17:47:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T18:56:51.000Z (over 5 years ago)
- Last Synced: 2024-11-05T11:52:18.519Z (2 months ago)
- Language: Swift
- Size: 5.2 MB
- Stars: 20
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - drag-and-drop - Simple drag and drop for SwiftUI (etc)
- awesome - drag-and-drop - Simple drag and drop for SwiftUI (etc)
README
# Drag and Drop
Simple drag and drop for SwiftUI
![Sample GIF](Resources/SampleGIF.gif)
## Installation
You can install via the Swift Package Manager:`File > Swift Packages > Add Package Dependency...`, then paste in `https://github.com/carson-katri/drag-and-drop`
## Usage
First, add the `DragDropManager` environment object:
```swift
ContentView().environmentObject(DragDropManager())
```Example:
```swift
VStack {
Text("Drop Here")
.droppable()
Text("Drag Me")
.draggable(data: myDropData)
}
```You can also get the data from the drag view like so:
```swift
VStack {
DropView { data in
Text(data as? String ?? "Drop Here")
}
Text("Drag Me")
.draggable(data: "Hello World")
}
```You can also make the `DragView` directly:
```swift
DragView(myDropData) {
Text("Drag Me")
}
```Another capability is resizing the `DragView` to fit in the `DropView` automatically:
```swift
Text("Drag Me")
.draggable(data: "Hello World", resize: true)
```