When I try to set an If query in Xcode (Swift & SwiftUI) in a view, I get the following error: Cannot invoke 'padding' with an argument list of type '(Double)'.
Once I comment out the If statement, the code works without problems. In the following code I have commented out the If statement.
What can I do to avoid the output of the error? The error is output at .padding(0.0)
var body: some View {
NavigationLink(destination: TransactionDetail(product: product)) {
HStack {
Text("X")
.font(.largeTitle)
.clipShape(Circle())
.foregroundColor(.green)
.overlay(Circle().stroke(Color.green, lineWidth: 1))
.shadow(radius: 5)
VStack(alignment: .leading) {
HStack {
Text(product.name)
.font(.headline)
.foregroundColor(.black)
}
Text("21. Januar")
.font(.caption)
.foregroundColor(.black)
}
Spacer()
Text("\(product.price),00 €")
.font(.caption)
.padding(2)
/*
if product.price > 0 {
.foregroundColor(.black)
} else {
.foregroundColor(.black)
}
*/
.cornerRadius(5)
}
.padding(0.0)
}
}
.foregroundColor(product.price > 0 ? .red : .green)instead?