I'm trying to implement the drag and drop feature to my LazyHGridview. When I try to drop the view on another view, a "plus" icon within a green circle is displayed at the top right corner of the view.
struct TestView: View {
var d: GridData
@Binding var list: [GridData]
@State private var dragOver = false
var body: some View {
VStack {
Text(String(d.id))
.font(.headline)
.foregroundColor(.white)
}
.frame(width: 160, height: 240)
.background(colorPalette[d.id])
.onDrag {
let item = NSItemProvider(object: String(d.id) as NSString)
item.suggestedName = String(d.id)
return item
}
.onDrop(of: [UTType.text], isTargeted: $dragOver) { providers in
return true
}
.border(Color(UIColor.label), width: dragOver ? 8 : 0)
}
}
}
