diff --git a/MondrianLayout/Classic/MondrianArrayBuilder.swift b/MondrianLayout/Classic/MondrianArrayBuilder.swift index a2f1f14..8a377a0 100644 --- a/MondrianLayout/Classic/MondrianArrayBuilder.swift +++ b/MondrianLayout/Classic/MondrianArrayBuilder.swift @@ -25,6 +25,10 @@ public struct MondrianArrayBuilder { public static func buildEither(second component: [Element]) -> [Element] { return component } + + public static func buildArray(_ components: [[Element]]) -> [Element] { + components.flatMap { $0 } + } public static func buildExpression(_ element: Element?) -> [Element] { return element.map { [$0] } ?? [] diff --git a/MondrianLayout/Descriptors/VHStackContentBuilder.swift b/MondrianLayout/Descriptors/VHStackContentBuilder.swift index 61500df..b07f28e 100644 --- a/MondrianLayout/Descriptors/VHStackContentBuilder.swift +++ b/MondrianLayout/Descriptors/VHStackContentBuilder.swift @@ -153,6 +153,10 @@ public enum VStackContentBuilder { public static func buildEither(second component: [Component]) -> [Component] { return component } + + public static func buildArray(_ components: [[Component]]) -> [Component] { + return components.flatMap { $0 } + } public static func buildExpression(_ layoutGuides: [UILayoutGuide]...) -> [Component] { return layoutGuides.flatMap { $0 }.map { @@ -227,6 +231,10 @@ public enum HStackContentBuilder { public static func buildEither(second component: [Component]) -> [Component] { return component } + + public static func buildArray(_ components: [[Component]]) -> [Component] { + components.flatMap { $0 } + } public static func buildExpression(_ views: [UIView]...) -> [Component] { return views.flatMap { $0 }.map { diff --git a/MondrianLayout/LayoutBlocks/VGridBlock.swift b/MondrianLayout/LayoutBlocks/VGridBlock.swift index ad6f10b..1bd43fd 100644 --- a/MondrianLayout/LayoutBlocks/VGridBlock.swift +++ b/MondrianLayout/LayoutBlocks/VGridBlock.swift @@ -263,6 +263,10 @@ public enum VGridContentBuilder { public static func buildEither(second component: [Component]) -> [Component] { return component } + + public static func buildArray(_ components: [[Component]]) -> [Component] { + components.flatMap { $0 } + } public static func buildExpression(_ views: [UIView]...) -> [Component] { return views.flatMap { $0 }.map { diff --git a/MondrianLayout/LayoutBlocks/ZStackBlock.swift b/MondrianLayout/LayoutBlocks/ZStackBlock.swift index 2a344ad..c3743d6 100644 --- a/MondrianLayout/LayoutBlocks/ZStackBlock.swift +++ b/MondrianLayout/LayoutBlocks/ZStackBlock.swift @@ -263,7 +263,11 @@ public enum ZStackContentBuilder { public static func buildEither(second component: [Component]) -> [Component] { return component } - + + public static func buildArray(_ components: [[Component]]) -> [Component] { + components.flatMap { $0 } + } + public static func buildExpression(_ layoutGuides: [UILayoutGuide]...) -> [Component] { return layoutGuides.flatMap { $0 }.map { .init(node: .layoutGuide(.init($0)))