0

I am using a TabView PageTabView to mimic TikTok's main UI (full screen carousel swiping up and down) with the following code.

@State var tab_pos = 0
var edges = UIApplication.shared.windows.first?.safeAreaInsets

TabView(selection: $tab_pos) {
    ForEach(Array(posts.enumerated()), id: \.element) { index, post in
        VStack {
            Text(post.title)
            
            Image(systemName: "chevron.down")
                .imageScale(.large)
                .font(.system(size: 24))
                .foregroundColor(.primary)
        
        }.tag(index)
             .rotationEffect(.init(degrees: -90))
    }
}
    .rotationEffect(.init(degrees: 90))
    .frame(width: UIScreen.main.bounds.height - (edges!.top + edges!.bottom))
    .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
    .background(Color.black.ignoresSafeArea(.all, edges: .all))

I want to add a pull to refresh type of action (similar to the new refreshable for lists) when the user swipes down on the first item. I tried using a DragGesture. Swipe detection works for left and right swipes but it seemed that the TabView is not allowing me to register the up and down swipes. Is there a way for me to implement a pull to refresh feature for this.

Swapnil
  • 11
  • 2

0 Answers0