Created
May 3, 2020 08:42
-
-
Save michzio/464cf1b952e7bc6346dfe9000a03eccb to your computer and use it in GitHub Desktop.
CollectionView in SwiftUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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