Skip to content

Commit b3320f4

Browse files
Merge pull request #16 from niralishaha25/dev
fix in added buttons bottom constraint
2 parents b5f8513 + 678dc12 commit b3320f4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Source/Pages/Gallery/YPLibraryVC+CollectionView.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import Photos
1011

1112
extension YPLibraryVC {
1213
var isLimitExceeded: Bool { return selectedItems.count >= YPConfig.library.maxNumberOfItems }
@@ -103,12 +104,12 @@ extension YPLibraryVC {
103104
func checkLimit() {
104105
let isHidden = !isLimitExceeded || isMultipleSelectionEnabled == false
105106
v.maxNumberWarningView.isHidden = isHidden
106-
if !isHidden {
107-
v.selectMoreButton.bottomConstraint?.constant = (v.maxNumberWarningView.bottomConstraint?.constant ?? 0) - 40
108-
v.seeAllButton.bottomConstraint?.constant = (v.maxNumberWarningView.bottomConstraint?.constant ?? 0) - 40
109-
} else {
110-
v.selectMoreButton.bottomConstraint?.constant = 0
111-
v.seeAllButton.bottomConstraint?.constant = 0
107+
if #available(iOS 14, *) {
108+
let status = PHPhotoLibrary.authorizationStatus(for: .readWrite)
109+
if status == .limited {
110+
v.selectMoreButton.isHidden = !isHidden
111+
v.seeAllButton.isHidden = !isHidden
112+
}
112113
}
113114
}
114115
}

Source/Pages/Gallery/YPLibraryView.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ internal final class YPLibraryView: UIView {
5555
status = PHPhotoLibrary.authorizationStatus(for: .readWrite)
5656
if status == .limited {
5757
v.isHidden = false
58-
v.setTitle(" Select more photos ", for: .normal)
59-
v.frame.size.width = 300.0
58+
v.setTitle(" Select more ", for: .normal)
6059
v.backgroundColor = YPConfig.selectMoreButtonBackgroundColour.withAlphaComponent(0.8)
6160
v.layer.cornerRadius = 4
6261
v.layer.masksToBounds = true
@@ -77,7 +76,6 @@ internal final class YPLibraryView: UIView {
7776
if status == .limited {
7877
v.isHidden = false
7978
v.setTitle(" See all photos ", for: .normal)
80-
v.frame.size.width = 300.0
8179
v.backgroundColor = YPConfig.seeAllPhotosButtonBackgroundColour.withAlphaComponent(0.8)
8280
v.layer.cornerRadius = 4
8381
v.layer.masksToBounds = true
@@ -249,12 +247,12 @@ internal final class YPLibraryView: UIView {
249247
maxNumberWarningView.Top == safeAreaLayoutGuide.Bottom - 40
250248
maxNumberWarningLabel.centerHorizontally().top(11)
251249

252-
seeAllButton.bottom(0)
250+
seeAllButton.Bottom == safeAreaLayoutGuide.Bottom
253251
seeAllButton.Top == safeAreaLayoutGuide.Bottom - 40
254252
seeAllButton.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.50).isActive = true
255253
seeAllButton.Left == UIScreen.main.bounds.width * 0.05
256254

257-
selectMoreButton.bottom(0)
255+
selectMoreButton.Bottom == safeAreaLayoutGuide.Bottom
258256
selectMoreButton.Top == safeAreaLayoutGuide.Bottom - 40
259257
selectMoreButton.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.35).isActive = true
260258
selectMoreButton.Right == UIScreen.main.bounds.width * 0.05

0 commit comments

Comments
 (0)