Skip to content

Commit 0e55c09

Browse files
authored
Merge pull request #185 from layoutBox/feature/add_missing_objc_wrapContent
Add missing Objective-C API `wrapContent` methods.
2 parents c8b70f9 + 6fff1c5 commit 0e55c09

File tree

8 files changed

+59
-94
lines changed

8 files changed

+59
-94
lines changed

Example/PinLayoutSample.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,10 @@
619619
inputPaths = (
620620
"${PODS_ROOT}/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample-frameworks.sh",
621621
"${BUILT_PRODUCTS_DIR}/PinLayout/PinLayout.framework",
622-
"${PODS_ROOT}/Reveal-SDK/RevealServer-20/iOS/RevealServer.framework",
623622
);
624623
name = "[CP] Embed Pods Frameworks";
625624
outputPaths = (
626625
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PinLayout.framework",
627-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RevealServer.framework",
628626
);
629627
runOnlyForDeploymentPostprocessing = 0;
630628
shellPath = /bin/sh;

PinLayout.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
242723711F008B85006A5C3A /* MinMaxWidthHeightSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinMaxWidthHeightSpec.swift; sourceTree = "<group>"; };
199199
242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelativePositionMultipleViewsSpec.swift; sourceTree = "<group>"; };
200200
243B12C41FC3CFC10072A9C3 /* LayoutMethodSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutMethodSpec.swift; sourceTree = "<group>"; };
201-
243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ObjectiveCSpec.m; sourceTree = "<group>"; };
202201
243C620E1FC3834B0082C327 /* Percent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Percent.swift; path = Impl/Percent.swift; sourceTree = "<group>"; };
203202
244C6E141E776A0C0074FC74 /* MarginsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginsSpec.swift; sourceTree = "<group>"; };
204203
244DF2F81EF46C500090508B /* PinLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PinLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -412,7 +411,6 @@
412411
DF1A5D252084C9E200725EF5 /* iOS */ = {
413412
isa = PBXGroup;
414413
children = (
415-
243B12C91FC469550072A9C3 /* ObjectiveCSpec.m */,
416414
DF1E39B420482B1F0002D0AA /* PinSafeAreaTests.swift */,
417415
DFBCAEFF213023700025F7BF /* ReadableLayoutMarginsSpec.swift */,
418416
245C1DA11FEC4FC6007594F7 /* TransformSpec.swift */,

Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PODS:
2-
- Nimble (7.3.1)
2+
- Nimble (7.3.4)
33
- PinLayout (1.8.6)
4-
- Quick (1.3.2)
5-
- Reveal-SDK (20)
6-
- SwiftLint (0.29.1)
4+
- Quick (1.3.4)
5+
- Reveal-SDK (21)
6+
- SwiftLint (0.30.1)
77

88
DEPENDENCIES:
99
- Nimble
@@ -24,11 +24,11 @@ EXTERNAL SOURCES:
2424
:path: "./"
2525

2626
SPEC CHECKSUMS:
27-
Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae
27+
Nimble: 051e3d8912d40138fa5591c78594f95fb172af37
2828
PinLayout: fe2a2432d6982588e208572005c941aeeae417ab
29-
Quick: 2623cb30d7a7f41ca62f684f679586558f483d46
30-
Reveal-SDK: 43206a57f575632fd304e85385cc259b5d359e32
31-
SwiftLint: 6772320e40b52049053a518c17db9b0634a0b45a
29+
Quick: f4f7f063c524394c73ed93ac70983c609805d481
30+
Reveal-SDK: 3523e0eb7c562811c51bb71da6e523a6373702c8
31+
SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7
3232

3333
PODFILE CHECKSUM: 62618887f8155abc1ed3348d9b676cf6915137e2
3434

Sources/ObjectiveC/PinLayoutObjC.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ import AppKit
249249
#elseif os(macOS)
250250
@discardableResult func size(of view: NSView) -> PinLayoutObjC
251251
#endif
252+
253+
254+
//
255+
// MARK: wrapContent
256+
@discardableResult func wrapContent() -> PinLayoutObjC;
257+
@discardableResult func wrapContent(padding: CGFloat) -> PinLayoutObjC;
258+
@discardableResult func wrapContent(insets: PEdgeInsets) -> PinLayoutObjC;
259+
@discardableResult func wrapContent(type: WrapType) -> PinLayoutObjC;
260+
@discardableResult func wrapContent(type: WrapType, padding: CGFloat) -> PinLayoutObjC;
261+
@discardableResult func wrapContent(type: WrapType, insets: PEdgeInsets) -> PinLayoutObjC;
262+
252263

253264
/**
254265
Set the view aspect ratio.

Sources/ObjectiveC/PinLayoutObjCImpl.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,36 @@ import AppKit
662662
return self
663663
}
664664

665+
func wrapContent() -> PinLayoutObjC {
666+
_ = impl?.wrapContent()
667+
return self
668+
}
669+
670+
func wrapContent(padding: CGFloat) -> PinLayoutObjC {
671+
_ = impl?.wrapContent(padding: padding)
672+
return self
673+
}
674+
675+
func wrapContent(insets: PEdgeInsets) -> PinLayoutObjC {
676+
_ = impl?.wrapContent(padding: insets)
677+
return self
678+
}
679+
680+
func wrapContent(type: WrapType) -> PinLayoutObjC {
681+
_ = impl?.wrapContent(type)
682+
return self
683+
}
684+
685+
func wrapContent(type: WrapType, padding: CGFloat) -> PinLayoutObjC {
686+
_ = impl?.wrapContent(type, padding: padding)
687+
return self
688+
}
689+
690+
func wrapContent(type: WrapType, insets: PEdgeInsets) -> PinLayoutObjC {
691+
_ = impl?.wrapContent(type, padding: insets)
692+
return self
693+
}
694+
665695
func aspectRatio(_ ratio: CGFloat) -> PinLayoutObjC {
666696
_ = impl?.aspectRatio(ratio)
667697
return self

Sources/Types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public enum FitType {
185185
case content
186186
}
187187

188-
public enum WrapType {
188+
@objc public enum WrapType: Int {
189189
/// Adjust the view's width AND height to wrap all its subviews.
190190
case all
191191
/// Adjust only the view's width to wrap all its subviews. The view's height won't be modified.

Tests/Common/ObjectiveCSpec.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@
7474
expect(@(aView.frame)).to(equal(@(CGRectMake(40, 10, 100, 60))));
7575
expect(Pin.lastWarningText).to(beNil());
7676
});
77+
78+
it(@"check the access to PinLayout methods from objective-c", ^{
79+
[[[rootView pinObjc] wrapContent] layout];
80+
[[[rootView pinObjc] wrapContentWithType:WrapTypeVertically] layout];
81+
[[[rootView pinObjc] wrapContentWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)] layout];
82+
[[[rootView pinObjc] wrapContentWithType:WrapTypeAll insets:UIEdgeInsetsMake(0, 0, 0, 0)] layout];
83+
[[[rootView pinObjc] wrapContentWithPadding:10] layout];
84+
[[[rootView pinObjc] wrapContentWithType:WrapTypeHorizontally padding:10] layout];
85+
});
7786
});
7887
});
7988

Tests/iOS/ObjectiveCSpec.m

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)