In some cases, the struct design in heavier than func design, for little subviews. But is there any problem to use functions rather than structs?
Eg:
func ƒText(_ text: String, fontSize: CGFloat = 13) -> some View {
Text(text)
.font(.system(size: fontSize))
}
compared to:
struct sText: View {
let text: String
let fontSize: CGFloat
init(_ text: String, fontSize: CGFloat = 13) {
self.text = text ; self.fontSize = fontSize
}
var body: some View {
Text(text)
.font(.system(size: fontSize))
}
}
@ViewBuilderthere is no problem. You can use computed variables as well.