Skip to content

Commit 9fff380

Browse files
authored
Merge pull request #135 from mirego/update_objc_interface
Add few missing Objective-C Interface properties and methods
2 parents 27b4487 + d4e8456 commit 9fff380

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ disabled_rules: # rule identifiers to exclude from running
2020
- nimble_operator
2121
- identifier_name
2222
- line_length
23+
- empty_count
2324

2425
excluded: # paths to ignore during linting. overridden by `included`.
2526
- Pods

Example/.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ disabled_rules: # rule identifiers to exclude from running
2020
- nimble_operator
2121
- identifier_name
2222
- line_length
23+
- empty_count
2324

2425
excluded: # paths to ignore during linting. overridden by `included`.
2526
- Pods

Sources/Pin.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import Foundation
2121

22-
public enum LayoutDirection {
22+
@objc public enum LayoutDirection: Int {
2323
case auto
2424
case ltr
2525
case rtl
@@ -28,7 +28,7 @@ public enum LayoutDirection {
2828
/// Control how PinLayout will calls `UIView.safeAreaInsetsDidChange` when the `UIView.pin.safeArea` change.
2929
/// This support is usefull only on iOS 8/9/10. On iOS 11 `UIView.safeAreaInsetsDidChange` is supported
3030
/// natively so this settings have no impact.
31-
public enum PinSafeAreaInsetsDidChangeMode {
31+
@objc public enum PinSafeAreaInsetsDidChangeMode: Int {
3232
/// PinLayout won't call `UIView.safeAreaInsetsDidChange` on iOS 8/9/10.
3333
case disable
3434
/// PinLayout will call `UIView.safeAreaInsetsDidChange` only if the UIView implement the PinSafeAreaInsetsUpdate protocol.
@@ -38,11 +38,11 @@ public enum PinSafeAreaInsetsDidChangeMode {
3838
}
3939

4040
@objc public class Pin: NSObject {
41-
public static var layoutDirection = LayoutDirection.ltr
41+
@objc public static var layoutDirection = LayoutDirection.ltr
4242

4343
#if os(iOS) || os(tvOS)
4444
/// Controls how PinLayout will calls `UIView.safeAreaInsetsDidChange` when the `UIView.pin.safeArea` change.
45-
public static var safeAreaInsetsDidChangeMode: PinSafeAreaInsetsDidChangeMode = .optIn {
45+
@objc public static var safeAreaInsetsDidChangeMode: PinSafeAreaInsetsDidChangeMode = .optIn {
4646
didSet {
4747
PinSafeArea.safeAreaInsetsDidChangeMode = safeAreaInsetsDidChangeMode
4848
}
@@ -51,9 +51,9 @@ public enum PinSafeAreaInsetsDidChangeMode {
5151

5252

5353
#if DEBUG
54-
public static var logWarnings = true
54+
@objc public static var logWarnings = true
5555
#else
56-
public static var logWarnings = false
56+
@objc public static var logWarnings = false
5757
#endif
5858

5959
/**
@@ -65,15 +65,15 @@ public enum PinSafeAreaInsetsDidChangeMode {
6565

6666
static fileprivate var isInitialized = false
6767

68-
public static func initPinLayout() {
68+
@objc public static func initPinLayout() {
6969
#if os(iOS) || os(tvOS)
7070
guard !Pin.isInitialized else { return }
7171
PinSafeArea.initSafeAreaSupport()
7272
Pin.isInitialized = true
7373
#endif
7474
}
7575

76-
public static func layoutDirection(_ direction: LayoutDirection) {
76+
@objc public static func layoutDirection(_ direction: LayoutDirection) {
7777
self.layoutDirection = direction
7878
}
7979

Tests/iOS/ObjectiveCSpec.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@
3838
Pin.logMissingLayoutCalls = false;
3939
});
4040

41-
describe(@"its click", ^{
42-
it(@"is loud", ^{
41+
describe(@"generic objective-c tests", ^{
42+
it(@"Access Pin properties and methods", ^{
43+
[Pin initPinLayout];
44+
[Pin layoutDirection:LayoutDirectionLtr];
45+
Pin.safeAreaInsetsDidChangeMode = PinSafeAreaInsetsDidChangeModeAlways;
46+
Pin.layoutDirection = LayoutDirectionLtr;
47+
Pin.logWarnings = true;
48+
});
49+
50+
it(@"basic pinlayout calls", ^{
4351
[[[aView pinObjc] top:10] layout];
4452
expect(@(aView.frame)).to(equal(@(CGRectMake(40, 10, 100, 60))));
4553
});

0 commit comments

Comments
 (0)