This is my code:
var body: some View {
List(months) { month in
NavigationLink {
MonthView(month: month)
} label: {
MonthElementView(month: month)
}
.listRowBackground(
Color(uiColor: mode.underlayBackgroundColor)
.clipped()
.cornerRadius(10)
)
}
.navigationTitle(months.first?.descriptiveYear ?? "")
}
This simply works as expected, but I need to use MonthElementView(month: month)
also here:
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 3, content: {
if let month = month {
MonthElementView(month: month)
} else {
Text("Nothing here yet")
}
})
}
}
and here it doesn't work. Is there a way to setup .listRowBackground style directly inside my MonthElementView
?
Here is the body for MonthElementView
:
var body: some View {
VStack(alignment: .center, spacing: 8, content: {
// some staff here
})
.frame(maxWidth: .infinity)
.padding(.top, 10)
.padding(.bottom, 10)
.padding(.leading, 2)
.padding(.trailing, 2)
}