jueves, febrero 22, 2024
InicioiOS Developmentios - onTapGesture not being referred to as

ios – onTapGesture not being referred to as


I’ve have a View that presents an inventory that has checkboxes in every row which when tapped they show a checkmark and will add the corresponding the descriptive time period to a binding String array. Once I faucet on the checkbox, the checkmark is displayed however the faucet gesture to append the descriptive time period shouldn’t be even reached. If somebody might please clarify the right method to name the respective faucet gestures.

Right here is the code:

NewWineView

struct NewWineView: View {
    Button(motion: {
       descriptorsViewVisible.toggle()
    }, label: {
          HStack{
            Textual content("Descriptors")
              .font(.customized("Oswald-Daring", dimension: 20))
              .foregroundStyle(Shade.black)
            Spacer()
            Picture(systemName: "chevron.proper")
              .foregroundStyle(Shade.grey)
          }
    })
    .padding([.leading, .trailing],100)
    .padding([.top, .bottom])
}
.sheet(isPresented: $descriptorsViewVisible, onDismiss: {
            print(descriptors)
            descriptorsViewVisible = false
        }, content material: {
            WineDescriptorsListView(descriptorArray: $descriptors)
        })

WineDescriptorsListView

struct WineDescriptorsListView: View {
    @EnvironmentObject var mannequin: Mannequin
    @Binding var descriptorArray: [String]
    
    var physique: some View {
        Listing {
            ForEach(mannequin.wineDescriptors, id: .self) { descriptor in
                HStack {
                    Checkbox()
                        .onTapGesture {
                            descriptorArray.append(descriptor)
                        }
                    Textual content(descriptor)
                        .font(.customized("Oswald-Common", dimension: 20))
                }
            }
        }
    }
}

Checkbox

struct Checkbox: View {
    @State var isChecked: Bool = false
    
    var physique: some View {
        ZStack {
            Rectangle()
                .aspectRatio(1.0, contentMode: .match)
                .foregroundStyle(Shade.white)
                .border(Shade.black) //must make thicker
                .body(width: 30, top: 30)
                .onTapGesture {
                    isChecked.toggle()
                }
            if isChecked {
                Picture(systemName: "checkmark")
            }
        }
    }
}

Moreover mannequin.wineDescriptors is simply an array of descriptive phrases.

RELATED ARTICLES

DEJA UNA RESPUESTA

Por favor ingrese su comentario!
Por favor ingrese su nombre aquí

Most Popular

Recent Comments