Very strange scroll view bug.
When my subView called CardView is inside the List... images show fine. But when I use ScrollView instead of List (because I need to remove dividers and next arrow), than images dont display (just giant blue tint overlay) Seems like SWIFTUI is full of bugs or something.
// BUG HERE - IMAGES NOT SHOWN, JUST GIANT BLUE
ScrollView() {
ForEach(clients, id: \.id) { client in
NavigationLink(
destination: AuditsList()
) {
CardView(image: "richmond", category: client.name, heading: client.addressLine1, author: client.addressLine2)
}
// end vstack
}
}.navigationBarTitle(Text("Select Customer"))
}
// SHOWS IMAGES OK
List() {
ForEach(clients, id: \.id) { client in
NavigationLink(
destination: AuditsList()
) {
CardView(image: "richmond", category: client.name, heading: client.addressLine1, author: client.addressLine2)
}
// end vstack
}
}.navigationBarTitle(Text("Select Customer"))
}
For reference CardView:
struct CardView: View {
var image: String
var category: String
var heading: String
var author: String
var body: some View {
VStack {
Image(image)
.frame(minWidth: 0, maxWidth: .infinity, maxHeight: 100)
.aspectRatio(contentMode: .fit)
//.resizable()
HStack {
VStack(alignment: .leading) {
Text(heading)
.font(.title)
.fontWeight(.black)
.foregroundColor(.primary)
.lineLimit(3)
Text(category)
.font(.caption)
.foregroundColor(.secondary)
Text(author)
.font(.caption)
.foregroundColor(.secondary)
}
.layoutPriority(100)
Spacer()
}
.padding()
}
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(.sRGB, red: 150/255, green: 150/255, blue: 150/255, opacity: 0.1), lineWidth: 1)
)
.padding([.top, .horizontal])
}
}
struct CardView_Previews: PreviewProvider {
static var previews: some View {
CardView(image: "richmond", category: "701 East Byrd Street", heading: "Federal Reserver Bank of Richmond", author: "Richmond VA 23219")
}
}