Skip to content

Commit

Permalink
Add missing Objective-C API wrapContent methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucdion committed Feb 28, 2019
1 parent c8b70f9 commit 6fff1c5
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 94 deletions.
2 changes: 0 additions & 2 deletions Example/PinLayoutSample.xcodeproj/project.pbxproj
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions PinLayout.xcodeproj/project.pbxproj
Expand Up @@ -198,7 +198,6 @@
242723711F008B85006A5C3A /* MinMaxWidthHeightSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinMaxWidthHeightSpec.swift; sourceTree = "<group>"; };
242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelativePositionMultipleViewsSpec.swift; sourceTree = "<group>"; };
243B12C41FC3CFC10072A9C3 /* LayoutMethodSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutMethodSpec.swift; sourceTree = "<group>"; };
243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ObjectiveCSpec.m; sourceTree = "<group>"; };
243C620E1FC3834B0082C327 /* Percent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Percent.swift; path = Impl/Percent.swift; sourceTree = "<group>"; };
244C6E141E776A0C0074FC74 /* MarginsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginsSpec.swift; sourceTree = "<group>"; };
244DF2F81EF46C500090508B /* PinLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PinLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -412,7 +411,6 @@
DF1A5D252084C9E200725EF5 /* iOS */ = {
isa = PBXGroup;
children = (
243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */,
DF1E39B420482B1F0002D0AA /* PinSafeAreaTests.swift */,
DFBCAEFF213023700025F7BF /* ReadableLayoutMarginsSpec.swift */,
245C1DA11FEC4FC6007594F7 /* TransformSpec.swift */,
Expand Down
16 changes: 8 additions & 8 deletions 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
Expand All @@ -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

Expand Down
11 changes: 11 additions & 0 deletions Sources/ObjectiveC/PinLayoutObjC.swift
Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions Sources/ObjectiveC/PinLayoutObjCImpl.swift
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Types.swift
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions Tests/Common/ObjectiveCSpec.m
Expand Up @@ -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];
});
});
});

Expand Down
81 changes: 0 additions & 81 deletions Tests/iOS/ObjectiveCSpec.m

This file was deleted.

0 comments on commit 6fff1c5

Please sign in to comment.