I need to concatenate Text() views in SwiftUI using + operator
I tried something like this
Text("\(feed.author?.firstName ?? "") \(feed.author?.lastName ?? "") ")
.font(.custom("AvenirNext-Medium", size: 15))
.foregroundColor(.black)
ForEach(feed.titleChunks, id: \.self) { chunk in
+ Text("\(chunk)")
.font(.custom("AvenirNext-Regular", size: 15))
.foregroundColor(Color("BodyText"))
}
But it of course doesn't work. Is there a way to get array of string of unknown number of elements printed using Text so that it forms single text view in SwiftUI just like
Text("1") + Text("2") + Text("3") does?
Is there some solution to this problem. I tired static approach and it works but I do not know in advance how much Text() I have
Text("\(feed.author?.firstName ?? "") \(feed.author?.lastName ?? "") ")
.font(.custom("AvenirNext-Medium", size: 15))
.foregroundColor(.black)
+ Text("\(feed.titleChunks[0])")
.font(.custom("AvenirNext-Regular", size: 15))
.foregroundColor(Color("BodyText"))
+ Text("\(feed.titleChunks[1])")
.font(.custom("AvenirNext-DemiBold", size: 15))
.foregroundColor(Color("BodyText"))