-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEnumerationView.swift
51 lines (45 loc) · 1.18 KB
/
EnumerationView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// EnumerationView.swift
//
// Created by Andreas in 2020
//
import SequenceBuilder
import SwiftUI
public struct EnumerationView<Content: Sequence>: View where Content.Element: View {
let content: Content
public init(@SequenceBuilder builder: () -> Content) {
self.content = builder()
}
public var body: some View {
VStack(alignment: .leading, spacing: 8) {
ForEach(sequence: content) { (index, content) in
HStack(alignment: .top) {
Text("\(index + 1). ")
content
}
}
}
}
}
struct EnumerationView_Previews: PreviewProvider {
static var previews: some View {
EnumerationView {
Text("Some text")
VStack {
ForEach(0..<10, id: \.self) { _ in
Text("Lorem ipsum dolet.")
}
}
if true {
Text("More text")
Text("Enough text")
}
HStack {
Text("With image:")
Image(systemName: "checkmark")
}
Text("The ending")
}
.padding()
}
}