Here is some of the code:
var body: some View {
HStack {
Text("(person.name ?? "Error") (person.vorname ?? "Error"), (person.klasse ?? "Error")")
.fontWeight(.bold)
.frame(width: 160, alignment: .leading)
Spacer(minLength: 20)
VStack {
Picker("Sprint", selection: $selectedSprint) {
ForEach(sprints, id: \.self) { sprint in
Text(sprint)
}
}
.pickerStyle(SegmentedPickerStyle())
.background(Color(UIColor(red: 135/255, green: 206/255, blue: 255/255, alpha: 1)))
.overlay(
RoundedRectangle(cornerRadius: 5)
.stroke(Color.white, lineWidth: 3))
.onAppear {
selectedSprint = person.dsprint ?? ""
}
.onChange(of: selectedSprint) { value in
person.dsprint = value
if let ergSprint = numberFormatter.number(from: ergebnisSprint)?.doubleValue {
if person.gender == "w" && selectedSprint == "50" {
P_Sprint = Int16(floor(( (50 / ( ergSprint + 0.24 ) - 3.648 ) ) / 0.0066))
}
if person.gender == "w" && selectedSprint == "75" {
P_Sprint = Int16(floor(( (75 / ( ergSprint + 0.24 ) - 3.998 ) ) / 0.0066))
}
if person.gender == "w" && selectedSprint == "100" {
P_Sprint = Int16(floor(( (100 / ( ergSprint + 0.24 ) - 4.0062 ) ) / 0.00656))
}
if person.gender == "w" && selectedSprint == "50 el" {
P_Sprint = Int16(floor(( (50 / ergSprint - 3.648 ) ) / 0.0066))
}
if person.gender == "w" && selectedSprint == "75 el" {
P_Sprint = Int16(floor(( (75 / ergSprint - 3.998 ) ) / 0.0066))
}
if person.gender == "w" && selectedSprint == "100 el" {
P_Sprint = Int16(floor(( (100 / ergSprint - 4.0062 ) ) / 0.00656))
}
if person.gender == "m" && selectedSprint == "50" {
P_Sprint = Int16(floor(( (50 / ( ergSprint + 0.24 ) - 3.79 ) ) / 0.0069))
}
if person.gender == "m" && selectedSprint == "75" {
P_Sprint = Int16(floor(( (75 / ( ergSprint + 0.24 ) - 4.1) ) / 0.00664))
}
if person.gender == "m" && selectedSprint == "100" {
P_Sprint = Int16(floor(( (100 / ( ergSprint + 0.24 ) - 4.341 ) ) / 0.00676))
}
if person.gender == "m" && selectedSprint == "50 el" {
P_Sprint = Int16(floor(( (50 / ergSprint - 3.79 ) ) / 0.0069))
}
if person.gender == "m" && selectedSprint == "75 el" {
P_Sprint = Int16(floor(( (75 / ergSprint - 4.1 ) ) / 0.00664))
}
if person.gender == "m" && selectedSprint == "100 el" {
P_Sprint = Int16(floor(( (100 / ergSprint - 4.341 ) ) / 0.00676))
}
}