0

I'm working on a onboarding screen:

VStack {
            if #available(iOS 14.0, *) {
                TabView(selection: $currentStep) {
                    ForEach(0..<OnBoardingSteps.count) { it in
                        VStack {
                            Text(OnBoardingSteps[it].title)
                            Image(OnBoardingSteps[it].image).resizable().frame(width: 200, height: 200)
                            Text(OnBoardingSteps[it].description)
                        }.tag(it)
                    }
                }.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
            } else {
                // Fallback on earlier versions
            }
            HStack {
                Spacer()
                Spacer()
                HStack{
                    ForEach(0..<OnBoardingSteps.count) { it in
                        if it == currentStep {
                            Rectangle()
                                .frame(width: 10, height: 10)
                                .cornerRadius(10)
                                .foregroundColor(.purple)
                        } else {
                            Circle()
                                .frame(width: 10, height: 10)
                                .foregroundColor(.gray)
                        }
                    }
                }
                Spacer()
                Button(action: {
                    if self.currentStep < OnBoardingSteps.count - 1 {
                        self.currentStep += 1
                    } else {
                        // now when i click 'Done' it should take me to Signup screen
                    }
                }){
                    HStack {
                    Text(currentStep < OnBoardingSteps.count - 1 ? "Next" : "Done")
                        
                        .foregroundColor(.blue)
                    Image(systemName: currentStep < OnBoardingSteps.count - 1 ? "arrow.right" : "checkmark")
                    }
                }
            }
        }

In my button I have some logic to change text based on if I'm on the last onBoarding step.

What im trying to achieve is, when im on the last step, when i click 'Done' i should navigate to the Signup screen.

Gurmukh Singh
  • 1,875
  • 3
  • 24
  • 62

0 Answers0