Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tilltue committed Nov 25, 2021
1 parent 2d57b0b commit 89f924e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Example/TLPhotoPicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {

@IBAction func pickerButtonTap() {
let viewController = CustomPhotoPickerViewController()
viewController.modalPresentationStyle = .fullScreen
viewController.delegate = self
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
self?.showExceededMaximumAlert(vc: picker)
Expand Down Expand Up @@ -67,6 +68,7 @@ class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {

@IBAction func pickerWithCustomBlackStyle() {
let viewController = CustomBlackStylePickerViewController()
viewController.modalPresentationStyle = .fullScreen
viewController.delegate = self
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
self?.showExceededMaximumAlert(vc: picker)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ public struct TLPhotosPickerConfigure {
public var preventAutomaticLimitedAccessAlert = true // newest iOS 14
public var mediaType: PHAssetMediaType? = nil
public var numberOfColumn = 3
public var minimumLineSpacing: CGFloat = 5
public var minimumInteritemSpacing: CGFloat = 5
public var singleSelectedMode = false
public var maxSelectedAssets: Int? = nil //default: inf
public var fetchOption: PHFetchOptions? = nil //default: creationDate
Expand Down
23 changes: 17 additions & 6 deletions TLPhotoPicker/Classes/TLPhotosPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public struct TLPhotosPickerConfigure {
public var preventAutomaticLimitedAccessAlert = true
public var mediaType: PHAssetMediaType? = nil
public var numberOfColumn = 3
public var minimumLineSpacing: CGFloat = 5
public var minimumInteritemSpacing: CGFloat = 5
public var singleSelectedMode = false
public var maxSelectedAssets: Int? = nil
public var fetchOption: PHFetchOptions? = nil
Expand Down Expand Up @@ -235,16 +237,22 @@ open class TLPhotosPickerViewController: UIViewController {
registerForPreviewing(with: self, sourceView: collectionView)
}


updateUserInterfaceStyle()
}

private func updateUserInterfaceStyle() {
if #available(iOS 13.0, *) {
let userInterfaceStyle = self.traitCollection.userInterfaceStyle
let image = TLBundle.podBundleImage(named: "pop_arrow")
let subImage = TLBundle.podBundleImage(named: "arrow")
if userInterfaceStyle.rawValue == 2 {
self.popArrowImageView.image = image?.colorMask(color: .systemBackground)
self.subTitleArrowImageView.image = subImage?.colorMask(color: .white)
self.view.backgroundColor = .black
self.collectionView.backgroundColor = .black
}else {
} else {
self.popArrowImageView.image = image?.colorMask(color: .white)
self.subTitleArrowImageView.image = subImage
self.view.backgroundColor = .white
self.collectionView.backgroundColor = .white
}
Expand Down Expand Up @@ -385,10 +393,11 @@ extension TLPhotosPickerViewController {
return
}
let count = CGFloat(self.configure.numberOfColumn)
let width = floor((self.view.frame.size.width-(5*(count-1)))/count)
let width = floor((self.view.frame.size.width - (self.configure.minimumInteritemSpacing * (count-1))) / count)
self.thumbnailSize = CGSize(width: width, height: width)
layout.itemSize = self.thumbnailSize
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = self.configure.minimumLineSpacing
self.collectionView.collectionViewLayout = layout
self.placeholderThumbnail = centerAtRect(image: self.configure.placeholderIcon, rect: CGRect(x: 0, y: 0, width: width, height: width))
self.cameraImage = centerAtRect(image: self.configure.cameraIcon, rect: CGRect(x: 0, y: 0, width: width, height: width), bgColor: self.configure.cameraBgColor)
Expand All @@ -408,9 +417,10 @@ extension TLPhotosPickerViewController {
self.titleLabel.text = self.configure.customLocalizedTitle["Camera Roll"]
self.subTitleLabel.text = self.configure.tapHereToChange
self.cancelButton.title = self.configure.cancelTitle
self.cancelButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: UIFont.labelFontSize),NSAttributedString.Key.foregroundColor:UIColor.blue], for: .normal)

let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: UIFont.labelFontSize)]
self.doneButton.setTitleTextAttributes(attributes, for: .normal)
self.doneButton.title = self.configure.doneTitle
self.doneButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: UIFont.labelFontSize),NSAttributedString.Key.foregroundColor:UIColor.blue], for: .normal)
self.emptyView.isHidden = true
self.emptyImageView.image = self.configure.emptyImage
self.emptyMessageLabel.text = self.configure.emptyMessage
Expand All @@ -425,11 +435,12 @@ extension TLPhotosPickerViewController {
self.usedPrefetch = false
}
if #available(iOS 9.0, *), self.allowedLivePhotos {
}else {
} else {
self.allowedLivePhotos = false
}
self.customDataSouces?.registerSupplementView(collectionView: self.collectionView)
self.navigationBar.delegate = self
updateUserInterfaceStyle()
}

private func updatePresentLimitedLibraryButton() {
Expand Down
4 changes: 2 additions & 2 deletions TLPhotoPicker/Classes/TLPhotosPickerViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow.png" translatesAutoresizingMaskIntoConstraints="NO" id="b7w-7R-rco">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="b7w-7R-rco">
<rect key="frame" x="34.5" y="7.5" width="10" height="10"/>
<constraints>
<constraint firstAttribute="width" priority="999" constant="10" id="7bM-Da-Q8A"/>
Expand Down Expand Up @@ -172,7 +172,7 @@
<constraint firstAttribute="bottom" secondItem="grw-Nk-Sxr" secondAttribute="bottom" id="sPK-1G-qLo"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="pop_arrow.png" translatesAutoresizingMaskIntoConstraints="NO" id="5zn-je-qLx">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5zn-je-qLx">
<rect key="frame" x="180.5" y="10" width="14" height="7"/>
<constraints>
<constraint firstAttribute="height" constant="7" id="eZN-nB-EHu"/>
Expand Down

0 comments on commit 89f924e

Please sign in to comment.