Created
July 23, 2020 00:34
-
-
Save jamesrochabrun/1d310e2d74c9f1ec53a7b62ce6b807d9 to your computer and use it in GitHub Desktop.
GenericList using Swift UI.
This file contains 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
// 1 | |
struct GenericList<Element, RowContent: View>: View where Element: Identifiable { | |
// 2 | |
private let items: [Element] | |
private let rowContent: (Element) -> RowContent | |
// 3 | |
public init(_ items: [Element], @ViewBuilder rowContent: @escaping (Element) -> RowContent) { | |
self.items = items | |
self.rowContent = rowContent | |
} | |
// 4 | |
var body: some View { | |
List(items, rowContent: rowContent) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment