Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:17
Show Gist options
  • Save wizard1066/6e90804682dcd24f246209e4c495241e to your computer and use it in GitHub Desktop.
Save wizard1066/6e90804682dcd24f246209e4c495241e to your computer and use it in GitHub Desktop.
abgwtp7
import SwiftUI
import CoreServices
struct ContentView: View {
@State private var rect:[CGRect] = []
@State private var textText = ["","","",""]
@State private var textID = 0
@State private var textValue1:String = "Hello World 1"
@State private var textValue2:String = "Hello World 2"
var body: some View {
let dropDelegate = TheDropDelegate(textID: $textID, textText: $textText, rect: $rect)
return VStack {
Spacer()
Text(textValue1)
.onDrag {
return NSItemProvider(object: self.textValue1 as NSItemProviderWriting) }
Text(textValue2)
.onDrag {
return NSItemProvider(object: self.textValue2 as NSItemProviderWriting) }
Spacer()
HStack {
ForEach((0...3).reversed(), id: \.self) {
Text(self.textText[$0])
.frame(width: 128, height: 32, alignment: .center)
.background(Color.yellow)
.background(InsideView(rect: self.$rect))
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
}
}
Spacer()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment