Skip to content

Commit 3727388

Browse files
authored
Merge pull request #100 from hyperoslo/refactor/remove-cartography
Refactor: remove cartography
2 parents d7793c9 + 82445ae commit 3727388

File tree

11 files changed

+74
-59
lines changed

11 files changed

+74
-59
lines changed

Cartfile

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
github "robb/Cartography"
21
github "hyperoslo/Pages"

Cartfile.resolved

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
github "hyperoslo/Pages" "2.0.2"
2-
github "robb/Cartography" "2.0.0"

Example/Parallax/Parallax.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,12 @@
213213
);
214214
inputPaths = (
215215
"${SRCROOT}/Pods/Target Support Files/Pods-Parallax/Pods-Parallax-frameworks.sh",
216-
"${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework",
217216
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
218217
"${BUILT_PRODUCTS_DIR}/Pages/Pages.framework",
219218
"${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework",
220219
);
221220
name = "[CP] Embed Pods Frameworks";
222221
outputPaths = (
223-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework",
224222
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
225223
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework",
226224
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework",
@@ -366,6 +364,7 @@
366364
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
367365
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
368366
INFOPLIST_FILE = Parallax/Info.plist;
367+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
369368
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
370369
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
371370
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -382,6 +381,7 @@
382381
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
383382
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
384383
INFOPLIST_FILE = Parallax/Info.plist;
384+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
385385
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
386386
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
387387
PRODUCT_NAME = "$(TARGET_NAME)";

Example/Parallax/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use_frameworks!
22

3-
platform :ios, '8.0'
3+
platform :ios, '9.0'
44

55
pod 'Presentation', path: '../../'
66
pod 'Hue'

Example/Parallax/Podfile.lock

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
PODS:
2-
- Cartography (2.0.0)
3-
- Hue (2.0.1)
2+
- Hue (3.0.1)
43
- Pages (2.0.2)
5-
- Presentation (3.1.0):
6-
- Cartography
7-
- Pages
4+
- Presentation (4.1.0):
5+
- Pages (~> 2.0)
86

97
DEPENDENCIES:
108
- Hue
@@ -15,11 +13,10 @@ EXTERNAL SOURCES:
1513
:path: ../../
1614

1715
SPEC CHECKSUMS:
18-
Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281
19-
Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf
16+
Hue: 93e852fa6211ab35922ad8c293f51c43d6c79eb2
2017
Pages: 5564ac6035c48fef7a837049314f57507d263b11
21-
Presentation: 07f001419368d0ece73285f238b1dc3852462f23
18+
Presentation: b717a7e0bff6af8e028998269114a344d5c114e4
2219

23-
PODFILE CHECKSUM: 8a38e1ff9630071a018856bbaebe49be27870e49
20+
PODFILE CHECKSUM: 979718cbe7e3509ed288250a31b6c6036f4f9943
2421

25-
COCOAPODS: 1.3.1
22+
COCOAPODS: 1.4.0

Example/Tutorial/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
22

33
use_frameworks!
44

5-
platform :ios, '8.0'
5+
platform :ios, '9.0'
66

77
pod 'Presentation', path: '../../'
88
pod 'Hue'

Example/Tutorial/Podfile.lock

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
PODS:
2-
- Cartography (2.0.0)
3-
- Hue (1.2.0)
2+
- Hue (3.0.1)
43
- Pages (2.0.2)
5-
- Presentation (3.1.0):
6-
- Cartography
7-
- Pages
4+
- Presentation (4.1.0):
5+
- Pages (~> 2.0)
86

97
DEPENDENCIES:
108
- Hue
@@ -15,11 +13,10 @@ EXTERNAL SOURCES:
1513
:path: ../../
1614

1715
SPEC CHECKSUMS:
18-
Cartography: d295eb25ab54bb57eecd8c2f04e9648c850f1281
19-
Hue: 0705083b7aff40334033373e6293ec1215285ac2
16+
Hue: 93e852fa6211ab35922ad8c293f51c43d6c79eb2
2017
Pages: 5564ac6035c48fef7a837049314f57507d263b11
21-
Presentation: 07f001419368d0ece73285f238b1dc3852462f23
18+
Presentation: b717a7e0bff6af8e028998269114a344d5c114e4
2219

23-
PODFILE CHECKSUM: a2be853ebf7792783dc915c68a50d0f469a3c2ec
20+
PODFILE CHECKSUM: fdf662532b7595886c0398895df5b6e99fbfa147
2421

25-
COCOAPODS: 1.3.1
22+
COCOAPODS: 1.4.0

Example/Tutorial/Tutorial.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,12 @@
202202
);
203203
inputPaths = (
204204
"${SRCROOT}/Pods/Target Support Files/Pods-Tutorial/Pods-Tutorial-frameworks.sh",
205-
"${BUILT_PRODUCTS_DIR}/Cartography/Cartography.framework",
206205
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
207206
"${BUILT_PRODUCTS_DIR}/Pages/Pages.framework",
208207
"${BUILT_PRODUCTS_DIR}/Presentation/Presentation.framework",
209208
);
210209
name = "[CP] Embed Pods Frameworks";
211210
outputPaths = (
212-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cartography.framework",
213211
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
214212
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Pages.framework",
215213
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Presentation.framework",
@@ -352,6 +350,7 @@
352350
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
353351
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
354352
INFOPLIST_FILE = Tutorial/Info.plist;
353+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
355354
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
356355
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
357356
PRODUCT_NAME = Tutorial;
@@ -368,6 +367,7 @@
368367
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
369368
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
370369
INFOPLIST_FILE = Tutorial/Info.plist;
370+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
371371
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
372372
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)";
373373
PRODUCT_NAME = Tutorial;

Presentation.podspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "Presentation"
33
s.summary = "Presentation helps you to make tutorials, release notes and animated pages."
4-
s.version = "4.0.0"
4+
s.version = "4.1.0"
55
s.homepage = "https://github.com/hyperoslo/Presentation"
66
s.license = 'MIT'
77
s.author = { "Hyper" => "[email protected]" }
@@ -13,5 +13,4 @@ Pod::Spec.new do |s|
1313

1414
s.source_files = 'Source/**/*'
1515
s.dependency 'Pages', '~> 2.0'
16-
s.dependency 'Cartography', '~> 2.0'
1716
end

Presentation.xcodeproj/project.pbxproj

-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
D523B0EE1C43AC70001AD1EC /* PresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0E41C43AC70001AD1EC /* PresentationController.swift */; };
1818
D523B0EF1C43AC70001AD1EC /* SlideController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0E51C43AC70001AD1EC /* SlideController.swift */; };
1919
D523B0F21C43AE94001AD1EC /* Pages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0F01C43AE94001AD1EC /* Pages.framework */; };
20-
D523B0F31C43AE94001AD1EC /* Cartography.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0F11C43AE94001AD1EC /* Cartography.framework */; };
2120
/* End PBXBuildFile section */
2221

2322
/* Begin PBXFileReference section */
@@ -33,7 +32,6 @@
3332
D523B0E41C43AC70001AD1EC /* PresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentationController.swift; sourceTree = "<group>"; };
3433
D523B0E51C43AC70001AD1EC /* SlideController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlideController.swift; sourceTree = "<group>"; };
3534
D523B0F01C43AE94001AD1EC /* Pages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pages.framework; path = Carthage/Build/iOS/Pages.framework; sourceTree = "<group>"; };
36-
D523B0F11C43AE94001AD1EC /* Cartography.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cartography.framework; path = Carthage/Build/iOS/Cartography.framework; sourceTree = "<group>"; };
3735
/* End PBXFileReference section */
3836

3937
/* Begin PBXFrameworksBuildPhase section */
@@ -42,7 +40,6 @@
4240
buildActionMask = 2147483647;
4341
files = (
4442
D523B0F21C43AE94001AD1EC /* Pages.framework in Frameworks */,
45-
D523B0F31C43AE94001AD1EC /* Cartography.framework in Frameworks */,
4643
);
4744
runOnlyForDeploymentPostprocessing = 0;
4845
};
@@ -111,7 +108,6 @@
111108
isa = PBXGroup;
112109
children = (
113110
D523B0F01C43AE94001AD1EC /* Pages.framework */,
114-
D523B0F11C43AE94001AD1EC /* Cartography.framework */,
115111
);
116112
name = Frameworks;
117113
sourceTree = "<group>";
@@ -198,7 +194,6 @@
198194
);
199195
inputPaths = (
200196
"$(SRCROOT)/Carthage/Build/iOS/Pages.framework",
201-
"$(SRCROOT)/Carthage/Build/iOS/Cartography.framework",
202197
);
203198
outputPaths = (
204199
);

