I would like to use this function as a template with immutable values in a SwiftUI layout but get the error Result of call to 'padding' is unused:
func keys (padding: CGFloat, text: String, color: Color?) {
Rectangle()
.foregroundColor(color)
.padding(.trailing, padding)
.padding(.leading, padding)
Text(text)
.font(.largeTitle)
.foregroundColor(.white)
}
Thanks for any help.
Here it is
func keys (padding: CGFloat, text: String, color: Color?) -> some View {
Group { // << or any other container you want
Rectangle()
.foregroundColor(color)
.padding(.trailing, padding)
.padding(.leading, padding)
Text(text)
.font(.largeTitle)
.foregroundColor(.white)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With