Created
April 2, 2020 07:14
-
-
Save wizard1066/9667024a04a6f5bfb7f8b19c6d8b48d4 to your computer and use it in GitHub Desktop.
abgwtp5
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
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