Source/Content.swift

+53-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import UIKit
2-
import Cartography
32

43
public final class Content: NSObject {
54
public var view: UIView
@@ -12,7 +11,7 @@ public final class Content: NSObject {
1211
}
1312

1413
public private(set) var initialPosition: Position
15-
private let group = ConstraintGroup()
14+
private var constraints = [NSLayoutConstraint]()
1615

1716
public init(view: UIView, position: Position, centered: Bool = true) {
1817
self.view = view
@@ -22,40 +21,70 @@ public final class Content: NSObject {
2221

2322
super.init()
2423

25-
constrain(view) { [unowned self] view in
26-
view.width == self.view.frame.width
27-
view.height == self.view.frame.height
28-
}
24+
view.translatesAutoresizingMaskIntoConstraints = false
25+
setupSizeConstraints()
2926
}
3027

3128
public func layout() {
32-
guard view.superview != nil else {
29+
guard let superview = view.superview else {
3330
return
3431
}
3532

36-
constrain(view, replace: group) { [unowned self] view in
37-
let x = self.position.left == 0.0
38-
? view.superview!.left * 1.0
39-
: view.superview!.right * self.position.left
40-
let y = self.position.top == 0.0
41-
? view.superview!.top * 1.0
42-
: view.superview!.bottom * self.position.top
43-
44-
if self.centered {
45-
view.centerX == x
46-
view.centerY == y
47-
} else {
48-
view.left == x
49-
view.top == y
50-
}
51-
}
52-
33+
NSLayoutConstraint.deactivate(constraints)
34+
35+
let xAttribute: NSLayoutAttribute = centered ? .centerX : .leading
36+
let yAttribute: NSLayoutAttribute = centered ? .centerY : .top
37+
let xSuperAttribute: NSLayoutAttribute = position.left == 0 ? .leading : .trailing
38+
let ySuperAttribute: NSLayoutAttribute = position.top == 0 ? .top : .bottom
39+
let xMultiplier: CGFloat = position.left == 0 ? 1 : position.left
40+
let yMultiplier: CGFloat = position.top == 0 ? 1 : position.top
41+
42+
constraints = [
43+
NSLayoutConstraint(
44+
item: view,
45+
attribute: xAttribute,
46+
relatedBy: .equal,
47+
toItem: superview,
48+
attribute: xSuperAttribute,
49+
multiplier: xMultiplier,
50+
constant: 0
51+
),
52+
NSLayoutConstraint(
53+
item: view,
54+
attribute: yAttribute,
55+
relatedBy: .equal,
56+
toItem: superview,
57+
attribute: ySuperAttribute,
58+
multiplier: yMultiplier,
59+
constant: 0
60+
)
61+
]
62+
63+
NSLayoutConstraint.activate(constraints)
5364
view.layoutIfNeeded()
5465
}
5566

5667
public func animate() {
5768
view.superview!.layoutIfNeeded()
5869
}
70+
71+
private func setupSizeConstraints() {
72+
makeSizeConstraint(attribute: .width, constant: view.frame.width).isActive = true
73+
makeSizeConstraint(attribute: .height, constant: view.frame.height).isActive = true
74+
}
75+
76+
private func makeSizeConstraint(attribute: NSLayoutAttribute,
77+
constant: CGFloat) -> NSLayoutConstraint {
78+
return NSLayoutConstraint(
79+
item: view,
80+
attribute: attribute,
81+
relatedBy: .equal,
82+
toItem: nil,
83+
attribute: .notAnAttribute,
84+
multiplier: 1,
85+
constant: constant
86+
)
87+
}
5988
}
6089

6190
public extension Content {

0 commit comments

Comments
 (0)