Giter VIP home page Giter VIP logo

Comments (10)

izombieprod avatar izombieprod commented on May 27, 2024 1

i will create a test project and upload it here after work, thanks man!

from swiftui-navigation-transitions.

davdroman avatar davdroman commented on May 27, 2024

@izombieprod are you using the latest version of the library (0.13.3)?

If so, please provide a minimal reproducible project that can help me get started debugging the issue.

from swiftui-navigation-transitions.

izombieprod avatar izombieprod commented on May 27, 2024

Hi there! Yes, Im using 0.13.3 version as spm , with your custom zoom transition (but the same bug occurs to me with any transitions, I checked) on Xcode 15.

struct SplashScreenView: View {
    @StateObject var viewModel: SplashScreenViewModel

    @EnvironmentObject var coordinator: Coordinator
    
    @State private var isVisible = false
    
    typealias ViewModel = SplashScreenViewModel
    
    var body: some View {
        NavigationStack(path: $coordinator.steps) {
            ZStack {
                GradientBackgroundView()
                    .frame(maxWidth: .infinity, maxHeight: .infinity)
                
                Image(Constants.logos.splashScreen)
                    .transition(.move(edge: .leading))
            }
            .navigationDestination(for: ScreenModel.self) { screen in
                switch screen.type {
                case .login:
                    GetStartedView(viewModel: GetStartedViewModel())
                        .toolbar(screen.navigationBarVisible ? .visible : .hidden, for: .navigationBar)
                case .swipesExpandedView:
                    if let screen = screen as? SwipesExpandedViewScreenModel {
                        FullScreenDetailView(card: screen.card)
                            .navigationTransition(.zoom)
                            .toolbar(screen.navigationBarVisible ? .visible : .hidden, for: .navigationBar)
                            
                    } else {
                        EmptyView()
                    }
                    
                }
            }
        }
        .onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 1)  {
                viewModel.checkAuth { screenModel in
                    coordinator.showNextScreen(screenModel)
                }
            }
        }
    }
}

from swiftui-navigation-transitions.

izombieprod avatar izombieprod commented on May 27, 2024

and here's how my coordinator is look like

class Coordinator: ObservableObject {
    static let shared = Coordinator()
    
    @Published var steps = [ScreenModel]()
    
    private init() {
        
    }
    
    func showNextScreen(_ screenModel: ScreenModel) {
        steps.append(screenModel)
    }
    
    
    func goBack() {
        steps.removeLast()
    }
    
    func popToRoot() {
        steps = [.init(title: "Login", type: .login)]
    }
}

class ScreenModel: Identifiable, Hashable {
    static func == (lhs: ScreenModel, rhs: ScreenModel) -> Bool {
        lhs.id == rhs.id
    }
    
    var id: String {
        type.id
    }
    
    let title: String
    let type: CoordinatorStep
    
    let navigationBarVisible = false
    
    init(title: String, type: CoordinatorStep) {
        self.title = title
        self.type = type
    }
    
    func hash(into hasher: inout Hasher) {
        hasher.combine(id)
    }
}

class SwipesExpandedViewScreenModel: ScreenModel {
    let card: SwipeMockCard
    
    init(card: SwipeMockCard, title: String, type: CoordinatorStep) {
        self.card = card
        super.init(title: title, type: type)
    }
}

from swiftui-navigation-transitions.

davdroman avatar davdroman commented on May 27, 2024

I'm getting a lot of errors for things that are missing from your example. Could you narrow down the reproducible scenario into a standalone project that can be zipped or put in a repo? Otherwise there are too many gaps to fill to debug effectively.

Screenshot 2023-12-20 at 12 02 55 Screenshot 2023-12-20 at 12 00 56

from swiftui-navigation-transitions.

izombieprod avatar izombieprod commented on May 27, 2024

https://github.com/izombieprod/swiftUItestTransitions - here's a code example with the same transition behavior as I told you in the thread before. the first transition is always the default.

from swiftui-navigation-transitions.

rdsarna avatar rdsarna commented on May 27, 2024

Just wanted to pop in and say that I'm facing the same issue.

from swiftui-navigation-transitions.

davdroman avatar davdroman commented on May 27, 2024

Thank you @izombieprod, I'll take a look at this and get back to you shortly.

from swiftui-navigation-transitions.

davdroman avatar davdroman commented on May 27, 2024

Oh I see what's going on. So you're tacking the .navigationTransition modifier onto each detail view expecting them to have different transitions:

.navigationDestination(for: ScreenModel.self) { screen in
    switch screen.type {
    case .firstView:
        FirstView()
            .navigationTransition(.zoom)
    case .secondView:
        SecondView()
            .navigationTransition(.slide)
    case .thirdDView:
        ThirdView()
            .navigationTransition(.default)
    }
}

However, this is not a supported use case. I'm afraid you're limited to one specific transition per NavigationStack. Sorry about this, but there's just no way around this. You must pick one transition and apply it to the navigation stack instead of the detail views, as follows:

NavigationStack(path: $coordinator.steps) {
    // ...
}
.navigationTransition(.xyz)

from swiftui-navigation-transitions.

izombieprod avatar izombieprod commented on May 27, 2024

@davdroman Understood, thanks

from swiftui-navigation-transitions.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.