Skip to content

Commit

Permalink
Most init() functions now auto-generated via template (#44)
Browse files Browse the repository at this point in the history
A step towards adding footer support. #43
  • Loading branch information
reedes committed May 5, 2022
1 parent 1c97c37 commit 024e0a5
Show file tree
Hide file tree
Showing 58 changed files with 3,978 additions and 3,196 deletions.
5 changes: 5 additions & 0 deletions .sourcery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
- Sources
templates:
- Templates
output: Sources/Generated
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,20 @@ var body: some View {
}
```

## AutoInit Code Generation

**This applies only to those forking and customizing the _Tabler_ code.**

Many additional `init()` functions for each table variant are generated via the code template `Templates/AutoInit.stencil`.

To regenerate, run the [Sourcery](https://github.com/krzysztofzablocki/Sourcery) command from the project directory.

```
$ sourcery
```

The generated code will be found in the `Sources/Generated` directory.

## See Also

* [TablerDemo](https://github.com/openalloc/TablerDemo) - the demonstration app for this library, for value data sources
Expand Down
129 changes: 129 additions & 0 deletions Sources/Generated/TablerGrid+AutoInit.generated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Generated using Sourcery 1.8.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import SwiftUI

public extension TablerGrid {
// omitting Header
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
)
where Header == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: rowBackground,
rowOverlay: rowOverlay,
results: results
)
}

// omitting Overlay
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground
, results: Results
)
where RowOver == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: rowBackground,
rowOverlay: { _ in EmptyView() },
results: results
)

}

// omitting Background
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
)
where RowBack == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: rowOverlay,
results: results
)
}

// omitting Header AND Overlay
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground
, results: Results
)
where Header == EmptyView, RowOver == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: rowBackground,
rowOverlay: { _ in EmptyView() },
results: results
)
}

// omitting Header AND Background
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
)
where Header == EmptyView, RowBack == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: rowOverlay,
results: results
)
}

// omitting Background AND Overlay
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent
, results: Results
)
where RowBack == EmptyView, RowOver == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: { _ in EmptyView() },
results: results
)
}

// omitting Header, Background, AND Overlay
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent
, results: Results
)

where Header == EmptyView, RowBack == EmptyView, RowOver == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: { _ in EmptyView() },
results: results
)
}
}
143 changes: 143 additions & 0 deletions Sources/Generated/TablerGrid1+AutoInit.generated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Generated using Sourcery 1.8.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import SwiftUI

public extension TablerGrid1 {
// omitting Header
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
, selected: Binding<Selected>
)
where Header == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: rowBackground,
rowOverlay: rowOverlay,
results: results
, selected: selected
)
}

// omitting Overlay
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground
, results: Results
, selected: Binding<Selected>
)
where RowOver == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: rowBackground,
rowOverlay: { _ in EmptyView() },
results: results
, selected: selected
)

}

// omitting Background
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
, selected: Binding<Selected>
)
where RowBack == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: rowOverlay,
results: results
, selected: selected
)
}

// omitting Header AND Overlay
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowBackground: @escaping RowBackground
, results: Results
, selected: Binding<Selected>
)
where Header == EmptyView, RowOver == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: rowBackground,
rowOverlay: { _ in EmptyView() },
results: results
, selected: selected
)
}

// omitting Header AND Background
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent,
@ViewBuilder rowOverlay: @escaping RowOverlay
, results: Results
, selected: Binding<Selected>
)
where Header == EmptyView, RowBack == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: rowOverlay,
results: results
, selected: selected
)
}

// omitting Background AND Overlay
init(_ config: Config = .init(),
@ViewBuilder header: @escaping HeaderContent,
@ViewBuilder row: @escaping RowContent
, results: Results
, selected: Binding<Selected>
)
where RowBack == EmptyView, RowOver == EmptyView
{
self.init(config,
header: header,
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: { _ in EmptyView() },
results: results
, selected: selected
)
}

// omitting Header, Background, AND Overlay
init(_ config: Config = .init(),
@ViewBuilder row: @escaping RowContent
, results: Results
, selected: Binding<Selected>
)

where Header == EmptyView, RowBack == EmptyView, RowOver == EmptyView
{
self.init(config,
header: { _ in EmptyView() },
row: row,
rowBackground: { _ in EmptyView() },
rowOverlay: { _ in EmptyView() },
results: results
, selected: selected
)
}
}
Loading

0 comments on commit 024e0a5

Please sign in to comment.