Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michzio/464cf1b952e7bc6346dfe9000a03eccb to your computer and use it in GitHub Desktop.
Save michzio/464cf1b952e7bc6346dfe9000a03eccb to your computer and use it in GitHub Desktop.
CollectionView in SwiftUI
CollectionView(layout: createLayout(),
sections: self.sections,
items: [
.feature : Item.featureItems,
.categories : Item.categoryItems
],
supplementaryKinds: ["header", "footer"],
supplementaryContent: { kind, indexPath, item in
switch kind {
case "header":
return AnyView(Text("Header").font(.system(size: indexPath.section == 0 ? 30 : 16)))
case "footer":
return AnyView(Text("Footer"))
default:
return AnyView(EmptyView())
}
},
content: { indexPath, item in
AnyView(Text("\(self.sections.first!.rawValue) (\(indexPath.section), \(indexPath.row))"))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment