From 970ec09c8d2f2e8fca3c84bdbdee0dd9624a33ea Mon Sep 17 00:00:00 2001 From: dungntm58 Date: Tue, 8 Mar 2022 01:44:28 +0700 Subject: [PATCH 1/2] Extend ForEach's ability. Update Layoutless. Support SPM --- .../contents.xcworkspacedata | 7 +++ Package.swift | 27 +++++++++ .../project.pbxproj | 46 ++++++++-------- SwiftUIKit/Core/LayoutFunction.swift | 55 ++++++++----------- .../DeclarativeExtension/UI/UI-Button.swift | 8 --- .../UI/UI-CollectionViewCell.swift | 8 --- .../DeclarativeExtension/UI/UI-Control.swift | 8 --- .../UI/UI-ImageView.swift | 8 --- .../DeclarativeExtension/UI/UI-Label.swift | 8 --- .../UI/UI-TableViewCell.swift | 8 --- .../UI/UI-TextField.swift | 8 --- .../DeclarativeExtension/UI/UI-View.swift | 13 +---- .../UI/UI-ViewController.swift | 18 ++---- .../DeclarativeExtension/Views/ForEach.swift | 8 +-- .../Views/HStackView.swift | 24 +------- .../Views/LayoutBuilder.swift | 2 +- .../Views/StackView.swift | 24 +------- .../Views/StackViewProtocol.swift | 24 -------- .../Views/ZStackView.swift | 47 ++-------------- 19 files changed, 103 insertions(+), 248 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Package.swift delete mode 100644 SwiftUIKit/DeclarativeExtension/Views/StackViewProtocol.swift diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..3179e58 --- /dev/null +++ b/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftUIKit", + platforms: [.iOS(.v11)], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "SwiftUIKit", + targets: ["SwiftUIKit"]) + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "SwiftUIKit", + path: "SwiftUIKit" + ) + ], + swiftLanguageVersions: [.v5] +) diff --git a/SwiftUIKit-Example/SwiftUIKit-Example.xcodeproj/project.pbxproj b/SwiftUIKit-Example/SwiftUIKit-Example.xcodeproj/project.pbxproj index 02c2403..b5de6fe 100644 --- a/SwiftUIKit-Example/SwiftUIKit-Example.xcodeproj/project.pbxproj +++ b/SwiftUIKit-Example/SwiftUIKit-Example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -11,30 +11,12 @@ 1C28A7BD262E7D9F0036951E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1C28A7BC262E7D9F0036951E /* Assets.xcassets */; }; 1C28A7C0262E7D9F0036951E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1C28A7BE262E7D9F0036951E /* LaunchScreen.storyboard */; }; 1C28A7D0262E7E740036951E /* HomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A7CF262E7E740036951E /* HomeVC.swift */; }; - 1C28A81C262E84570036951E /* SwiftUIKitCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C28A81B262E84570036951E /* SwiftUIKitCore.framework */; }; - 1C28A81D262E84570036951E /* SwiftUIKitCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1C28A81B262E84570036951E /* SwiftUIKitCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 1C28A823262E850D0036951E /* SwiftUIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C28A822262E850D0036951E /* SwiftUIKit.framework */; }; - 1C28A824262E850D0036951E /* SwiftUIKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1C28A822262E850D0036951E /* SwiftUIKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1C28A8DF26314DF10036951E /* Themes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8DE26314DF10036951E /* Themes.swift */; }; 1C28A8E6263155410036951E /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8E5263155410036951E /* Styles.swift */; }; 1C28A8F5263172320036951E /* BasicVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8F4263172320036951E /* BasicVC.swift */; }; + E184120427D7011700680F85 /* SwiftUIKit in Frameworks */ = {isa = PBXBuildFile; productRef = E184120327D7011700680F85 /* SwiftUIKit */; }; /* End PBXBuildFile section */ -/* Begin PBXCopyFilesBuildPhase section */ - 1C28A7D7262E7F670036951E /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 1C28A81D262E84570036951E /* SwiftUIKitCore.framework in Embed Frameworks */, - 1C28A824262E850D0036951E /* SwiftUIKit.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 1C28A7B0262E7D9D0036951E /* SwiftUIKit-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUIKit-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1C28A7B3262E7D9D0036951E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -50,6 +32,7 @@ 1C28A8DE26314DF10036951E /* Themes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Themes.swift; sourceTree = ""; }; 1C28A8E5263155410036951E /* Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styles.swift; sourceTree = ""; }; 1C28A8F4263172320036951E /* BasicVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicVC.swift; sourceTree = ""; }; + E184120227D700F800680F85 /* SwiftUIKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftUIKit; path = ..; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -57,8 +40,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1C28A81C262E84570036951E /* SwiftUIKitCore.framework in Frameworks */, - 1C28A823262E850D0036951E /* SwiftUIKit.framework in Frameworks */, + E184120427D7011700680F85 /* SwiftUIKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -68,6 +50,7 @@ 1C28A7A7262E7D9D0036951E = { isa = PBXGroup; children = ( + E184120127D700F800680F85 /* Packages */, 1C28A7B2262E7D9D0036951E /* SwiftUIKit-Example */, 1C28A7B1262E7D9D0036951E /* Products */, 1C28A7D3262E7F670036951E /* Frameworks */, @@ -141,6 +124,14 @@ path = Manager; sourceTree = ""; }; + E184120127D700F800680F85 /* Packages */ = { + isa = PBXGroup; + children = ( + E184120227D700F800680F85 /* SwiftUIKit */, + ); + name = Packages; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -151,13 +142,15 @@ 1C28A7AC262E7D9D0036951E /* Sources */, 1C28A7AD262E7D9D0036951E /* Frameworks */, 1C28A7AE262E7D9D0036951E /* Resources */, - 1C28A7D7262E7F670036951E /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( ); name = "SwiftUIKit-Example"; + packageProductDependencies = ( + E184120327D7011700680F85 /* SwiftUIKit */, + ); productName = "SwiftUIKit-Example"; productReference = 1C28A7B0262E7D9D0036951E /* SwiftUIKit-Example.app */; productType = "com.apple.product-type.application"; @@ -409,6 +402,13 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + E184120327D7011700680F85 /* SwiftUIKit */ = { + isa = XCSwiftPackageProductDependency; + productName = SwiftUIKit; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 1C28A7A8262E7D9D0036951E /* Project object */; } diff --git a/SwiftUIKit/Core/LayoutFunction.swift b/SwiftUIKit/Core/LayoutFunction.swift index 9bf49a4..42714aa 100644 --- a/SwiftUIKit/Core/LayoutFunction.swift +++ b/SwiftUIKit/Core/LayoutFunction.swift @@ -92,6 +92,29 @@ extension View where Node: Anchorable { } } +// MARK: Insetting +extension View where Node: Anchorable { + + /// Inset the node by wrapping it in a dummy view and filling it using the given insets. + public func insetting(leftBy left: CGFloat, rightBy right: CGFloat, topBy top: CGFloat, bottomBy bottom: CGFloat) -> Layout { + return insetting(by: UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)) + } + + /// Inset the node by wrapping it in a dummy view and filling it using the given insets. + public func insetting(by insets: CGFloat) -> Layout { + return insetting(by: UIEdgeInsets(top: insets, left: insets, bottom: insets, right: insets)) + } + + /// Inset the node by wrapping it in a dummy view and filling it using the given insets. + public func insetting(by insets: UIEdgeInsets) -> Layout { + return Layout { revertable in + let container = UIView() + revertable.append(self.fillingParent(insets: insets).makeSomeViewNode(revertable).layout(in: container)) + return container + } + } +} + extension View where Node: Anchorable { public func centeringInParent(xOffset: Length? = 0, yOffset: Length? = 0, relativeToSafeArea: Bool) -> Layout> { return layout { (parent, node, revertable) in @@ -252,31 +275,6 @@ extension View where Node: UIView { } } -// MARK: Stacking - -/// Stack an array of views in a stack view. -public func stack(_ views: [SomeView], axis: NSLayoutConstraint.Axis, spacing: CGFloat = 0, distribution: UIStackView.Distribution = .fill, alignment: UIStackView.Alignment = .fill, configure: @escaping (UIStackView) -> Void = { _ in }) -> Layout { - return Layout { revertable in - let stackView = UIStackView() - stackView.axis = axis - stackView.spacing = spacing - stackView.distribution = distribution - stackView.alignment = alignment - views.forEach { - revertable.append($0.layout(in: stackView)) - } - configure(stackView) - return stackView - } -} - -/// Stack an array of views in a stack view. -public func stack(_ axis: NSLayoutConstraint.Axis, spacing: CGFloat = 0, distribution: UIStackView.Distribution = .fill, alignment: UIStackView.Alignment = .fill, configure: @escaping (UIStackView) -> Void = { _ in }) -> ((SomeView...) -> Layout) { - return { (views: SomeView...) -> Layout in - return stack(views, axis: axis, spacing: spacing, distribution: distribution, alignment: alignment, configure: configure) - } -} - // MARK: Grouping public class ViewGroup: ViewNode { @@ -295,17 +293,12 @@ public class ViewGroup: ViewNode { } /// Group an array of layouts that should be laid out in the same container. -public func group(_ layouts: [SomeView]) -> Layout { +func group(_ layouts: [SomeView]) -> Layout { return Layout { revertable in return ViewGroup(layouts) } } -/// Group an array of layouts that should be laid out in the same container. -public func group(_ layouts: SomeView...) -> Layout { - return group(layouts) -} - // MARK: Configuring intrinsic size behaviour extension View where Node: UIView { diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-Button.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-Button.swift index b4cac56..75964b1 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-Button.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-Button.swift @@ -21,14 +21,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-CollectionViewCell.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-CollectionViewCell.swift index 8b5985b..a2eccf5 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-CollectionViewCell.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-CollectionViewCell.swift @@ -19,14 +19,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-Control.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-Control.swift index 104ad06..5797997 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-Control.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-Control.swift @@ -19,14 +19,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-ImageView.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-ImageView.swift index 8e1cc64..963eb36 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-ImageView.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-ImageView.swift @@ -19,14 +19,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-Label.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-Label.swift index 7d15eb7..64093e2 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-Label.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-Label.swift @@ -98,14 +98,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-TableViewCell.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-TableViewCell.swift index 3101207..e53fd8d 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-TableViewCell.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-TableViewCell.swift @@ -19,14 +19,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-TextField.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-TextField.swift index af327a5..000ada4 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-TextField.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-TextField.swift @@ -21,14 +21,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(frame: .zero) self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-View.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-View.swift index fb23c14..1f39c98 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-View.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-View.swift @@ -18,18 +18,9 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(frame: .zero) - self.layouts = layouts - - setup() - defineLayout() - } - - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { - self.init(frame: .zero) + public init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.layouts = layoutBuilder() - + super.init(frame: .zero) setup() defineLayout() } diff --git a/SwiftUIKit/DeclarativeExtension/UI/UI-ViewController.swift b/SwiftUIKit/DeclarativeExtension/UI/UI-ViewController.swift index 112e623..b9f58ab 100644 --- a/SwiftUIKit/DeclarativeExtension/UI/UI-ViewController.swift +++ b/SwiftUIKit/DeclarativeExtension/UI/UI-ViewController.swift @@ -15,14 +15,6 @@ extension UI { private var layouts: [SomeView] = [] - public convenience init(_ layouts: [SomeView]) { - self.init(nibName: nil, bundle: nil) - self.layouts = layouts - - setup() - defineLayout() - } - public convenience init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { self.init(nibName: nil, bundle: nil) self.layouts = layoutBuilder() @@ -54,11 +46,11 @@ extension UI { } open func setup() { - if #available(iOS 13.0, *) { - self.view.backgroundColor = UIColor.systemBackground - } else { - self.view.backgroundColor = .white - } +// if #available(iOS 13.0, *) { +// self.view.backgroundColor = UIColor.systemBackground +// } else { +// self.view.backgroundColor = .white +// } } open func defineLayout() { diff --git a/SwiftUIKit/DeclarativeExtension/Views/ForEach.swift b/SwiftUIKit/DeclarativeExtension/Views/ForEach.swift index ba62240..78c732e 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/ForEach.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/ForEach.swift @@ -7,16 +7,16 @@ import Foundation -public struct ForEach { +public struct ForEach where Data: RandomAccessCollection { public var layouts: [SomeView] - public var items: [Item] + public var items: Data - public init(_ items: [Item], layouts: [SomeView]) { + public init(_ items: Data, layouts: [SomeView]) { self.items = items self.layouts = layouts } - public init(_ items: [Item], @LayoutBuilder layoutBuilder: (Int, Item) -> [SomeView]) { + public init(_ items: Data, @LayoutBuilder layoutBuilder: (Int, Data.Element) -> [SomeView]) { self.items = items self.layouts = items.enumerated().reduce([SomeView](), { (seed, next) -> [SomeView] in seed + layoutBuilder(next.offset, next.element) diff --git a/SwiftUIKit/DeclarativeExtension/Views/HStackView.swift b/SwiftUIKit/DeclarativeExtension/Views/HStackView.swift index 65b4755..55406bf 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/HStackView.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/HStackView.swift @@ -10,33 +10,15 @@ import UIKit public class HStackView: UIStackView { public var configure: (UIStackView) -> Void = {_ in} - public var layouts: [SomeView] + private var layouts: [SomeView] public var layoutBag = LayoutBag() - required public init( + public init( spacing: CGFloat = 0, distribution: UIStackView.Distribution = .fillEqually, alignment: UIStackView.Alignment = .fill, - layouts: [SomeView] - ) { - self.layouts = layouts - - super.init(frame: .zero) - - self.axis = .horizontal - self.spacing = spacing - self.distribution = distribution - self.alignment = alignment - - defineLayout() - } - - required public init( - spacing: CGFloat = 0, - distribution: UIStackView.Distribution = .fillEqually, - alignment: UIStackView.Alignment = .fill, - @LayoutBuilder layoutBuilder: () -> [SomeView] + @LayoutBuilder _ layoutBuilder: () -> [SomeView] ) { self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift b/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift index 10a7f6d..1a0bf97 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift @@ -7,7 +7,7 @@ import Foundation -@_functionBuilder +@resultBuilder public struct LayoutBuilder { public typealias Expression = SomeView diff --git a/SwiftUIKit/DeclarativeExtension/Views/StackView.swift b/SwiftUIKit/DeclarativeExtension/Views/StackView.swift index 24f025c..d7ff883 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/StackView.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/StackView.swift @@ -10,33 +10,15 @@ import UIKit public class VStackView: UIStackView { public var configure: (UIStackView) -> Void = {_ in} - public var layouts: [SomeView] + private var layouts: [SomeView] public var layoutBag = LayoutBag() - required public init( + public init( spacing: CGFloat = 0, distribution: UIStackView.Distribution = .fillEqually, alignment: UIStackView.Alignment = .fill, - layouts: [SomeView] - ) { - self.layouts = layouts - - super.init(frame: .zero) - - self.axis = .vertical - self.spacing = spacing - self.distribution = distribution - self.alignment = alignment - - defineLayout() - } - - required public init( - spacing: CGFloat = 0, - distribution: UIStackView.Distribution = .fillEqually, - alignment: UIStackView.Alignment = .fill, - @LayoutBuilder layoutBuilder: () -> [SomeView] + @LayoutBuilder _ layoutBuilder: () -> [SomeView] ) { self.layouts = layoutBuilder() diff --git a/SwiftUIKit/DeclarativeExtension/Views/StackViewProtocol.swift b/SwiftUIKit/DeclarativeExtension/Views/StackViewProtocol.swift deleted file mode 100644 index 60ab178..0000000 --- a/SwiftUIKit/DeclarativeExtension/Views/StackViewProtocol.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// StackViewProtocol.swift -// SwiftUIKit -// -// Created by finos.son.le on 22/04/2021. -// - -import UIKit - -public protocol StackViewProtocol: View { - var axis: NSLayoutConstraint.Axis { get set } - var distribution: UIStackView.Distribution { get set } - var spacing: CGFloat { get set } - var alignment: UIStackView.Alignment { get set } - var configure: (UIStackView) -> Void { get set } - var layouts: [SomeView] { get set } -} - -public extension StackViewProtocol { - func makeViewNode(_ compositeRevertable: LayoutRevertable) -> UIStackView { - stack(layouts, axis: axis, spacing: spacing, distribution: distribution, alignment: alignment, configure: configure) - .makeViewNode(compositeRevertable) - } -} diff --git a/SwiftUIKit/DeclarativeExtension/Views/ZStackView.swift b/SwiftUIKit/DeclarativeExtension/Views/ZStackView.swift index a95dafc..cefa231 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/ZStackView.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/ZStackView.swift @@ -8,50 +8,11 @@ import UIKit public class ZStackView: UI.View { - public var layouts: [SomeView] - - required public init(_ layouts: [SomeView]) { - self.layouts = layouts - - super.init(frame: .zero) - } - - required public init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { - self.layouts = layoutBuilder() - - super.init(frame: .zero) - } - - required init?(coder: NSCoder) { - fatalError("Not support init from coder") + public override init(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) { + super.init(layoutBuilder) } - public override var subviewsLayout: SomeView { - group(layouts) + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") } } - -//public struct ZStackView { -// public var layouts: [SomeView] -// public var container: UIView -// -// public init(_ container: UIView = UIView(), configure: @escaping (UIView) -> Void = {_ in}, layouts: [SomeView]) { -// self.container = container -// configure(container) -// self.layouts = layouts -// } -// -// public init(_ container: UIView = UIView(), configure: @escaping (UIView) -> Void = {_ in}, @LayoutBuilder layoutBuilder: () -> [SomeView]) { -// self.container = container -// configure(container) -// self.layouts = layoutBuilder() -// } -//} -// -//extension ZStackView: View { -// public func makeViewNode(_ compositeRevertable: LayoutRevertable) -> UIView { -// group(layouts) -// .embedding(in: container) -// .makeViewNode(compositeRevertable) -// } -//} From 72452fc567f8efe8aca56ef951abbc3e0e4b3f92 Mon Sep 17 00:00:00 2001 From: dungntm58 Date: Sat, 12 Mar 2022 21:33:06 +0700 Subject: [PATCH 2/2] Update Layout Builder to support control flow if-else. Update Example --- .../SwiftUIKit-Example/Views/BasicVC.swift | 40 +- SwiftUIKit.xcodeproj/project.pbxproj | 648 ------------------ .../contents.xcworkspacedata | 10 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - SwiftUIKit/Core/LayoutFunction.swift | 10 + .../Views/LayoutBuilder.swift | 15 +- 6 files changed, 50 insertions(+), 681 deletions(-) delete mode 100644 SwiftUIKit.xcodeproj/project.pbxproj delete mode 100644 SwiftUIKit.xcworkspace/contents.xcworkspacedata delete mode 100644 SwiftUIKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SwiftUIKit-Example/SwiftUIKit-Example/Views/BasicVC.swift b/SwiftUIKit-Example/SwiftUIKit-Example/Views/BasicVC.swift index ebbdff7..3773025 100644 --- a/SwiftUIKit-Example/SwiftUIKit-Example/Views/BasicVC.swift +++ b/SwiftUIKit-Example/SwiftUIKit-Example/Views/BasicVC.swift @@ -17,17 +17,39 @@ class BasicVC: UI.ViewController { } override var subviewsLayout: SomeView { - UI.Label { + ZStackView { + if false { + UI.Label { + UIView() + .dx.backgroundColor(.red) + .sizing(width: 100, height: 100) + .fillingParent(insets: 30) + } + .dx.backgroundColor(.green) + .dx.gestureOnTap { _ in + print("ok") + } + .stickingToParentEdges(left: 0, top: 0) + } else { + UI.Label { + UIView() + .dx.backgroundColor(.blue) + .sizing(width: 100, height: 100) + .fillingParent(insets: 30) + } + .dx.backgroundColor(.yellow) + .dx.gestureOnTap { _ in + print("ok") + } + .stickingToParentEdges(left: 0, top: 0) + } + UIView() - .dx.backgroundColor(.red) - .sizing(width: 100, height: 100) - .fillingParent(insets: 30) + .dx.backgroundColor(.black) + .sizing(width: 50, height: 50) + .centeringInParent() } - .dx.backgroundColor(.green) - .dx.gestureOnTap { _ in - print("ok") - } - .centeringInParent() + .fillingParent() } deinit { diff --git a/SwiftUIKit.xcodeproj/project.pbxproj b/SwiftUIKit.xcodeproj/project.pbxproj deleted file mode 100644 index bdf6207..0000000 --- a/SwiftUIKit.xcodeproj/project.pbxproj +++ /dev/null @@ -1,648 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 1C28A7A1262D980E0036951E /* Anchorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A7A0262D980E0036951E /* Anchorable.swift */; }; - 1C28A7EE262E80D20036951E /* Anchorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A7A0262D980E0036951E /* Anchorable.swift */; }; - 1C28A803262E81750036951E /* Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A802262E81750036951E /* Style.swift */; }; - 1C28A828262E85D90036951E /* Length.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A827262E85D90036951E /* Length.swift */; }; - 1C28A829262E85D90036951E /* Length.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A827262E85D90036951E /* Length.swift */; }; - 1C28A82F262E898E0036951E /* ViewNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A82E262E898E0036951E /* ViewNode.swift */; }; - 1C28A830262E898E0036951E /* ViewNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A82E262E898E0036951E /* ViewNode.swift */; }; - 1C28A835262E89D80036951E /* LayoutBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A834262E89D80036951E /* LayoutBag.swift */; }; - 1C28A836262E89D90036951E /* LayoutBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A834262E89D80036951E /* LayoutBag.swift */; }; - 1C28A83C262E93840036951E /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A83B262E93840036951E /* View.swift */; }; - 1C28A83D262E93840036951E /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A83B262E93840036951E /* View.swift */; }; - 1C28A84E262EB5E40036951E /* LayoutFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A84D262EB5E40036951E /* LayoutFunction.swift */; }; - 1C28A84F262EB5E40036951E /* LayoutFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A84D262EB5E40036951E /* LayoutFunction.swift */; }; - 1C28A853262EBE070036951E /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A852262EBE070036951E /* Layout.swift */; }; - 1C28A854262EBE070036951E /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A852262EBE070036951E /* Layout.swift */; }; - 1C28A85C262EE63E0036951E /* SwiftUIKit+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A85B262EE63E0036951E /* SwiftUIKit+UIKit.swift */; }; - 1C28A85D262EE63E0036951E /* SwiftUIKit+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A85B262EE63E0036951E /* SwiftUIKit+UIKit.swift */; }; - 1C28A86126311A460036951E /* TraitQueryLayoutSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86026311A460036951E /* TraitQueryLayoutSet.swift */; }; - 1C28A86226311A460036951E /* TraitQueryLayoutSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86026311A460036951E /* TraitQueryLayoutSet.swift */; }; - 1C28A86626311B140036951E /* WindowTraitCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86526311B140036951E /* WindowTraitCollection.swift */; }; - 1C28A86726311B140036951E /* WindowTraitCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86526311B140036951E /* WindowTraitCollection.swift */; }; - 1C28A86C26311DF30036951E /* UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86B26311DF30036951E /* UI.swift */; }; - 1C28A86D26311DF30036951E /* UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A86B26311DF30036951E /* UI.swift */; }; - 1C28A87126311E0E0036951E /* UI-View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A87026311E0E0036951E /* UI-View.swift */; }; - 1C28A87A26311F030036951E /* UI-Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A87926311F030036951E /* UI-Window.swift */; }; - 1C28A87B26311F040036951E /* UI-Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A87926311F030036951E /* UI-Window.swift */; }; - 1C28A87F26311F4C0036951E /* UI-ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A87E26311F4C0036951E /* UI-ViewController.swift */; }; - 1C28A88626311FDD0036951E /* UI-TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A88526311FDD0036951E /* UI-TextField.swift */; }; - 1C28A88B2631201D0036951E /* UI-TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A88A2631201D0036951E /* UI-TableViewCell.swift */; }; - 1C28A8902631206B0036951E /* UI-Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A88F2631206B0036951E /* UI-Label.swift */; }; - 1C28A895263120A80036951E /* UI-ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A894263120A80036951E /* UI-ImageView.swift */; }; - 1C28A89A263121050036951E /* UI-Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A899263121050036951E /* UI-Control.swift */; }; - 1C28A89F263121440036951E /* UI-CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A89E263121440036951E /* UI-CollectionViewCell.swift */; }; - 1C28A8A42631218A0036951E /* UI-Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8A32631218A0036951E /* UI-Button.swift */; }; - 1C28A8AA2631223E0036951E /* LayoutBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8A92631223E0036951E /* LayoutBuilder.swift */; }; - 1C28A8AF263122710036951E /* StackViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8AE263122710036951E /* StackViewProtocol.swift */; }; - 1C28A8B4263122EA0036951E /* StackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8B3263122EA0036951E /* StackView.swift */; }; - 1C28A8B9263123400036951E /* HStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8B8263123400036951E /* HStackView.swift */; }; - 1C28A8BE2631238B0036951E /* ZStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8BD2631238B0036951E /* ZStackView.swift */; }; - 1C28A8C3263123F00036951E /* ForEach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8C2263123F00036951E /* ForEach.swift */; }; - 1C28A8D7263128FD0036951E /* DeclarativeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8D6263128FD0036951E /* DeclarativeExtension.swift */; }; - 1C28A8E1263151700036951E /* UIView+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8E0263151700036951E /* UIView+Style.swift */; }; - 1C28A8EE263169AA0036951E /* UIView+Dx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C28A8ED263169AA0036951E /* UIView+Dx.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 1C28A78F262D8AAE0036951E /* SwiftUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 1C28A793262D8AAE0036951E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 1C28A7A0262D980E0036951E /* Anchorable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Anchorable.swift; sourceTree = ""; }; - 1C28A7F4262E80D20036951E /* SwiftUIKitCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftUIKitCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 1C28A802262E81750036951E /* Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Style.swift; sourceTree = ""; }; - 1C28A827262E85D90036951E /* Length.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Length.swift; sourceTree = ""; }; - 1C28A82E262E898E0036951E /* ViewNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewNode.swift; sourceTree = ""; }; - 1C28A834262E89D80036951E /* LayoutBag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutBag.swift; sourceTree = ""; }; - 1C28A83B262E93840036951E /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; - 1C28A84D262EB5E40036951E /* LayoutFunction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutFunction.swift; sourceTree = ""; }; - 1C28A852262EBE070036951E /* Layout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = ""; }; - 1C28A85B262EE63E0036951E /* SwiftUIKit+UIKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwiftUIKit+UIKit.swift"; sourceTree = ""; }; - 1C28A86026311A460036951E /* TraitQueryLayoutSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TraitQueryLayoutSet.swift; sourceTree = ""; }; - 1C28A86526311B140036951E /* WindowTraitCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowTraitCollection.swift; sourceTree = ""; }; - 1C28A86B26311DF30036951E /* UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UI.swift; sourceTree = ""; }; - 1C28A87026311E0E0036951E /* UI-View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-View.swift"; sourceTree = ""; }; - 1C28A87926311F030036951E /* UI-Window.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-Window.swift"; sourceTree = ""; }; - 1C28A87E26311F4C0036951E /* UI-ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-ViewController.swift"; sourceTree = ""; }; - 1C28A88526311FDD0036951E /* UI-TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-TextField.swift"; sourceTree = ""; }; - 1C28A88A2631201D0036951E /* UI-TableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-TableViewCell.swift"; sourceTree = ""; }; - 1C28A88F2631206B0036951E /* UI-Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-Label.swift"; sourceTree = ""; }; - 1C28A894263120A80036951E /* UI-ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-ImageView.swift"; sourceTree = ""; }; - 1C28A899263121050036951E /* UI-Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-Control.swift"; sourceTree = ""; }; - 1C28A89E263121440036951E /* UI-CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-CollectionViewCell.swift"; sourceTree = ""; }; - 1C28A8A32631218A0036951E /* UI-Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UI-Button.swift"; sourceTree = ""; }; - 1C28A8A92631223E0036951E /* LayoutBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutBuilder.swift; sourceTree = ""; }; - 1C28A8AE263122710036951E /* StackViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackViewProtocol.swift; sourceTree = ""; }; - 1C28A8B3263122EA0036951E /* StackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackView.swift; sourceTree = ""; }; - 1C28A8B8263123400036951E /* HStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HStackView.swift; sourceTree = ""; }; - 1C28A8BD2631238B0036951E /* ZStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZStackView.swift; sourceTree = ""; }; - 1C28A8C2263123F00036951E /* ForEach.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForEach.swift; sourceTree = ""; }; - 1C28A8D6263128FD0036951E /* DeclarativeExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclarativeExtension.swift; sourceTree = ""; }; - 1C28A8E0263151700036951E /* UIView+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Style.swift"; sourceTree = ""; }; - 1C28A8ED263169AA0036951E /* UIView+Dx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Dx.swift"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 1C28A78C262D8AAE0036951E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1C28A7EF262E80D20036951E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 1C28A785262D8AAE0036951E = { - isa = PBXGroup; - children = ( - 1C28A791262D8AAE0036951E /* SwiftUIKit */, - 1C28A790262D8AAE0036951E /* Products */, - ); - sourceTree = ""; - }; - 1C28A790262D8AAE0036951E /* Products */ = { - isa = PBXGroup; - children = ( - 1C28A78F262D8AAE0036951E /* SwiftUIKit.framework */, - 1C28A7F4262E80D20036951E /* SwiftUIKitCore.framework */, - ); - name = Products; - sourceTree = ""; - }; - 1C28A791262D8AAE0036951E /* SwiftUIKit */ = { - isa = PBXGroup; - children = ( - 1C28A79E262D8BAB0036951E /* DeclarativeExtension */, - 1C28A79D262D8B940036951E /* Core */, - 1C28A793262D8AAE0036951E /* Info.plist */, - ); - path = SwiftUIKit; - sourceTree = ""; - }; - 1C28A79D262D8B940036951E /* Core */ = { - isa = PBXGroup; - children = ( - 1C28A86A26311D8D0036951E /* UIKitConvenient */, - 1C28A7A0262D980E0036951E /* Anchorable.swift */, - 1C28A827262E85D90036951E /* Length.swift */, - 1C28A82E262E898E0036951E /* ViewNode.swift */, - 1C28A834262E89D80036951E /* LayoutBag.swift */, - 1C28A83B262E93840036951E /* View.swift */, - 1C28A84D262EB5E40036951E /* LayoutFunction.swift */, - 1C28A852262EBE070036951E /* Layout.swift */, - 1C28A85B262EE63E0036951E /* SwiftUIKit+UIKit.swift */, - 1C28A86026311A460036951E /* TraitQueryLayoutSet.swift */, - 1C28A86526311B140036951E /* WindowTraitCollection.swift */, - ); - path = Core; - sourceTree = ""; - }; - 1C28A79E262D8BAB0036951E /* DeclarativeExtension */ = { - isa = PBXGroup; - children = ( - 1C28A9142632DDB00036951E /* UI */, - 1C28A8C72631242C0036951E /* Styles */, - 1C28A8A8263122250036951E /* Views */, - 1C28A8D6263128FD0036951E /* DeclarativeExtension.swift */, - 1C28A8ED263169AA0036951E /* UIView+Dx.swift */, - ); - path = DeclarativeExtension; - sourceTree = ""; - }; - 1C28A86A26311D8D0036951E /* UIKitConvenient */ = { - isa = PBXGroup; - children = ( - 1C28A86B26311DF30036951E /* UI.swift */, - 1C28A87926311F030036951E /* UI-Window.swift */, - ); - path = UIKitConvenient; - sourceTree = ""; - }; - 1C28A8A8263122250036951E /* Views */ = { - isa = PBXGroup; - children = ( - 1C28A8A92631223E0036951E /* LayoutBuilder.swift */, - 1C28A8AE263122710036951E /* StackViewProtocol.swift */, - 1C28A8B3263122EA0036951E /* StackView.swift */, - 1C28A8B8263123400036951E /* HStackView.swift */, - 1C28A8BD2631238B0036951E /* ZStackView.swift */, - 1C28A8C2263123F00036951E /* ForEach.swift */, - ); - path = Views; - sourceTree = ""; - }; - 1C28A8C72631242C0036951E /* Styles */ = { - isa = PBXGroup; - children = ( - 1C28A802262E81750036951E /* Style.swift */, - 1C28A8E0263151700036951E /* UIView+Style.swift */, - ); - path = Styles; - sourceTree = ""; - }; - 1C28A9142632DDB00036951E /* UI */ = { - isa = PBXGroup; - children = ( - 1C28A88526311FDD0036951E /* UI-TextField.swift */, - 1C28A88A2631201D0036951E /* UI-TableViewCell.swift */, - 1C28A88F2631206B0036951E /* UI-Label.swift */, - 1C28A894263120A80036951E /* UI-ImageView.swift */, - 1C28A899263121050036951E /* UI-Control.swift */, - 1C28A89E263121440036951E /* UI-CollectionViewCell.swift */, - 1C28A8A32631218A0036951E /* UI-Button.swift */, - 1C28A87026311E0E0036951E /* UI-View.swift */, - 1C28A87E26311F4C0036951E /* UI-ViewController.swift */, - ); - path = UI; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 1C28A78A262D8AAE0036951E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1C28A7EB262E80D20036951E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 1C28A78E262D8AAE0036951E /* SwiftUIKit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1C28A797262D8AAE0036951E /* Build configuration list for PBXNativeTarget "SwiftUIKit" */; - buildPhases = ( - 1C28A78A262D8AAE0036951E /* Headers */, - 1C28A78B262D8AAE0036951E /* Sources */, - 1C28A78C262D8AAE0036951E /* Frameworks */, - 1C28A78D262D8AAE0036951E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SwiftUIKit; - productName = SwiftUIKit; - productReference = 1C28A78F262D8AAE0036951E /* SwiftUIKit.framework */; - productType = "com.apple.product-type.framework"; - }; - 1C28A7EA262E80D20036951E /* SwiftUIKitCore */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1C28A7F1262E80D20036951E /* Build configuration list for PBXNativeTarget "SwiftUIKitCore" */; - buildPhases = ( - 1C28A7EB262E80D20036951E /* Headers */, - 1C28A7EC262E80D20036951E /* Sources */, - 1C28A7EF262E80D20036951E /* Frameworks */, - 1C28A7F0262E80D20036951E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SwiftUIKitCore; - productName = SwiftUIKit; - productReference = 1C28A7F4262E80D20036951E /* SwiftUIKitCore.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 1C28A786262D8AAE0036951E /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1240; - TargetAttributes = { - 1C28A78E262D8AAE0036951E = { - CreatedOnToolsVersion = 12.4; - LastSwiftMigration = 1240; - }; - }; - }; - buildConfigurationList = 1C28A789262D8AAE0036951E /* Build configuration list for PBXProject "SwiftUIKit" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 1C28A785262D8AAE0036951E; - productRefGroup = 1C28A790262D8AAE0036951E /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 1C28A78E262D8AAE0036951E /* SwiftUIKit */, - 1C28A7EA262E80D20036951E /* SwiftUIKitCore */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 1C28A78D262D8AAE0036951E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1C28A7F0262E80D20036951E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 1C28A78B262D8AAE0036951E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1C28A86126311A460036951E /* TraitQueryLayoutSet.swift in Sources */, - 1C28A89F263121440036951E /* UI-CollectionViewCell.swift in Sources */, - 1C28A88B2631201D0036951E /* UI-TableViewCell.swift in Sources */, - 1C28A8A42631218A0036951E /* UI-Button.swift in Sources */, - 1C28A88626311FDD0036951E /* UI-TextField.swift in Sources */, - 1C28A8AF263122710036951E /* StackViewProtocol.swift in Sources */, - 1C28A828262E85D90036951E /* Length.swift in Sources */, - 1C28A835262E89D80036951E /* LayoutBag.swift in Sources */, - 1C28A8B4263122EA0036951E /* StackView.swift in Sources */, - 1C28A87126311E0E0036951E /* UI-View.swift in Sources */, - 1C28A85C262EE63E0036951E /* SwiftUIKit+UIKit.swift in Sources */, - 1C28A83C262E93840036951E /* View.swift in Sources */, - 1C28A8C3263123F00036951E /* ForEach.swift in Sources */, - 1C28A8B9263123400036951E /* HStackView.swift in Sources */, - 1C28A895263120A80036951E /* UI-ImageView.swift in Sources */, - 1C28A8902631206B0036951E /* UI-Label.swift in Sources */, - 1C28A86C26311DF30036951E /* UI.swift in Sources */, - 1C28A89A263121050036951E /* UI-Control.swift in Sources */, - 1C28A803262E81750036951E /* Style.swift in Sources */, - 1C28A82F262E898E0036951E /* ViewNode.swift in Sources */, - 1C28A8D7263128FD0036951E /* DeclarativeExtension.swift in Sources */, - 1C28A87F26311F4C0036951E /* UI-ViewController.swift in Sources */, - 1C28A87A26311F030036951E /* UI-Window.swift in Sources */, - 1C28A853262EBE070036951E /* Layout.swift in Sources */, - 1C28A8E1263151700036951E /* UIView+Style.swift in Sources */, - 1C28A84E262EB5E40036951E /* LayoutFunction.swift in Sources */, - 1C28A8BE2631238B0036951E /* ZStackView.swift in Sources */, - 1C28A86626311B140036951E /* WindowTraitCollection.swift in Sources */, - 1C28A7A1262D980E0036951E /* Anchorable.swift in Sources */, - 1C28A8AA2631223E0036951E /* LayoutBuilder.swift in Sources */, - 1C28A8EE263169AA0036951E /* UIView+Dx.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 1C28A7EC262E80D20036951E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1C28A86726311B140036951E /* WindowTraitCollection.swift in Sources */, - 1C28A829262E85D90036951E /* Length.swift in Sources */, - 1C28A830262E898E0036951E /* ViewNode.swift in Sources */, - 1C28A83D262E93840036951E /* View.swift in Sources */, - 1C28A84F262EB5E40036951E /* LayoutFunction.swift in Sources */, - 1C28A86226311A460036951E /* TraitQueryLayoutSet.swift in Sources */, - 1C28A854262EBE070036951E /* Layout.swift in Sources */, - 1C28A85D262EE63E0036951E /* SwiftUIKit+UIKit.swift in Sources */, - 1C28A87B26311F040036951E /* UI-Window.swift in Sources */, - 1C28A86D26311DF30036951E /* UI.swift in Sources */, - 1C28A836262E89D90036951E /* LayoutBag.swift in Sources */, - 1C28A7EE262E80D20036951E /* Anchorable.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 1C28A795262D8AAE0036951E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 1C28A796262D8AAE0036951E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 1C28A798262D8AAE0036951E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 556LZQ7WUH; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = SwiftUIKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.misshypocrite.swiftuikit; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 1C28A799262D8AAE0036951E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 556LZQ7WUH; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = SwiftUIKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.misshypocrite.swiftuikit; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 1C28A7F2262E80D20036951E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 556LZQ7WUH; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INCLUDED_SOURCE_FILE_NAMES = "./Core/*.swift"; - INFOPLIST_FILE = SwiftUIKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.misshypocrite.swiftuikit.core; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 1C28A7F3262E80D20036951E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 556LZQ7WUH; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INCLUDED_SOURCE_FILE_NAMES = "./Core/*.swift"; - INFOPLIST_FILE = SwiftUIKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.misshypocrite.swiftuikit.core; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1C28A789262D8AAE0036951E /* Build configuration list for PBXProject "SwiftUIKit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1C28A795262D8AAE0036951E /* Debug */, - 1C28A796262D8AAE0036951E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1C28A797262D8AAE0036951E /* Build configuration list for PBXNativeTarget "SwiftUIKit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1C28A798262D8AAE0036951E /* Debug */, - 1C28A799262D8AAE0036951E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1C28A7F1262E80D20036951E /* Build configuration list for PBXNativeTarget "SwiftUIKitCore" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1C28A7F2262E80D20036951E /* Debug */, - 1C28A7F3262E80D20036951E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 1C28A786262D8AAE0036951E /* Project object */; -} diff --git a/SwiftUIKit.xcworkspace/contents.xcworkspacedata b/SwiftUIKit.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index bcaa8e8..0000000 --- a/SwiftUIKit.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/SwiftUIKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftUIKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/SwiftUIKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/SwiftUIKit/Core/LayoutFunction.swift b/SwiftUIKit/Core/LayoutFunction.swift index 42714aa..61bd6c4 100644 --- a/SwiftUIKit/Core/LayoutFunction.swift +++ b/SwiftUIKit/Core/LayoutFunction.swift @@ -273,6 +273,16 @@ extension View where Node: UIView { return node } } + + /// Layout the given layout within the node and return the layout that has the node as a root node. + public func addingLayout(@LayoutBuilder _ layoutBuilder: () -> [SomeView]) -> Layout { + let layoutGroup = group(layoutBuilder()) + return Layout { revertable in + let node = self.makeViewNode(revertable) + revertable.append(layoutGroup.makeSomeViewNode(revertable).layout(in: node)) + return node + } + } } // MARK: Grouping diff --git a/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift b/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift index 1a0bf97..2ea1de0 100644 --- a/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift +++ b/SwiftUIKit/DeclarativeExtension/Views/LayoutBuilder.swift @@ -10,14 +10,13 @@ import Foundation @resultBuilder public struct LayoutBuilder { - public typealias Expression = SomeView public typealias Component = [SomeView] public static func buildBlock(_ layouts: Component...) -> Component { layouts.flatMap { $0 } } - public static func buildExpression(_ layout: Expression) -> Component { + public static func buildExpression(_ layout: SomeView) -> Component { [layout] } @@ -29,11 +28,15 @@ public struct LayoutBuilder { layouts ?? [] } - public static func buildEither(first layout: Component) -> Component { - layout + public static func buildOptional(_ layout: Component?) -> Component { + layout ?? [] } - public static func buildEither(second layout: Component) -> Component { - layout + public static func buildEither(first: Component) -> Component { + first + } + + public static func buildEither(second: Component) -> Component { + second } }