I'm trying to implement a drag/drop to reorder function on a SwiftUI view (without using List). I'm playing around with .draggable, but I'm not sure how to implement drag/drop such that the drag preview looks the same as the view being dragged. You can see below the code that the drag preview has an abnormal shape:
@State private var items: [Color] = [.red, .blue, .green, .orange, .purple]
var body: some View {
VStack(spacing: 16) {
ForEach(items, id: \.self) { color in
color
.frame(height: 100)
.draggable(color) {
color
.frame(height: 100)
}
}
}
.padding()
}
I have implemented the suggestion outlined in this post but that seemingly interfered with the drag/drop behavior.
Interested if this is possible.

I added a GeometryReader and then took that to calculate the size of the Preview.