Skip to content

Commit

Permalink
Update for swift 5.8 (#4)
Browse files Browse the repository at this point in the history
* updated result builder

* updated views init to avoid ambiguity
  • Loading branch information
KazaiMazai authored Aug 21, 2023
1 parent 3715de1 commit dfc9c59
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
8 changes: 2 additions & 6 deletions Sources/SwiftyUIKit/HStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import UIKit

public extension HStackView {
convenience init(spacing: CGFloat = 0, @ViewContentBuilder content: () -> [UIView]) {
self.init(spacing: spacing, content: content())
}

convenience init(spacing: CGFloat = 0, @OptionalViewContentBuilder optionalContent: () -> [UIView]) {
self.init(spacing: spacing, content: optionalContent())
convenience init(spacing: CGFloat = 0, @ViewContentBuilder contentBuilder: () -> [UIView]) {
self.init(spacing: spacing, content: contentBuilder())
}
}

Expand Down
8 changes: 2 additions & 6 deletions Sources/SwiftyUIKit/VStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import UIKit

public extension VStackView {
convenience init(spacing: CGFloat = 0, @ViewContentBuilder content: () -> [UIView]) {
self.init(spacing: spacing, content: content())
}

convenience init(spacing: CGFloat = 0, @OptionalViewContentBuilder optionalContent: () -> [UIView]) {
self.init(spacing: spacing, content: optionalContent())
convenience init(spacing: CGFloat = 0, @ViewContentBuilder _ contentBuilder: () -> [UIView]) {
self.init(spacing: spacing, content: contentBuilder())
}
}

Expand Down
7 changes: 0 additions & 7 deletions Sources/SwiftyUIKit/ViewContentBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ import UIKit

@resultBuilder
public struct ViewContentBuilder {
public static func buildBlock(_ subviews: UIView...) -> [UIView] {
subviews
}
}

@resultBuilder
public struct OptionalViewContentBuilder {
public static func buildBlock(_ subviews: UIView?...) -> [UIView] {
subviews.compactMap { $0 }
}
Expand Down
8 changes: 2 additions & 6 deletions Sources/SwiftyUIKit/ZStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import UIKit

public extension ZStackView {
convenience init(alignment: Alignment = .all, @ViewContentBuilder content: () -> [UIView]) {
self.init(alignment: alignment, content: content())
}

convenience init(alignment: Alignment = .all, @OptionalViewContentBuilder optionalContent: () -> [UIView]) {
self.init(alignment: alignment, content: optionalContent())
convenience init(alignment: Alignment = .all, @ViewContentBuilder _ contentBuilder: () -> [UIView]) {
self.init(alignment: alignment, content: contentBuilder())
}
}

Expand Down

0 comments on commit dfc9c59

Please sign in to comment.