Skip to content

Commit 8b7d67d

Browse files
committed
Run formatter, add branching, #available support, don't inline everything.
1 parent 2537f7a commit 8b7d67d

File tree

3 files changed

+49
-30
lines changed

3 files changed

+49
-30
lines changed

Package.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
import PackageDescription
44

55
let package = Package(
6-
name: "ViewModifierBuilder",
7-
platforms: [
8-
.iOS(.v13),
9-
.macOS(.v10_15),
10-
.tvOS(.v13),
11-
.watchOS(.v6)
12-
],
13-
products: [
14-
.library(
15-
name: "ViewModifierBuilder",
16-
targets: ["ViewModifierBuilder"]),
17-
],
18-
targets: [
19-
.target(
20-
name: "ViewModifierBuilder",
21-
dependencies: [],
22-
path: "Sources")
23-
]
6+
name: "ViewModifierBuilder",
7+
platforms: [
8+
.iOS(.v13),
9+
.macOS(.v10_15),
10+
.tvOS(.v13),
11+
.watchOS(.v6),
12+
],
13+
products: [
14+
.library(
15+
name: "ViewModifierBuilder",
16+
targets: ["ViewModifierBuilder"])
17+
],
18+
targets: [
19+
.target(
20+
name: "ViewModifierBuilder",
21+
dependencies: [],
22+
path: "Sources")
23+
]
2424
)

Sources/View+Modifiers.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ extension View {
1010
modifier(ApplyViewModifiers(modifiers))
1111
}
1212
}
13-

Sources/ViewModifierBuilder.swift

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ import SwiftUI
44
@resultBuilder public enum ViewModifierBuilder {
55

66
/// Builds an empty ViewModifer from a block containing no statements.
7-
@inlinable public static func buildBlock() -> EmptyModifier {
7+
public static func buildBlock() -> EmptyModifier {
88
EmptyModifier()
99
}
1010

1111
/// Passes a single view written as a child view through unmodified.
12-
@inlinable public static func buildBlock<Modifier>(_ modifier: Modifier) -> Modifier
12+
public static func buildBlock<Modifier>(_ modifier: Modifier) -> Modifier
1313
where Modifier: ViewModifier {
1414
modifier
1515
}
1616

17-
@inlinable public static func buildBlock<M0, M1>(_ m0: M0, _ m1: M1) -> some ViewModifier
17+
public static func buildBlock<M0, M1>(_ m0: M0, _ m1: M1) -> some ViewModifier
1818
where M0: ViewModifier, M1: ViewModifier {
1919
m0.concat(m1)
2020
}
2121

22-
@inlinable public static func buildBlock<M0, M1, M2>(_ m0: M0, _ m1: M1, _ m2: M2)
22+
public static func buildBlock<M0, M1, M2>(_ m0: M0, _ m1: M1, _ m2: M2)
2323
-> some ViewModifier where M0: ViewModifier, M1: ViewModifier, M2: ViewModifier
2424
{
2525
m0.concat(m1).concat(m2)
2626
}
2727

28-
@inlinable public static func buildBlock<M0, M1, M2, M3>(_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3)
28+
public static func buildBlock<M0, M1, M2, M3>(_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3)
2929
-> some ViewModifier
3030
where M0: ViewModifier, M1: ViewModifier, M2: ViewModifier, M3: ViewModifier {
3131
m0.concat(m1).concat(m2).concat(m3)
3232
}
3333

34-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4>(
34+
public static func buildBlock<M0, M1, M2, M3, M4>(
3535
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4
3636
) -> some ViewModifier
3737
where M0: ViewModifier, M1: ViewModifier, M2: ViewModifier, M3: ViewModifier, M4: ViewModifier {
3838
m0.concat(m1).concat(m2).concat(m3).concat(m4)
3939
}
4040

41-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4, M5>(
41+
public static func buildBlock<M0, M1, M2, M3, M4, M5>(
4242
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4, _ m5: M5
4343
) -> some ViewModifier
4444
where
@@ -48,7 +48,7 @@ import SwiftUI
4848
m0.concat(m1).concat(m2).concat(m3).concat(m4).concat(m5)
4949
}
5050

51-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4, M5, M6>(
51+
public static func buildBlock<M0, M1, M2, M3, M4, M5, M6>(
5252
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4, _ m5: M5, _ m6: M6
5353
) -> some ViewModifier
5454
where
@@ -58,7 +58,7 @@ import SwiftUI
5858
m0.concat(m1).concat(m2).concat(m3).concat(m4).concat(m5).concat(m6)
5959
}
6060

61-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7>(
61+
public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7>(
6262
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4, _ m5: M5, _ m6: M6, _ m7: M7
6363
) -> some ViewModifier
6464
where
@@ -68,7 +68,7 @@ import SwiftUI
6868
m0.concat(m1).concat(m2).concat(m3).concat(m4).concat(m5).concat(m6).concat(m7)
6969
}
7070

71-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7, M8>(
71+
public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7, M8>(
7272
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4, _ m5: M5, _ m6: M6, _ m7: M7, _ m8: M8
7373
) -> some ViewModifier
7474
where
@@ -78,7 +78,7 @@ import SwiftUI
7878
m0.concat(m1).concat(m2).concat(m3).concat(m4).concat(m5).concat(m6).concat(m7).concat(m8)
7979
}
8080

81-
@inlinable public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7, M8, M9>(
81+
public static func buildBlock<M0, M1, M2, M3, M4, M5, M6, M7, M8, M9>(
8282
_ m0: M0, _ m1: M1, _ m2: M2, _ m3: M3, _ m4: M4, _ m5: M5, _ m6: M6, _ m7: M7, _ m8: M8,
8383
_ m9: M9
8484
) -> some ViewModifier
@@ -89,4 +89,24 @@ import SwiftUI
8989
m0.concat(m1).concat(m2).concat(m3).concat(m4).concat(m5).concat(m6).concat(m7).concat(m8)
9090
.concat(m9)
9191
}
92+
93+
/// Provides support for “if” statements in multi-statement closures, producing conditional content for the “then” branch.
94+
public static func buildEither<Modifier>(first left: Modifier) -> some ViewModifier
95+
where Modifier: ViewModifier {
96+
left
97+
}
98+
99+
/// Provides support for “if-else” statements in multi-statement closures, producing conditional content for the “else” branch.
100+
public static func buildEither<Modifier>(second right: Modifier) -> some ViewModifier
101+
where Modifier: ViewModifier {
102+
right
103+
}
104+
105+
/// Provides support for “if” statements with #available() clauses in multi-statement closures,
106+
/// producing conditional content for the “then” branch, i.e. the conditionally-available branch.
107+
public static func buildLimitedAvailability<Modifier>(_ modifier: Modifier)
108+
-> some ViewModifier where Modifier: ViewModifier
109+
{
110+
modifier
111+
}
92112
}

0 commit comments

Comments
 (0)