0

I have an image slider with dot indicator named "Onboardingslider". I have used it in my another screen "onboard4" , I want to change the text of "next" button to "get started" only on last image of slider otherwise it stays "next".

I have tried a lot of things but nothing works

Please help me I'm a newbie


struct onboard4: View {
    
    @State var showModal = false
    @State var maxlogoheight: CGFloat = 0
    @State var isLinkActive = false
    
    var body: some View {
        
        NavigationView {
            ZStack{
                
                
                //max height will be width of the screen
                GeometryReader{ proxy -> AnyView in
                    
                    let height = proxy.frame(in: .global).height
                    
                    DispatchQueue.main.async {
                        if maxlogoheight == 0 {
                            maxlogoheight = height
                        }
                    }
                    
                    return AnyView (
            ZStack{
                Image("Logo")
                    .resizable()
                    .scaledToFit()
                    .offset(x: getReact().width/3.5, y: -height/1.25)
                
                
            }//zstack 2
           // .padding(.leading,10)
             
           )//anyview
        
          }//end of gr
           .frame(maxHeight: getReact().width)
             
                
                VStack{
                   
                      Onboardingslider()
                       
                    Button(action: {
                        showModal = true
                                    }) {
                                        ZStack{
                                           Text("Next")
                                            .foregroundColor(Color.white)
                                            .fontWeight(.bold)
                                            .frame (width: 295, height: 30)
                                            .padding()
                                            .background(Color("YellowAccent"))
                                            .cornerRadius(20)
                                            
                                            .shadow(color: .gray, radius: 5, x: 0, y: 4)
                                            Image("NextButtonOnboard")
                                        }
                                        }
                                    .fullScreenCover(isPresented: $showModal) {
                                        LoginView() }
                                    .offset(y: getSafearea().bottom + -55)
                    
                }//vstack
                
                Button(action: {}, label: {
                    Text("Continue to the listing service")
                        .underline()
                })
                .foregroundColor(Color.black)
                .offset(y: getSafearea().bottom + 310)
                
            }//zstack
            .background(
                         NavigationLink(destination: LoginView(), isActive: $isLinkActive) {
                                    EmptyView()
                                }
                                .hidden()
                            )
            .toolbar {
                ToolbarItem(placement: .navigationBarTrailing) {
                    Button(action: {
                        showModal = true
                                    }) {
                                        Text("Skip").underline()
                                    }
                                    
                                    .foregroundColor(Color("YellowAccent"))
                                    .font(.system(size: 20,weight: .semibold,design: .serif))
                                    .frame(width: 100, height: 100)
                                    .padding(.top)
                                    .fullScreenCover(isPresented: $showModal) {
                                      LoginView() }
                        
                        //.padding(.bottom)
                       
                }//toolbaritem
               
        
        }//toolbar
        }
    }
}

struct onboard4_Previews: PreviewProvider {
    static var previews: some View {
        onboard4()
    }
}
struct Onboardingslider: View {
    private let images = ["1", "2", "3", "4"]
    init() {
        // modify appearance
        UIPageControl.appearance().currentPageIndicatorTintColor = .orange
        UIPageControl.appearance().pageIndicatorTintColor = .gray
      }
    var body: some View {
        
        TabView {
                    ForEach(images, id: \.self) { item in
                        Image(item)
                            .padding(.leading,24)
                            
                    }
                }
                  .frame(height: 600)
                .tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
                

    }
}





bushra
  • 27
  • 4

0 Answers0