Is there a way to attached multiple functions (via action) per selected option in a Picker (Wheelview)?
I have this code so far:
struct Picker1Zon: View {
//Variable
@EnvironmentObject var name: SelectNames
//Waarden
@EnvironmentObject var vuur: VuurValues
@EnvironmentObject var aarde: AardeValues
@EnvironmentObject var lucht: LuchtValues
@EnvironmentObject var water: WaterValues
//PickerSelect
@EnvironmentObject var picker: PickerSelectValues
//Profiles
@ObservedObject var profileRam = RamProfile()
@ObservedObject var profileStier = StierProfile()
@ObservedObject var profileTweelingen = TweelingenProfile()
@ObservedObject var profileKreeft = KreeftProfile()
@ObservedObject var profileLeeuw = LeeuwProfile()
@ObservedObject var profileMaagd = MaagdProfile()
@ObservedObject var profileWeegschaal = WeegschaalProfile()
@ObservedObject var profileSchorpioen = SchorpioenProfile()
@ObservedObject var profileBoogschutter = BoogschutterProfile()
@ObservedObject var profileSteenbok = SteenbokProfile()
@ObservedObject var profileWaterman = WatermanProfile()
@ObservedObject var profileVissen = VissenProfile()
var body: some View {
VStack{
Picker(selection: $name.Select1Variable , label: Text("")){
Group {
Text("Selecteer...").tag(" ")
Text("\(profileRam.sterrenbeeldIcon) Ram").tag("Ram")
Text("\(profileStier.sterrenbeeldIcon) Stier").tag("Stier")
Text("\(profileTweelingen.sterrenbeeldIcon) Tweelingen").tag("Tweelingen")
Text("\(profileKreeft.sterrenbeeldIcon) Kreeft").tag("Kreeft")
Text("\(profileLeeuw.sterrenbeeldIcon) Leeuw").tag("Leeuw")
Text("\(profileMaagd.sterrenbeeldIcon) Maagd").tag("Maagd")
}
Group {
Text("\(profileWeegschaal.sterrenbeeldIcon) Weegschaal").tag("Weegschaal")
Text("\(profileSchorpioen.sterrenbeeldIcon) Schorpioen").tag("Schorpioen")
Text("\(profileBoogschutter.sterrenbeeldIcon) Boogschutter").tag("Boogschutter")
Text("\(profileSteenbok.sterrenbeeldIcon) Steenbok").tag("Steenbok")
Text("\(profileWaterman.sterrenbeeldIcon) Waterman").tag("Waterman")
Text("\(profileVissen.sterrenbeeldIcon) Vissen").tag("Vissen")
}
}
.pickerStyle(WheelPickerStyle())
.padding(.horizontal, 90.0)
.background(content: {
Rectangle()
.foregroundColor(.white)
.padding(.vertical, -15)
.cornerRadius(17)
.frame(width: 250, height: 200)
})
}
.animation(.easeInOut(duration: 0.35).delay(0.25), value: picker.picker1)
.scaleEffect(picker.picker1 ? 1 : 0)
.opacity(picker.picker1 ? 1 : 0.2)
.animation(.easeInOut(duration: 0.30), value: picker.picker1)
}
}
.
In this code design I have only one observed variable that changes, but I would like to change multiple. Is there a way to do this?