Mijick / NavigationView

Navigation made simple (SwiftUI)
MIT License
238 stars 9 forks source link

Drag Gesture Issue #46

Closed devmlew closed 2 months ago

devmlew commented 2 months ago

Hello, I am seeing odd gesture behavior when navigating more than 1 view deep. I am also seeing this behavior with rotation. I have attached some GIFs and a test snippet to recreate the issue.

Simulator Screen Recording - iPhone 15 Pro - 2024-07-07 at 02 20 09

Simulator Screen Recording - iPhone 15 Pro - 2024-07-07 at 02 21 36

import SwiftUI
import MijickNavigationView

var navigationConfig: NavigationGlobalConfig {
    var config = NavigationGlobalConfig()
    config.backgroundColour = Color(.gray)
    config.backGestureThreshold = 0.25
    config.backGesturePosition = .anywhere
    return config
}

@main
struct naviIssueApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
               .implementNavigationView(config: navigationConfig)
        }
    }
}

struct ContentView: NavigatableView {
    func configure(view: NavigationConfig) -> NavigationConfig {
        view
            .backgroundColour(.purple)
            .navigationBackGesture(.drag)
            .ignoresSafeArea(.all, .bottom)
    }
    var body: some View {
        VStack(spacing: 0) {
            Text("ContentView1")
            Spacer()

            Button(action: {
                ContentView2().push(with: .horizontalSlide)
            }) {
                Text("Jump to ContentView2")
                    .foregroundColor(.black)
            }

            Spacer()
        }
    }
}

struct ContentView2: NavigatableView {
    func configure(view: NavigationConfig) -> NavigationConfig {
        view
            .backgroundColour(.blue)
            .navigationBackGesture(.drag)
            .ignoresSafeArea(.all, .bottom)
    }
    var body: some View {
        VStack(spacing: 0) {
            Text("ContentView2")
            Spacer()

            Button(action: pop) { 
                Text("Pop").foregroundColor(.black)
            }

            Button(action: {
                ContentView3().push(with: .horizontalSlide)
            }) { 
                Text("Jump to ContentView3")
                    .foregroundColor(.black)
            }

            Spacer()
        }
    }
}

struct ContentView3: NavigatableView {
    func configure(view: NavigationConfig) -> NavigationConfig {
        view
            .backgroundColour(.green)
            .navigationBackGesture(.drag)
            .ignoresSafeArea(.all, .bottom)
    }
    var body: some View {
        VStack(spacing: 0) {
            Text("ContentView3")
            Spacer()

            Button(action: pop) { 
                Text("Pop").foregroundColor(.black)
            }

            Spacer()
        }
    }
}

#Preview {
    ContentView()
        .implementNavigationView(config: navigationConfig)
}
FulcrumOne commented 2 months ago

Hey @devmlew!

Thanks for your report, we'll check it out

ByLiangCheng commented 2 months ago

I also encountered this problem

FulcrumOne commented 2 months ago

Hey guys!

This problem should be fixed in Patch-1.1.2 branch. Could you please check it? Thanks!

ByLiangCheng commented 2 months ago

Hey guys!

This problem should be fixed in Patch-1.1.2 branch. Could you please check it? Thanks!

I switched to this branch and it worked, thank you.