Skip to content

Commit 024e0a5

Browse files
authored
Most init() functions now auto-generated via template (#44)
A step towards adding footer support. #43
1 parent 1c97c37 commit 024e0a5

File tree

58 files changed

+3978
-3196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3978
-3196
lines changed

.sourcery.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sources:
2+
- Sources
3+
templates:
4+
- Templates
5+
output: Sources/Generated

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,20 @@ var body: some View {
492492
}
493493
```
494494

495+
## AutoInit Code Generation
496+
497+
**This applies only to those forking and customizing the _Tabler_ code.**
498+
499+
Many additional `init()` functions for each table variant are generated via the code template `Templates/AutoInit.stencil`.
500+
501+
To regenerate, run the [Sourcery](https://github.com/krzysztofzablocki/Sourcery) command from the project directory.
502+
503+
```
504+
$ sourcery
505+
```
506+
507+
The generated code will be found in the `Sources/Generated` directory.
508+
495509
## See Also
496510

497511
* [TablerDemo](https://github.com/openalloc/TablerDemo) - the demonstration app for this library, for value data sources
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Generated using Sourcery 1.8.1 — https://github.com/krzysztofzablocki/Sourcery
2+
// DO NOT EDIT
3+
4+
import SwiftUI
5+
6+
public extension TablerGrid {
7+
// omitting Header
8+
init(_ config: Config = .init(),
9+
@ViewBuilder row: @escaping RowContent,
10+
@ViewBuilder rowBackground: @escaping RowBackground,
11+
@ViewBuilder rowOverlay: @escaping RowOverlay
12+
, results: Results
13+
)
14+
where Header == EmptyView
15+
{
16+
self.init(config,
17+
header: { _ in EmptyView() },
18+
row: row,
19+
rowBackground: rowBackground,
20+
rowOverlay: rowOverlay,
21+
results: results
22+
)
23+
}
24+
25+
// omitting Overlay
26+
init(_ config: Config = .init(),
27+
@ViewBuilder header: @escaping HeaderContent,
28+
@ViewBuilder row: @escaping RowContent,
29+
@ViewBuilder rowBackground: @escaping RowBackground
30+
, results: Results
31+
)
32+
where RowOver == EmptyView
33+
{
34+
self.init(config,
35+
header: header,
36+
row: row,
37+
rowBackground: rowBackground,
38+
rowOverlay: { _ in EmptyView() },
39+
results: results
40+
)
41+
42+
}
43+
44+
// omitting Background
45+
init(_ config: Config = .init(),
46+
@ViewBuilder header: @escaping HeaderContent,
47+
@ViewBuilder row: @escaping RowContent,
48+
@ViewBuilder rowOverlay: @escaping RowOverlay
49+
, results: Results
50+
)
51+
where RowBack == EmptyView
52+
{
53+
self.init(config,
54+
header: header,
55+
row: row,
56+
rowBackground: { _ in EmptyView() },
57+
rowOverlay: rowOverlay,
58+
results: results
59+
)
60+
}
61+
62+
// omitting Header AND Overlay
63+
init(_ config: Config = .init(),
64+
@ViewBuilder row: @escaping RowContent,
65+
@ViewBuilder rowBackground: @escaping RowBackground
66+
, results: Results
67+
)
68+
where Header == EmptyView, RowOver == EmptyView
69+
{
70+
self.init(config,
71+
header: { _ in EmptyView() },
72+
row: row,
73+
rowBackground: rowBackground,
74+
rowOverlay: { _ in EmptyView() },
75+
results: results
76+
)
77+
}
78+
79+
// omitting Header AND Background
80+
init(_ config: Config = .init(),
81+
@ViewBuilder row: @escaping RowContent,
82+
@ViewBuilder rowOverlay: @escaping RowOverlay
83+
, results: Results
84+
)
85+
where Header == EmptyView, RowBack == EmptyView
86+
{
87+
self.init(config,
88+
header: { _ in EmptyView() },
89+
row: row,
90+
rowBackground: { _ in EmptyView() },
91+
rowOverlay: rowOverlay,
92+
results: results
93+
)
94+
}
95+
96+
// omitting Background AND Overlay
97+
init(_ config: Config = .init(),
98+
@ViewBuilder header: @escaping HeaderContent,
99+
@ViewBuilder row: @escaping RowContent
100+
, results: Results
101+
)
102+
where RowBack == EmptyView, RowOver == EmptyView
103+
{
104+
self.init(config,
105+
header: header,
106+
row: row,
107+
rowBackground: { _ in EmptyView() },
108+
rowOverlay: { _ in EmptyView() },
109+
results: results
110+
)
111+
}
112+
113+
// omitting Header, Background, AND Overlay
114+
init(_ config: Config = .init(),
115+
@ViewBuilder row: @escaping RowContent
116+
, results: Results
117+
)
118+
119+
where Header == EmptyView, RowBack == EmptyView, RowOver == EmptyView
120+
{
121+
self.init(config,
122+
header: { _ in EmptyView() },
123+
row: row,
124+
rowBackground: { _ in EmptyView() },
125+
rowOverlay: { _ in EmptyView() },
126+
results: results
127+
)
128+
}
129+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Generated using Sourcery 1.8.1 — https://github.com/krzysztofzablocki/Sourcery
2+
// DO NOT EDIT
3+
4+
import SwiftUI
5+
6+
public extension TablerGrid1 {
7+
// omitting Header
8+
init(_ config: Config = .init(),
9+
@ViewBuilder row: @escaping RowContent,
10+
@ViewBuilder rowBackground: @escaping RowBackground,
11+
@ViewBuilder rowOverlay: @escaping RowOverlay
12+
, results: Results
13+
, selected: Binding<Selected>
14+
)
15+
where Header == EmptyView
16+
{
17+
self.init(config,
18+
header: { _ in EmptyView() },
19+
row: row,
20+
rowBackground: rowBackground,
21+
rowOverlay: rowOverlay,
22+
results: results
23+
, selected: selected
24+
)
25+
}
26+
27+
// omitting Overlay
28+
init(_ config: Config = .init(),
29+
@ViewBuilder header: @escaping HeaderContent,
30+
@ViewBuilder row: @escaping RowContent,
31+
@ViewBuilder rowBackground: @escaping RowBackground
32+
, results: Results
33+
, selected: Binding<Selected>
34+
)
35+
where RowOver == EmptyView
36+
{
37+
self.init(config,
38+
header: header,
39+
row: row,
40+
rowBackground: rowBackground,
41+
rowOverlay: { _ in EmptyView() },
42+
results: results
43+
, selected: selected
44+
)
45+
46+
}
47+
48+
// omitting Background
49+
init(_ config: Config = .init(),
50+
@ViewBuilder header: @escaping HeaderContent,
51+
@ViewBuilder row: @escaping RowContent,
52+
@ViewBuilder rowOverlay: @escaping RowOverlay
53+
, results: Results
54+
, selected: Binding<Selected>
55+
)
56+
where RowBack == EmptyView
57+
{
58+
self.init(config,
59+
header: header,
60+
row: row,
61+
rowBackground: { _ in EmptyView() },
62+
rowOverlay: rowOverlay,
63+
results: results
64+
, selected: selected
65+
)
66+
}
67+
68+
// omitting Header AND Overlay
69+
init(_ config: Config = .init(),
70+
@ViewBuilder row: @escaping RowContent,
71+
@ViewBuilder rowBackground: @escaping RowBackground
72+
, results: Results
73+
, selected: Binding<Selected>
74+
)
75+
where Header == EmptyView, RowOver == EmptyView
76+
{
77+
self.init(config,
78+
header: { _ in EmptyView() },
79+
row: row,
80+
rowBackground: rowBackground,
81+
rowOverlay: { _ in EmptyView() },
82+
results: results
83+
, selected: selected
84+
)
85+
}
86+
87+
// omitting Header AND Background
88+
init(_ config: Config = .init(),
89+
@ViewBuilder row: @escaping RowContent,
90+
@ViewBuilder rowOverlay: @escaping RowOverlay
91+
, results: Results
92+
, selected: Binding<Selected>
93+
)
94+
where Header == EmptyView, RowBack == EmptyView
95+
{
96+
self.init(config,
97+
header: { _ in EmptyView() },
98+
row: row,
99+
rowBackground: { _ in EmptyView() },
100+
rowOverlay: rowOverlay,
101+
results: results
102+
, selected: selected
103+
)
104+
}
105+
106+
// omitting Background AND Overlay
107+
init(_ config: Config = .init(),
108+
@ViewBuilder header: @escaping HeaderContent,
109+
@ViewBuilder row: @escaping RowContent
110+
, results: Results
111+
, selected: Binding<Selected>
112+
)
113+
where RowBack == EmptyView, RowOver == EmptyView
114+
{
115+
self.init(config,
116+
header: header,
117+
row: row,
118+
rowBackground: { _ in EmptyView() },
119+
rowOverlay: { _ in EmptyView() },
120+
results: results
121+
, selected: selected
122+
)
123+
}
124+
125+
// omitting Header, Background, AND Overlay
126+
init(_ config: Config = .init(),
127+
@ViewBuilder row: @escaping RowContent
128+
, results: Results
129+
, selected: Binding<Selected>
130+
)
131+
132+
where Header == EmptyView, RowBack == EmptyView, RowOver == EmptyView
133+
{
134+
self.init(config,
135+
header: { _ in EmptyView() },
136+
row: row,
137+
rowBackground: { _ in EmptyView() },
138+
rowOverlay: { _ in EmptyView() },
139+
results: results
140+
, selected: selected
141+
)
142+
}
143+
}

0 commit comments

Comments
 (0)