Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:14
Show Gist options
  • Save wizard1066/9667024a04a6f5bfb7f8b19c6d8b48d4 to your computer and use it in GitHub Desktop.
Save wizard1066/9667024a04a6f5bfb7f8b19c6d8b48d4 to your computer and use it in GitHub Desktop.
abgwtp5
struct ContentView: View {
@State private var rect: CGPoint = CGPoint()
@State private var textText = ["",""]
@State private var textID = 0
@State private var textValue:String = "Hello World"
var body: some View {
let dropDelegate = TheDropDelegate(textID: $textID, textText: $textText, textValue: $textValue)
return VStack {
Spacer()
Text(textValue).background(InsideView(rect: $rect))
.onDrag {
return NSItemProvider(object: self.textValue as NSItemProviderWriting) }
Spacer()
HStack {
Text(textText[0])
.frame(width: 128, height: 20, alignment: .center)
.background(Color.yellow)
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
Text(textText[1])
.frame(width: 128, height: 20, alignment: .center)
.background(Color.yellow)
.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