1

I am new to SwiftUI. I need to create a list that is displaying in two columns. Its more likely a collectionView with two items per row. The condition is I need to create it using "List" because I need to add a "drag and drop to reorder" functionality on this list.

So far I have implemented it using HStack and VStack but in this case there is no option to drag and reorder the list.

Here is the code I have done so far:

           ZStack{
              Button(action: {
                 }) {
                      HStack{
                         Image(systemName: "person.crop.circle.fill")
                         Text(font)
                             .font(.system(size: 13 ))
                         .foregroundColor(.black)
                            .frame(minWidth: UIScreen.main.bounds.size.width/4, maxWidth: UIScreen.main.bounds.size.width/4)
                         .padding(.horizontal)
                       }
                       .padding(10)
                     }
                     .foregroundColor(Color.black)
                     .background(Color.white)
                     .cornerRadius(8)
                     .background(
                     RoundedRectangle(cornerRadius: 5)
                         .fill(Color.white)
                         .shadow(color: .gray, radius: 2, x: 0, y: 2)
                     )
          }

My question is: how can I create collection view type of two column list in SwiftUI Using List?? IF my implementation using HStack and Stack sounds good then: Is there any way to implement drag and drop to reorder list functionality on it??

Using LazyVGrid is not possible for me because my requirement is ios13.

Any help will be appreciated.

Thanks!!

Update: I solved it using UICollectionView wrapped in UIViewRepresentable in swiftui.

Rj19
  • 305
  • 1
  • 6
  • 20
  • Look at this implementation https://stackoverflow.com/questions/62606907/swiftui-using-ondrag-and-ondrop-to-reorder-items-within-one-single-lazygrid – lorem ipsum Oct 08 '20 at 14:59
  • @loremipsum Thanks for reply.. But that code is using LazyVGrid that support in iOS 14 and my requirement is iOS 13 support. Sorry I forgot to mention it in my question. – Rj19 Oct 08 '20 at 15:57

0 Answers0