Created
February 22, 2020 01:14
-
-
Save tarasis/f9bac6d98de5433f1ddbadaef02f9a29 to your computer and use it in GitHub Desktop.
To demonstrate poss iOS 13.4 beta drag and drop bug
This file contains hidden or 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
//: A SwiftUI playground | |
import SwiftUI | |
import PlaygroundSupport | |
struct Person: Identifiable, Hashable { | |
var id = UUID() | |
var name: String | |
} | |
struct PersonRow: View { | |
@State var targeted: Bool = true | |
var person: Person | |
var body: some View { | |
HStack { | |
Image(systemName: "person.circle") | |
Text(person.name) | |
Text(person.id.description) | |
} | |
.onDrop(of: ["public.utf8-plain-text"], isTargeted: self.$targeted) { item in | |
DispatchQueue.main.async { | |
print("onDrop PersonRow: \(item.description)") | |
} | |
return true | |
} | |
.onDrag { | |
var item = NSItemProvider(object: NSString(string: self.person.name)) | |
item.suggestedName = self.person.name | |
print("onDrag: \(item)") | |
return item | |
} | |
} | |
} | |
struct MyView : View { | |
var people: [Person] = [Person(name: "George"), Person(name: "The Kurruth"), Person(name: "The Other")] | |
@State var targeted: Bool = true | |
var body: some View { | |
VStack { | |
Text("Test") | |
Text("") | |
PersonRow(person: Person(name:"Test Person")) | |
Text("---------------------") | |
PersonRow(person: Person(name:"Another Test Person")) | |
List(people) { person in | |
PersonRow(person: person) | |
// Button("\(person.name)", action: { | |
// | |
// }) | |
// .onDrop(of: ["public.utf8-plain-text"], isTargeted: self.$targeted) { item in | |
// DispatchQueue.main.async { | |
// print("onDrop List in DetailView: \(item.description)") | |
// } | |
// return true | |
// } | |
} | |
.onDrop(of: ["public.utf8-plain-text"], isTargeted: self.$targeted) { item in | |
DispatchQueue.main.async { | |
print("onDrop List in DetailView: \(item.description)") | |
} | |
return true | |
} | |
} | |
.onDrop(of: ["public.utf8-plain-text"], isTargeted: self.$targeted) { item in | |
DispatchQueue.main.async { | |
print("onDrop VStack in DetailView: \(item.description)") | |
} | |
return true | |
} | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.setLiveView(MyView()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment