ios – how can I make a button adds textfield if you press it in the same page view in swiftui


I’m having a problem coding this view so I want to be able to press the plus button the add another exercise in the same page here hereenter image description here

I used this code but is says( Result of ‘VStack<Content>’ initializer is unused)

 Button(action: {
   
    VStack{
     HStack {
      Text("Exercise Name").bold()
      TextField("EX: Narrow Stance Leg Press", text: .constant("")).textFieldStyle(.roundedBorder)
     }
     ZStack{
    
      HStack {
    Spacer()
    Picker("Number of Sets", selection: $selectedNumber){
     ForEach(1...10, id: \.self) { number in
      Text("\(number)")
      
     }
    }.frame(width: 102.0, height: 25.0)
      }
      HStack {
    
    Text("Number of sets:").bold()
    Spacer()
    RoundedRectangle(cornerRadius: 13).stroke(.gray).frame(width: 133,height: 25)
      }
     }
     
     ZStack{
    
      HStack {
    Spacer()
    Picker("Number of reps", selection: $selectedNumber2){
     ForEach(1...20, id: \.self) { number in
      Text("\(number)")
      
     }
    }.frame(width: 102.0, height: 25.0)
      }
      HStack {
    
    Text("Number of reps:").bold()
    Spacer()
    RoundedRectangle(cornerRadius: 13).stroke(.gray).frame(width: 133,height: 25)
      }
     }

    }
    
   }) {
    ZStack{
     Text("+").bold()
     RoundedRectangle(cornerRadius: 13).stroke(.gray).frame(width: 133,height: 25)
    }

as I said I want to press
the plus then the same block ( exercise name ,# of sets, # of reps) adds again for the user to add another exercise ,,,, I hope its clear

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img