Skip to content

Commit 9f6528c

Browse files
committed
added foreach range init
1 parent 6ddacb9 commit 9f6528c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Sources/SwiftCrossUI/Views/ForEach.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ extension ForEach where Child == [MenuItem] {
1818
}
1919
}
2020

21+
extension ForEach where Items == [Int] {
22+
public init(
23+
_ range: ClosedRange<Int>,
24+
child: @escaping (Int) -> Child
25+
) {
26+
self.elements = Array(range)
27+
self.child = child
28+
}
29+
30+
public init(
31+
_ range: Range<Int>,
32+
child: @escaping (Int) -> Child
33+
) {
34+
self.elements = Array(range)
35+
self.child = child
36+
}
37+
}
38+
2139
extension ForEach: TypeSafeView, View where Child: View {
2240
typealias Children = ForEachViewChildren<Items, Child>
2341

0 commit comments

Comments
 (0)