Created
January 4, 2026 14:01
-
-
Save bguidolim/4f69c1435d470b77f000cafcfde7d7c7 to your computer and use it in GitHub Desktop.
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
| import SwiftUI | |
| public struct ForEachIndex<ItemType: Identifiable, ContentView: View>: View { | |
| let data: [ItemType] | |
| let content: (Int, ItemType) -> ContentView | |
| public init(_ data: [ItemType], @ViewBuilder content: @escaping (Int, ItemType) -> ContentView) { | |
| self.data = data | |
| self.content = content | |
| } | |
| public var body: some View { | |
| ForEach(Array(zip(data.indices, data)), id: \.1.id) { idx, item in | |
| content(idx, item) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment