Show HN: SwiftUI Reorderable – Pure SwiftUI Drag and Drop Components

Hey there!

I made a Swift Package containing a UI component I built for an upcoming app I’m working on. It’s my first time writing something serious using SwiftUI, and I’ve been annoyed with many of its limitations, especially when it comes to drag and drop. The native `onDrag` or `draggable` doesn’t allow you to customize the gesture it uses [0], has a really opinionated and finicky preview, and sometimes fires `onDrag` more than once in a seemingly non-deterministic fashion [1].

A common answer to SwiftUI frustrations seems to be to just write a UIKit component instead. Given that a month ago, I knew neither SwiftUI nor UIKit and decided to go with the former, I didn’t really want to start learning a second framework while barely mastering the first one.

So, I got fed up and decided to write my own component instead. I was a little shocked by how few high-quality SwiftUI open-source components there are. Coming from a mainly web-development background, I expected to find components I could use, and if not, at least look at their code to figure out how it’s done. It’s possible components like these already exist, and I haven’t found them. If that’s the case, oh well.

In any case, this was a good learning experience and I hope this component can help some of y’all!

[0] https://stackoverflow.com/questions/65311379/how-to-customiz…
[1] https://stackoverflow.com/questions/74087137/swiftui-ondrag-…

Comments URL: https://news.ycombinator.com/item?id=41664158

Points: 1

# Comments: 0