'How can i disable the swipe for the tab view in certain indexes before i swipe in swift UI?

TabView(index){
   UIView
} 
.gesture(
DragGesture()
    .onChanged {
          if $0.startLocation.x > $0.location.x {
            //left
            // methodTochangeIndex()
                } 
            })

Then i updated index on .onchange so that tabview show the certain index tab, but it shows the animation that moves to same index again. how do i disable that and i cant use the .disable (true) because it disables the whole ui interaction of tab view row items.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source