DEV Community

Cover image for Reorder items with Drag and Drop using SwiftUI
Raksha for Canopas Software

Posted on

Reorder items with Drag and Drop using SwiftUI

Learn how to replicate UIKit’s Drag and Drop feature in the SwiftUI

Earlier, we implemented a Drag and Drop feature for UICollectionView, which was used to copy the dragged item. Very useful for functionality like adding items to the cart.

Please check out the article if you’ve missed it.

Last week, we received a new requirement to provide drag and drop feature in the app for a better user experience.

According to requirements, we wanted to allow users to prioritize their activity according to their needs. While we did the implementation with UIKit in the past, we never had a chance to do it using SwiftUI.

I have divided this into 3 parts, feel free to jump around according to your needs!

  1. Create a basic UI
  2. Add drag support
  3. Add drop support and update the list

For detailed implementation, check out our blog.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay