Created
Oct ’21
Replies
4
Boosts
0
Views
1.4k
Participants
2
Can you show a complete code example and a sample image showing the green (+) icon?
example code
struct ContentView: View {
@State private var dragging: Ramen?
@State private var ramens = [Ramen(name: "ramen", id: 0),
Ramen(name: "ramen2", id: 1),
Ramen(name: "ramen3", id: 2)]
var body: some View {
List {
ForEach(ramens) { ramen in
Image(ramen.name)
.onDrag {
self.dragging = ramen
return NSItemProvider(object: String(ramen.id) as NSString)
}
}
.onInsert(of: [.text], perform: insert)
}
}
private func insert(index: Int, _: [NSItemProvider]) {
...
}
}
when dragging
I couldn't figure out how to change it with onInsert, but I did find out that DropProposal is involved. By implementing it with onDrop, I was able to successfully turn it off.