\
Button(answer, action: {
let convertInput = Int(L) ?? 0
W * D
answer = String(convertInput)
}
{ Text("Calculate"). X Extra trailing closure passed in call
It seems you have a lot of debris leftover from you stumbling around trying to find a solution. I removed it, and put your code through an autoformatter tool :)
Group {
Text("Calculator").font(.body)
Spacer()
Text("Area")
TextField("L", text: $L).keyboardType(.numberPad)
TextField("w", text: $W).keyboardType(.numberPad)
TextField("D", text: $D).keyboardType(.numberPad)
Text("M2 \(answer)")
// } random bracket
// Button(answer, action: { extra parameter at the start, assuming you want to create the button the same way as the others
Button(
action: {
let convertInput = Int(L) ?? 0
// W * D random multiplication
answer = String(convertInput)
},
label: { Text("Calculate") }
)
Menu {
Button(action: { choicemade = "MOT Type 1" }, label: { Text("MOT Type 1") })
Button(action: { choicemade = "Crushed Concrete" }, label: { Text("Crushed Concrete") })
Button(action: { choicemade = "Sand" }, label: { Text("Sand") })
}
// label: { random label
Label(title: { Text("\(choicemade)") }, icon: { Image(systemName: "Plus") })
// } two random closing brackets
// }
if choicemade == "MOT Type 1" {
Text("MOT Type 1 selected")
}
if choicemade == "Crushed Concrete" {
Text("Crushed Concrete selected")
}
if choicemade == "Sand" {
Text("Sand selected")
}
Spacer()
Spacer()
}