Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/32648272c1f2d103fffb2a74260e54b3 to your computer and use it in GitHub Desktop.
Save jacobsapps/32648272c1f2d103fffb2a74260e54b3 to your computer and use it in GitHub Desktop.
struct CardGridView: View {
@Query(sort: \CardEntity.title) private var cardEntities: [CardEntity]
var body: some View {
NavigationStack {
ScrollView {
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: 12) {
ForEach(cardEntities.compactMap { $0.toCard() }) { card in
CardView(card: card, size: .small, showEffects: false)
.onTapGesture {
selectedCard = card
}
}
}
.padding()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment