0

im trying to make a conditional navigationlink example if var = 0 still in the same view and nothing will change else it send me to the other view normally

HStack {
                Button   {
                    
                    if paymentType == nil {
                        self.showBanner = true
                        self.bannerData.type = .info
                    } else {
                        NavigationLink(destination:NewOfferStepThree() .navigationBarHidden(true)
                            .navigationBarBackButtonHidden(true))
                    }
                  
                } label: {
                    HStack {
                        
                        Text("Next")
                            .font(.system(size: 23.0))
                            .fontWeight(.bold)
                            .foregroundColor(Color.white)
                            .multilineTextAlignment(.center)
                            .frame(width: 332.0, height: 28.0)
                            .opacity(100.0)
                        
                        Image("Icon ionic-ios-arrow-forward")
                            .offset(x: -30, y: 1)
                    } 
                } .frame(width: 332.0, height: 54.0)
                    .background(.black)
                    .cornerRadius(15)
                    .offset(x: 1, y: -80)
            }

but i have this error " Missing argument for parameter #1 in call" and didn't work for me

  • I'm not sure what you want to achieve. Putting a View inside the action of the Button is doing nothing. – Carsten Sep 29 '22 at 12:30
  • so what should i do if i want to add a condition to navigationlink example i have a view with a label if the label is empty when i tap to the button next still in the same view and if the label is full when i tap on the button next send me to the second view taht's my goal and i don't know how –  Sep 29 '22 at 12:35
  • with `NavigationView`, there is a `NavigationLink(destination: Text("Destination"), isActive: $isActive, label: { Text("NavigationLink") })` that you could use, where you "trigger" the navigation with the `isActive:`. Look it up. Otherwise the traditional `if var == 0 {NavigationLink(...)}` – workingdog support Ukraine Sep 29 '22 at 12:38

0 Answers0