I've created a simple swiftui view with a simple vstack with a text and a toggle. I can't understand how to trigger toggle's changes because the method I've developed is not working.
This is the code
struct SquadMemberDetailView: View {
@State var admin = false
var body: some View {
VStack(alignment: .leading) {
Text("Amministratore")
.font(.body)
.foregroundColor(Color("DarkGray"))
.padding([.top, .leading, .trailing])
Toggle(isOn: $admin){
}
.onTapGesture(perform: {
self.admin = !self.admin
manageToggle()
})
.labelsHidden()
.padding(.horizontal)
}
}
}
The onTapGesture method is never called when I switch the toggle state.
Any idea?