Hi! There must be a simpler way to do this, right?
I have like 25 instances of the types "priceLevel", "outside" and "tastings" variables. I can get it to loop like this through the var ratings:[Ratings] array but not the next step to get the actual var in the array, like "priceLevel" and so on.
In my "ContentView()" i declare my "breweriesData" at startup.
What is it I can't get my head around?
Thanks!
struct RatingsView: View {
// MARK: - properties
var brewery:Brewery
var headlineColor:Color = Color("ColorDark")
var body: some View {
HStack (alignment: .top) {
ForEach (brewery.ratings, id:\.id) { section in
ScrollView (.horizontal, showsIndicators: false) {
HStack (alignment: .top) {
// Price level
HStack (alignment: .top, spacing: 10) {
Image("\(section.priceLevel[0])")
.font(.system(size: 30))
.padding(.top, 5)
VStack (alignment: .leading, spacing: 2) {
Text("\(section.priceLevel[1])").bold()
.foregroundColor(self.headlineColor)
Text("\(section.priceLevel[2])")
}.font(.footnote).frame(idealWidth: 100, idealHeight: 200)
}
.padding(10)
.padding(.trailing, 5)
.background(Color(.white))
.cornerRadius(6)
// Outside area
HStack (alignment: .top, spacing: 10) {
Image("\(section.outside[0])")
.font(.system(size: 30))
.padding(.top, 5)
VStack (alignment: .leading, spacing: 2) {
Text("\(section.outside[1])").bold()
.foregroundColor(self.headlineColor)
Text("\(section.outside[2])")
//.lineLimit(3)
}.font(.footnote).frame(idealWidth: 100, idealHeight: 200)
}
.padding(10)
.padding(.trailing, 5)
.background(Color(.white))
.cornerRadius(6)
// Tastings
HStack (alignment: .top, spacing: 10) {
Image("\(section.tastings[0])")
.font(.system(size: 30))
.padding(.top, 5)
VStack (alignment: .leading, spacing: 2) {
Text("\(section.tastings[1])").bold()
.foregroundColor(self.headlineColor)
Text("\(section.tastings[2])")
}.font(.footnote).frame(idealWidth: 100, idealHeight: 200)
}
.padding(10)
.padding(.trailing, 5)
.background(Color(.white))
.cornerRadius(6)
}
}
}
}.shadow(color: Color("BlackTransparentLight"), radius: 4, x: 0, y: 0)
}
}