Skip to content

Commit f34bf7b

Browse files
Remove dependency on Device library
1 parent 8053205 commit f34bf7b

File tree

7 files changed

+25
-44
lines changed

7 files changed

+25
-44
lines changed

AssetsPickerViewController.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ Fully customizable UI.
4141
# s.public_header_files = 'Pod/Classes/**/*.h'
4242
# s.frameworks = 'UIKit', 'MapKit'
4343
s.dependency 'SnapKit'
44-
s.dependency 'Device'
4544
end

AssetsPickerViewController/Classes/Photo/Controller/AssetsPhotoViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import UIKit
1010
import Photos
1111
import PhotosUI
12-
import Device
1312
import SnapKit
1413

1514
// MARK: - AssetsPhotoViewController

AssetsPickerViewController/Classes/Photo/View/AssetsPhotoLayout.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
import UIKit
10-
import Device
1110

1211
open class AssetsPhotoLayout: UICollectionViewFlowLayout {
1312

@@ -46,13 +45,13 @@ extension AssetsPhotoLayout {
4645
let cellSize = isPortrait ? pickerConfig.assetPortraitCellSize(forViewSize: UIScreen.main.portraitContentSize) : pickerConfig.assetLandscapeCellSize(forViewSize: UIScreen.main.landscapeContentSize)
4746
let lineSpace = isPortrait ? pickerConfig.assetPortraitLineSpace : pickerConfig.assetLandscapeLineSpace
4847
let contentHeight = CGFloat(rows) * cellSize.height + (CGFloat(max(rows - 1, 0)) * lineSpace)
49-
let bottomHeight = cellSize.height * 2/3 + Device.safeAreaInsets(isPortrait: isPortrait).bottom
48+
let bottomHeight = cellSize.height * 2/3 + UIScreen.safeAreaInsets(isPortrait: isPortrait).bottom
5049

5150
return contentHeight + bottomHeight
5251
}
5352

5453
private func offsetRatio(collectionView: UICollectionView, offset: CGPoint, contentSize: CGSize, isPortrait: Bool) -> CGFloat {
55-
return (offset.y > 0 ? offset.y : 0) / ((contentSize.height + Device.safeAreaInsets(isPortrait: isPortrait).bottom) - collectionView.bounds.height)
54+
return (offset.y > 0 ? offset.y : 0) / ((contentSize.height + UIScreen.safeAreaInsets(isPortrait: isPortrait).bottom) - collectionView.bounds.height)
5655
}
5756

5857
open func translateOffset(forChangingSize size: CGSize, currentOffset: CGPoint) -> CGPoint? {
@@ -67,8 +66,8 @@ extension AssetsPhotoLayout {
6766
var futureOffsetY = (contentHeight - size.height) * currentRatio
6867

6968
if currentOffset.y < 0 {
70-
let insetRatio = (-currentOffset.y) / Device.safeAreaInsets(isPortrait: isPortraitCurrent).top
71-
let insetDiff = Device.safeAreaInsets(isPortrait: isPortraitFuture).top * insetRatio
69+
let insetRatio = (-currentOffset.y) / UIScreen.safeAreaInsets(isPortrait: isPortraitCurrent).top
70+
let insetDiff = UIScreen.safeAreaInsets(isPortrait: isPortraitFuture).top * insetRatio
7271
futureOffsetY -= insetDiff
7372
}
7473

AssetsPickerViewController/Classes/Utility/Device+AssetsPickerViewController.swift

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

AssetsPickerViewController/Classes/Utility/UIScreen+AssetsPickerViewController.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
//
88

99
import UIKit
10-
import Device
1110

1211
extension UIScreen {
12+
static func safeAreaInsets(isPortrait: Bool) -> UIEdgeInsets {
13+
let w: Double = Double(UIScreen.main.bounds.width)
14+
let h: Double = Double(UIScreen.main.bounds.height)
15+
let screenHeight: Double = max(w, h)
16+
17+
switch screenHeight {
18+
case 812: // 5.8" (iPhone X/XS/XR/11)
19+
return isPortrait ? UIEdgeInsets(top: 88, left: 0, bottom: 34, right: 0) : UIEdgeInsets(top: 32, left: 44, bottom: 21, right: 44)
20+
default:
21+
return isPortrait ? UIEdgeInsets(top: 64, left: 0, bottom: 0, right: 0) : UIEdgeInsets(top: 30, left: 0, bottom: 0, right: 0)
22+
}
23+
}
1324

1425
var portraitSize: CGSize {
1526
let size = UIScreen.main.bounds.size
@@ -24,17 +35,17 @@ extension UIScreen {
2435
var portraitContentSize: CGSize {
2536
var size = UIScreen.main.portraitSize
2637
if #available(iOS 11.0, *) {
27-
size.width -= Device.safeAreaInsets(isPortrait: true).left + Device.safeAreaInsets(isPortrait: true).right
28-
size.height -= Device.safeAreaInsets(isPortrait: true).top + Device.safeAreaInsets(isPortrait: true).bottom
38+
size.width -= UIScreen.safeAreaInsets(isPortrait: true).left + UIScreen.safeAreaInsets(isPortrait: true).right
39+
size.height -= UIScreen.safeAreaInsets(isPortrait: true).top + UIScreen.safeAreaInsets(isPortrait: true).bottom
2940
}
3041
return size
3142
}
3243

3344
var landscapeContentSize: CGSize {
3445
var size = UIScreen.main.landscapeSize
3546
if #available(iOS 11.0, *) {
36-
size.width -= Device.safeAreaInsets(isPortrait: false).left + Device.safeAreaInsets(isPortrait: false).right
37-
size.height -= Device.safeAreaInsets(isPortrait: false).top + Device.safeAreaInsets(isPortrait: false).bottom
47+
size.width -= UIScreen.safeAreaInsets(isPortrait: false).left + UIScreen.safeAreaInsets(isPortrait: false).right
48+
size.height -= UIScreen.safeAreaInsets(isPortrait: false).top + UIScreen.safeAreaInsets(isPortrait: false).bottom
3849
}
3950
return size
4051
}

Example/AssetsPickerViewController.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,11 @@
344344
inputPaths = (
345345
"${PODS_ROOT}/Target Support Files/Pods-AssetsPickerViewController_Example/Pods-AssetsPickerViewController_Example-frameworks.sh",
346346
"${BUILT_PRODUCTS_DIR}/AssetsPickerViewController/AssetsPickerViewController.framework",
347-
"${BUILT_PRODUCTS_DIR}/Device/Device.framework",
348347
"${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework",
349348
);
350349
name = "[CP] Embed Pods Frameworks";
351350
outputPaths = (
352351
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AssetsPickerViewController.framework",
353-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Device.framework",
354352
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework",
355353
);
356354
runOnlyForDeploymentPostprocessing = 0;

Example/Podfile.lock

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
PODS:
2-
- AssetsPickerViewController (2.9.2):
3-
- Device
2+
- AssetsPickerViewController (2.9.6):
43
- SnapKit
5-
- Device (3.1.2)
6-
- SnapKit (5.0.0)
4+
- SnapKit (5.0.1)
75

86
DEPENDENCIES:
97
- AssetsPickerViewController (from `../`)
108

119
SPEC REPOS:
12-
https://github.com/CocoaPods/Specs.git:
13-
- Device
10+
trunk:
1411
- SnapKit
1512

1613
EXTERNAL SOURCES:
1714
AssetsPickerViewController:
1815
:path: "../"
1916

2017
SPEC CHECKSUMS:
21-
AssetsPickerViewController: 6626c9640d75ee4b60eea9b0fddf95cac0f41124
22-
Device: 62242076214c30fb5760174b3601cefafa70a481
23-
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
18+
AssetsPickerViewController: afad53707ec66ddd15182fa62630448736ed3976
19+
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
2420

2521
PODFILE CHECKSUM: ed535a80c7e9986ea173935163bbd69a1c717311
2622

0 commit comments

Comments
 (0)