This is the child component:
import SwiftUI
struct CourseCell: View {
var course: Course
var body: some View {
HStack(spacing: 12){
Image(systemName: "person.circle.fill")
.resizable()
.frame(width: 48, height: 48)
.foregroundStyle(Color(.systemGray5))
VStack(alignment: .leading, content: {
Text(course.name)
.font(.subheadline)
.fontWeight(.semibold)
Text(course.description)
.font(.footnote)
})
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
}
.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/)
.contentShape(Rectangle())
}
}
#Preview {
ForEach(courses){ course in
CourseCell(course: course)
}
}
This is the parent component:
import SwiftUI
struct CoursesView: View {
var body: some View {
NavigationStack {
ScrollView() {
LazyVStack() {
ForEach(courses) { course in
NavigationLink(destination: FeedView()) {
CourseCell(course: course)
.padding(.horizontal)
.foregroundColor(.primary)
}
}
}
}
.navigationTitle("Courses")
.navigationBarTitleDisplayMode(.inline)
}
}
}
#Preview {
CoursesView()
}
I tried putting it in chatgpt and it had no idea. Everything seems right. There are no global styles as well. The CourseCell is a custom view that displays course information, and it’s used within CoursesView which is a scrollable list of these cells. Based on your description and the provided code, everything seems structurally correct.




