diff --git a/Example/PinLayoutSample.xcodeproj/project.pbxproj b/Example/PinLayoutSample.xcodeproj/project.pbxproj index 3c7f4108..40e4d9ab 100644 --- a/Example/PinLayoutSample.xcodeproj/project.pbxproj +++ b/Example/PinLayoutSample.xcodeproj/project.pbxproj @@ -619,12 +619,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/PinLayout/PinLayout.framework", - "${PODS_ROOT}/Reveal-SDK/RevealServer-20/iOS/RevealServer.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PinLayout.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RevealServer.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/PinLayout.xcodeproj/project.pbxproj b/PinLayout.xcodeproj/project.pbxproj index 98f96dc2..ebdcac4e 100644 --- a/PinLayout.xcodeproj/project.pbxproj +++ b/PinLayout.xcodeproj/project.pbxproj @@ -198,7 +198,6 @@ 242723711F008B85006A5C3A /* MinMaxWidthHeightSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinMaxWidthHeightSpec.swift; sourceTree = ""; }; 242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelativePositionMultipleViewsSpec.swift; sourceTree = ""; }; 243B12C41FC3CFC10072A9C3 /* LayoutMethodSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutMethodSpec.swift; sourceTree = ""; }; - 243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ObjectiveCSpec.m; sourceTree = ""; }; 243C620E1FC3834B0082C327 /* Percent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Percent.swift; path = Impl/Percent.swift; sourceTree = ""; }; 244C6E141E776A0C0074FC74 /* MarginsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginsSpec.swift; sourceTree = ""; }; 244DF2F81EF46C500090508B /* PinLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PinLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -412,7 +411,6 @@ DF1A5D252084C9E200725EF5 /* iOS */ = { isa = PBXGroup; children = ( - 243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */, DF1E39B420482B1F0002D0AA /* PinSafeAreaTests.swift */, DFBCAEFF213023700025F7BF /* ReadableLayoutMarginsSpec.swift */, 245C1DA11FEC4FC6007594F7 /* TransformSpec.swift */, diff --git a/Podfile.lock b/Podfile.lock index 6e4f5f5c..807080ab 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - Nimble (7.3.1) + - Nimble (7.3.4) - PinLayout (1.8.6) - - Quick (1.3.2) - - Reveal-SDK (20) - - SwiftLint (0.29.1) + - Quick (1.3.4) + - Reveal-SDK (21) + - SwiftLint (0.30.1) DEPENDENCIES: - Nimble @@ -24,11 +24,11 @@ EXTERNAL SOURCES: :path: "./" SPEC CHECKSUMS: - Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae + Nimble: 051e3d8912d40138fa5591c78594f95fb172af37 PinLayout: fe2a2432d6982588e208572005c941aeeae417ab - Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 - Reveal-SDK: 43206a57f575632fd304e85385cc259b5d359e32 - SwiftLint: 6772320e40b52049053a518c17db9b0634a0b45a + Quick: f4f7f063c524394c73ed93ac70983c609805d481 + Reveal-SDK: 3523e0eb7c562811c51bb71da6e523a6373702c8 + SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7 PODFILE CHECKSUM: 62618887f8155abc1ed3348d9b676cf6915137e2 diff --git a/Sources/ObjectiveC/PinLayoutObjC.swift b/Sources/ObjectiveC/PinLayoutObjC.swift index 19346110..e40bccb5 100644 --- a/Sources/ObjectiveC/PinLayoutObjC.swift +++ b/Sources/ObjectiveC/PinLayoutObjC.swift @@ -249,6 +249,17 @@ import AppKit #elseif os(macOS) @discardableResult func size(of view: NSView) -> PinLayoutObjC #endif + + + // + // MARK: wrapContent + @discardableResult func wrapContent() -> PinLayoutObjC; + @discardableResult func wrapContent(padding: CGFloat) -> PinLayoutObjC; + @discardableResult func wrapContent(insets: PEdgeInsets) -> PinLayoutObjC; + @discardableResult func wrapContent(type: WrapType) -> PinLayoutObjC; + @discardableResult func wrapContent(type: WrapType, padding: CGFloat) -> PinLayoutObjC; + @discardableResult func wrapContent(type: WrapType, insets: PEdgeInsets) -> PinLayoutObjC; + /** Set the view aspect ratio. diff --git a/Sources/ObjectiveC/PinLayoutObjCImpl.swift b/Sources/ObjectiveC/PinLayoutObjCImpl.swift index 4055cdaa..3c2fb67c 100644 --- a/Sources/ObjectiveC/PinLayoutObjCImpl.swift +++ b/Sources/ObjectiveC/PinLayoutObjCImpl.swift @@ -662,6 +662,36 @@ import AppKit return self } + func wrapContent() -> PinLayoutObjC { + _ = impl?.wrapContent() + return self + } + + func wrapContent(padding: CGFloat) -> PinLayoutObjC { + _ = impl?.wrapContent(padding: padding) + return self + } + + func wrapContent(insets: PEdgeInsets) -> PinLayoutObjC { + _ = impl?.wrapContent(padding: insets) + return self + } + + func wrapContent(type: WrapType) -> PinLayoutObjC { + _ = impl?.wrapContent(type) + return self + } + + func wrapContent(type: WrapType, padding: CGFloat) -> PinLayoutObjC { + _ = impl?.wrapContent(type, padding: padding) + return self + } + + func wrapContent(type: WrapType, insets: PEdgeInsets) -> PinLayoutObjC { + _ = impl?.wrapContent(type, padding: insets) + return self + } + func aspectRatio(_ ratio: CGFloat) -> PinLayoutObjC { _ = impl?.aspectRatio(ratio) return self diff --git a/Sources/Types.swift b/Sources/Types.swift index 8f788c15..6b6d5201 100644 --- a/Sources/Types.swift +++ b/Sources/Types.swift @@ -185,7 +185,7 @@ public enum FitType { case content } -public enum WrapType { +@objc public enum WrapType: Int { /// Adjust the view's width AND height to wrap all its subviews. case all /// Adjust only the view's width to wrap all its subviews. The view's height won't be modified. diff --git a/Tests/Common/ObjectiveCSpec.m b/Tests/Common/ObjectiveCSpec.m index 4c3a3af4..f5c13ab9 100644 --- a/Tests/Common/ObjectiveCSpec.m +++ b/Tests/Common/ObjectiveCSpec.m @@ -74,6 +74,15 @@ expect(@(aView.frame)).to(equal(@(CGRectMake(40, 10, 100, 60)))); expect(Pin.lastWarningText).to(beNil()); }); + + it(@"check the access to PinLayout methods from objective-c", ^{ + [[[rootView pinObjc] wrapContent] layout]; + [[[rootView pinObjc] wrapContentWithType:WrapTypeVertically] layout]; + [[[rootView pinObjc] wrapContentWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)] layout]; + [[[rootView pinObjc] wrapContentWithType:WrapTypeAll insets:UIEdgeInsetsMake(0, 0, 0, 0)] layout]; + [[[rootView pinObjc] wrapContentWithPadding:10] layout]; + [[[rootView pinObjc] wrapContentWithType:WrapTypeHorizontally padding:10] layout]; + }); }); }); diff --git a/Tests/iOS/ObjectiveCSpec.m b/Tests/iOS/ObjectiveCSpec.m deleted file mode 100644 index 44704b14..00000000 --- a/Tests/iOS/ObjectiveCSpec.m +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2018 Luc Dion -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -@import Quick; -@import Nimble; -@import XCTest; -@import UIKit; -@import PinLayout; - -QuickSpecBegin(ObjectiveCSpec) - -describe(@"test Objective-C interface", ^{ - __block UIViewController* viewController = nil; - __block UIView* rootView = nil; - __block UIView* aView = nil; - - beforeEach(^{ - Pin.logMissingLayoutCalls = false; - Pin.lastWarningText = nil; - - viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil]; - - rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]; - [viewController.view addSubview:rootView]; - - aView = [[UIView alloc] initWithFrame:CGRectMake(40, 100, 100, 60)]; - [rootView addSubview:aView]; - }); - - afterEach(^{ - Pin.logMissingLayoutCalls = false; - }); - - describe(@"generic objective-c tests", ^{ - it(@"Access Pin properties and methods", ^{ - [Pin initPinLayout]; - [Pin layoutDirection:LayoutDirectionLtr]; - Pin.safeAreaInsetsDidChangeMode = PinSafeAreaInsetsDidChangeModeAlways; - Pin.layoutDirection = LayoutDirectionLtr; - Pin.logWarnings = true; - }); - - it(@"basic pinlayout calls", ^{ - [[[aView pinObjc] top:10] layout]; - expect(@(aView.frame)).to(equal(@(CGRectMake(40, 10, 100, 60)))); - }); - - it(@"using Pin.logMissingLayoutCalls", ^{ - Pin.logMissingLayoutCalls = true; - [[aView pinObjc] top:10]; - //expect(Pin.lastWarningText).to(contain(@"PinLayout commands have been issued without calling the 'layout()' method to complete the layout")); - }); - - it(@"using Pin.logMissingLayoutCalls set to false", ^{ - Pin.logMissingLayoutCalls = false; - [[[aView pinObjc] top:10] layout]; - expect(@(aView.frame)).to(equal(@(CGRectMake(40, 10, 100, 60)))); - expect(Pin.lastWarningText).to(beNil()); - }); - }); -}); - -QuickSpecEnd