2

I have List in the TabView. List has text/button with delete and update swipe action. The swipe action does not work in the tabview but it is work fine without tab view. Below is my code.

  TabView {
     List {
        ForEach(0..<5, id: \.self) {index in
            Text(“\(index)”)
                .swipeActions(edge: .trailing, allowsFullSwipe: false) {
                    Button {
                        
                    } label: {
                        Label {
                            Text("Delete")
                        } icon: {
                            Image("ic_delete")
                                .renderingMode(.template)
                                .foregroundColor(.white)
                        }
                    }
                    .tint(.red)
                    Button {
                        
                    } label: {
                        Label {
                            Text("Update")
                        } icon: {
                            Image("ic_edit")
                                .renderingMode(.template)
                                .foregroundColor(.white)
                        }
                    }
                    .tint(.accentColor)
                }
}
}
        }
    .tabViewStyle(.page(indexDisplayMode: .never))

Can Anyone help me to fix this issue?

Muhammad Farooq
  • 263
  • 3
  • 10
  • 1
    I don't think this is fixable for you using a stock `TabView`. Essentially, you are trying to use the same gesture to do two different actions. I was able to get it to intermittently work by adding `.allowsHitTesting(true)`, but it became a race as to which would respond. Generally, the `TabView` won. The only way to fix this is to make your own `TabView` in which you can turn the swipe to change tabs on and off. – Yrb Apr 16 '22 at 19:16
  • Yes, It is impossible to use SwipeAction in the TabView. I make my own TabView. Thank you. – Muhammad Farooq Apr 20 '22 at 20:44
  • do you mind sharing the code for your custom tabView? – Nat Serrano Aug 25 '22 at 03:37

0 Answers0