Commit 88249c40 by Sarkizz

调整图片浏览vc,将多选和单选合成一个,并且添加图片大图展示界面

parent 3cd86481
......@@ -17,7 +17,6 @@
A70210522320FE8B009F8BC6 /* MRAlbumListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A702104E2320FE8B009F8BC6 /* MRAlbumListViewController.swift */; };
A70210532320FE8B009F8BC6 /* MRAlbumCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70210502320FE8B009F8BC6 /* MRAlbumCell.swift */; };
A70210542320FE8B009F8BC6 /* MRCheckBoxImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70210512320FE8B009F8BC6 /* MRCheckBoxImage.swift */; };
A702105823225148009F8BC6 /* SAMutableSelectionAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = A702105723225148009F8BC6 /* SAMutableSelectionAlbum.swift */; };
A7021067232742D7009F8BC6 /* UIImage+util.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7021066232742D7009F8BC6 /* UIImage+util.swift */; };
A702106A23277B2B009F8BC6 /* DataURLParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A702106923277B2B009F8BC6 /* DataURLParser.swift */; };
A73E5C8F23136605000C379B /* UIColor+util.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73E5C8E23136605000C379B /* UIColor+util.swift */; };
......@@ -48,6 +47,7 @@
A7B8E17C230FEB0700999DF2 /* NSMutableURLRequest+util.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B8E17B230FEB0700999DF2 /* NSMutableURLRequest+util.swift */; };
A7B8E17F230FEB9500999DF2 /* MRWebBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B8E17D230FEB9500999DF2 /* MRWebBridge.swift */; };
A7B8E180230FEB9500999DF2 /* MRWebMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B8E17E230FEB9500999DF2 /* MRWebMessageHandler.swift */; };
A7B92059232CE41D00C1C81A /* MRAlbumDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B92058232CE41D00C1C81A /* MRAlbumDetailViewController.swift */; };
D2C4CCE4857CBD85A0A306D6 /* Pods_MRFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95B35045DA3B1E69C27D2A08 /* Pods_MRFramework.framework */; };
/* End PBXBuildFile section */
......@@ -77,7 +77,6 @@
A702104E2320FE8B009F8BC6 /* MRAlbumListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MRAlbumListViewController.swift; sourceTree = "<group>"; };
A70210502320FE8B009F8BC6 /* MRAlbumCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MRAlbumCell.swift; sourceTree = "<group>"; };
A70210512320FE8B009F8BC6 /* MRCheckBoxImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MRCheckBoxImage.swift; sourceTree = "<group>"; };
A702105723225148009F8BC6 /* SAMutableSelectionAlbum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SAMutableSelectionAlbum.swift; sourceTree = "<group>"; };
A7021066232742D7009F8BC6 /* UIImage+util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+util.swift"; sourceTree = "<group>"; };
A702106923277B2B009F8BC6 /* DataURLParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataURLParser.swift; sourceTree = "<group>"; };
A73E5C8E23136605000C379B /* UIColor+util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+util.swift"; sourceTree = "<group>"; };
......@@ -111,6 +110,7 @@
A7B8E17B230FEB0700999DF2 /* NSMutableURLRequest+util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableURLRequest+util.swift"; sourceTree = "<group>"; };
A7B8E17D230FEB9500999DF2 /* MRWebBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MRWebBridge.swift; sourceTree = "<group>"; };
A7B8E17E230FEB9500999DF2 /* MRWebMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MRWebMessageHandler.swift; sourceTree = "<group>"; };
A7B92058232CE41D00C1C81A /* MRAlbumDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MRAlbumDetailViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -180,6 +180,7 @@
children = (
A702104F2320FE8B009F8BC6 /* Interface */,
A702104E2320FE8B009F8BC6 /* MRAlbumListViewController.swift */,
A7B92058232CE41D00C1C81A /* MRAlbumDetailViewController.swift */,
);
path = Album;
sourceTree = "<group>";
......@@ -351,7 +352,6 @@
isa = PBXGroup;
children = (
A7B8E160230E319700999DF2 /* SAPhotoPicker.swift */,
A702105723225148009F8BC6 /* SAMutableSelectionAlbum.swift */,
);
path = PhotoPicker;
sourceTree = "<group>";
......@@ -563,7 +563,6 @@
A73E5C97231377CD000C379B /* UITableView+reusable.swift in Sources */,
A7B8E15D230E318400999DF2 /* BLEManager.swift in Sources */,
A7021016231CC60C009F8BC6 /* MRScanningProtocol.swift in Sources */,
A702105823225148009F8BC6 /* SAMutableSelectionAlbum.swift in Sources */,
A7B8E161230E319700999DF2 /* SAPhotoPicker.swift in Sources */,
A7021017231CC60C009F8BC6 /* MRScanningLineView.swift in Sources */,
A702101B231CC60C009F8BC6 /* ScanningAVManager.swift in Sources */,
......@@ -575,6 +574,7 @@
A70210542320FE8B009F8BC6 /* MRCheckBoxImage.swift in Sources */,
A73E5C9D23137F51000C379B /* MRUpdateManager.swift in Sources */,
A7B8E13B230B9EE200999DF2 /* UIImage+file.swift in Sources */,
A7B92059232CE41D00C1C81A /* MRAlbumDetailViewController.swift in Sources */,
A73E5C9F2314CBC4000C379B /* Data+crypto.swift in Sources */,
A7B8E177230FDEB200999DF2 /* CAGradientLayer+util.swift in Sources */,
A73E5CA12314CCBC000C379B /* String+util.swift in Sources */,
......
......@@ -12,7 +12,7 @@ import SnapKit
public final class MRAlbumCell: UICollectionViewCell {
public static var checkboxSize: CGSize = CGSize(width: 30, height: 30)
public static var deselectedCheckboxOptions: MRCheckBoxOptions?
public static var deselectedCheckboxOptions: MRCheckBoxOptions = .custom(size: checkboxSize, backgroundColor: .clear)
public static var selectedCheckboxOptions: MRCheckBoxOptions = .defaultCheck(checkboxSize)
public let imageView = UIImageView()
......@@ -54,9 +54,7 @@ extension MRAlbumCell {
selectedMask.isUserInteractionEnabled = false
selectedMask.isHidden = true
if let options = MRAlbumCell.deselectedCheckboxOptions {
checkbox.setImage(MRCheckBoxImage.image(with: options), for: .normal)
}
checkbox.setImage(MRCheckBoxImage.image(with: MRAlbumCell.deselectedCheckboxOptions), for: .normal)
checkbox.setImage(MRCheckBoxImage.image(with: MRAlbumCell.selectedCheckboxOptions), for: .selected)
checkbox.addTarget(self, action: #selector(checkButtonPressed(_:)), for: .touchUpInside)
......
......@@ -28,8 +28,8 @@ public struct MRCheckBoxOptions {
public static func custom(size: CGSize,
type: MRCheckBoxType = .check,
checkLineWidth: CGFloat = 3,
curveLineWidth: CGFloat = 2,
checkLineWidth: CGFloat = 2,
curveLineWidth: CGFloat = 1,
checkLineColor: UIColor = .white,
curveLineColor: UIColor = .white,
backgroundColor: UIColor = .green) -> MRCheckBoxOptions {
......
//
// MRAlbumDetailViewController.swift
// MRFramework
//
// Created by Sarkizz on 2019/9/14.
// Copyright © 2019 sarkizz. All rights reserved.
//
import Foundation
import Photos
import SnapKit
public enum AlbumDetailState {
case none
case loading
case failed
case finish
}
open class MRAlbumDetailViewController: UIViewController {
static let requestQueue = DispatchQueue(label: "com.MRAblum.detail.queue")
public var confirm: ((_ vc: MRAlbumDetailViewController, _ isSelected: Bool) -> Void)?
public var assest: PHAsset!
public var isSelected = false
public var imageCache = PHCachingImageManager()
private let scrollView = UIScrollView()
private let imageView = UIImageView()
private let checkButton = UIButton(type: .custom)
private let checkboxSize = CGSize(width: 40, height: 40)
private var state: AlbumDetailState = .none {
didSet {
stateDidChange()
}
}
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .black
state = .loading
if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: false)
}
open override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: false)
}
open override var prefersStatusBarHidden: Bool {
return true
}
}
extension MRAlbumDetailViewController {
@objc private func singleTap(_ sender: UITapGestureRecognizer) {
if let nav = navigationController {
nav.setNavigationBarHidden(!nav.isNavigationBarHidden, animated: true)
}
}
@objc private func doubleTap(_ sender: UITapGestureRecognizer) {
if let nav = navigationController {
nav.setNavigationBarHidden(true, animated: true)
}
if scrollView.zoomScale == 1 {
scrollView.setZoomScale(3, animated: true)
} else {
scrollView.setZoomScale(1, animated: true)
}
}
@objc private func checkboxDidPress(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
isSelected = sender.isSelected
}
@objc private func confirmButtonDidPress(_ sender: UIButton) {
confirm?(self, isSelected)
}
}
extension MRAlbumDetailViewController {
private func loadImage(_ completion: @escaping (_ image: UIImage?, _ error: Error?) -> Void) {
ToastView.loading()
MRAlbumDetailViewController.requestQueue.async {
let options = PHImageRequestOptions()
options.isNetworkAccessAllowed = true
options.isSynchronous = true
self.imageCache.requestImage(for: self.assest, targetSize: PHImageManagerMaximumSize, contentMode: .default, options: options, resultHandler: { (image, _) in
DispatchQueue.main.async {
ToastView.hide()
completion(image, nil)
}
})
}
}
private func stateDidChange() {
switch state {
case .loading:
loadImage { (image, error) in
if let image = image {
self.imageView.image = image
self.state = .finish
} else {
self.state = .failed
}
}
case .failed:
ToastView.show("获取图片失败!")?.addCallbackWhenDismissCompleted {
self.navigationController?.popViewController(animated: true)
}
case .finish:
view.addSubview(scrollView)
scrollView.addSubview(imageView)
view.addSubview(checkButton)
addConfirmButton()
setupMainViews()
setupLayouts()
resizeImageView()
default:
break
}
}
private func setupMainViews() {
scrollView.zoomScale = 1
scrollView.maximumZoomScale = 3
scrollView.minimumZoomScale = 1
let singleTap = UITapGestureRecognizer(target: self, action: #selector(singleTap(_:)))
singleTap.numberOfTapsRequired = 1
singleTap.numberOfTouchesRequired = 1
let doubleTap = UITapGestureRecognizer(target: self, action: #selector(doubleTap(_:)))
doubleTap.numberOfTapsRequired = 2
doubleTap.numberOfTouchesRequired = 1
imageView.addGestureRecognizer(singleTap)
imageView.addGestureRecognizer(doubleTap)
imageView.isUserInteractionEnabled = true
let unCheckOptions: MRCheckBoxOptions = .custom(size: checkboxSize, backgroundColor: .clear)
let checkedOptions: MRCheckBoxOptions = .defaultCheck(checkboxSize)
checkButton.setImage(MRCheckBoxImage.image(with: unCheckOptions), for: .normal)
checkButton.setImage(MRCheckBoxImage.image(with: checkedOptions), for: .selected)
checkButton.addTarget(self, action: #selector(checkboxDidPress(_:)), for: .touchUpInside)
checkButton.isSelected = isSelected
}
private func setupLayouts() {
scrollView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
imageView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
checkButton.snp.makeConstraints { (make) in
make.right.bottom.equalToSuperview().offset(-10)
make.size.equalTo(checkboxSize)
}
view.setNeedsLayout()
}
private func resizeImageView() {
if let image = imageView.image {
let wradio = image.size.width / UIScreen.main.bounds.width
let hradio = image.size.height / UIScreen.main.bounds.height
let radio = max(wradio, hradio)
let size = image.size * (1/radio)
imageView.snp.remakeConstraints { (make) in
make.size.equalTo(size)
make.center.equalToSuperview()
}
}
}
private func addConfirmButton() {
let confirmBtn = UIButton(type: .custom)
confirmBtn.frame = CGRect(x: 0, y: 0, width: 50, height: 40)
confirmBtn.setTitle("确定", for: .normal)
confirmBtn.setTitleColor(.init(0x333333), for: .normal)
confirmBtn.addTarget(self, action: #selector(confirmButtonDidPress(_:)), for: .touchUpInside)
let item = UIBarButtonItem(customView: confirmBtn)
navigationItem.rightBarButtonItem = item
}
}
extension MRAlbumDetailViewController: UIScrollViewDelegate {
public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return imageView
}
}
......@@ -17,13 +17,19 @@ public enum MRAlbumListStatus {
case finish
}
public typealias MRAlbumDidSelect = (_ vc: MRAlbumListViewController, _ assests: [PHAsset]) -> Void
public typealias MRAlbumDidConfirm = (_ vc: MRAlbumListViewController, _ images: [UIImage], _ failedCount: Int) -> Void
public typealias MRAlbumDidCancel = (_ vc: MRAlbumListViewController) -> Void
open class MRAlbumListViewController: UIViewController {
private static let defaultNumberPreLine = 4
private static let defaultItemPadding: CGFloat = 1
open var maxCount = 1 {
didSet {
maxCountDidChange()
}
}
open var numbersPreLine = defaultNumberPreLine {
didSet {
resetItemSize()
......@@ -45,6 +51,7 @@ open class MRAlbumListViewController: UIViewController {
statusDidChange()
}
}
public var maxImageSize: CGSize?
public var assests: PHFetchResult<PHAsset>?
public var selectedAssests = [PHAsset]()
......@@ -67,7 +74,8 @@ open class MRAlbumListViewController: UIViewController {
return layout
}
public var didSelect: MRAlbumDidSelect?
public var didConfirm: MRAlbumDidConfirm?
public var didCancel: MRAlbumDidCancel?
open override func viewDidLoad() {
super.viewDidLoad()
......@@ -97,10 +105,40 @@ open class MRAlbumListViewController: UIViewController {
open func cellSetting(_ cell: UICollectionViewCell, at indexPath: IndexPath) {
if let cell = cell as? MRAlbumCell, let assest = assests?[indexPath.row] {
requestImage(with: assest, size: thumbImageSize * UIScreen.main.scale) { image, info in
cell.setImage(image)
requestImage(with: assest, size: thumbImageSize * UIScreen.main.scale) { image, isTemp in
if !isTemp {
cell.setImage(image)
}
}
cell.isSelected = selectedAssests.contains(assest)
weak var `self` = self
cell.check = { cell in
if let `self` = self {
self.didClickOnCellCheck(cell, at: indexPath)
}
}
}
}
open func didClickOnCellCheck(_ cell: UICollectionViewCell, at indexPath: IndexPath) {
if let selected = assests?.object(at: indexPath.row) {
if selectedAssests.contains(selected) {
selectedAssests.removeAll(where: { $0 == selected })
cell.isSelected = false
return
}
if selectedAssests.count >= maxCount {
return
}
selectedAssests.append(selected)
if !collectionView.allowsMultipleSelection {
confirm()
} else {
cell.isSelected = true
}
}
}
......@@ -127,21 +165,58 @@ open class MRAlbumListViewController: UIViewController {
}
}
open func maxCountDidChange() {
if maxCount <= 0 {
collectionView.allowsSelection = false
selectedAssests.removeAll()
} else {
collectionView.allowsSelection = true
collectionView.allowsMultipleSelection = maxCount > 1
let count = selectedAssests.count - maxCount
if count > 0 {
selectedAssests.removeLast(count)
}
}
collectionView.reloadData()
}
open func didSelectItem(_ collectionView: UICollectionView, at indexPath: IndexPath) {
collectionView.deselectItem(at: indexPath, animated: false)
if let assest = assests?[indexPath.row] {
let vc = MRAlbumDetailViewController()
vc.assest = assest
vc.isSelected = selectedAssests.contains(assest)
vc.imageCache = imageCache
vc.confirm = { vc, isSelected in
if isSelected, !self.selectedAssests.contains(assest) {
self.selectedAssests.append(assest)
} else if !isSelected {
self.selectedAssests.removeAll(where: { $0 == assest })
}
}
navigationController?.pushViewController(vc, animated: true)
}
}
@objc open func cancel() {
dismiss(animated: true)
didCancel?(self)
}
@objc open func confirm() {
didSelect?(self, selectedAssests)
dismiss(animated: true)
ToastView.loading()
requestImages(with: selectedAssests, size: maxImageSize) { (images, count) in
ToastView.hide(animate: false)
self.didConfirm?(self, images, count)
}
}
}
extension MRAlbumListViewController {
@discardableResult
public func requestImage(with assest: PHAsset, size: CGSize? = nil,
completion: @escaping (_ image: UIImage?, _ isTempImage: Bool) -> Void) -> PHImageRequestID {
public func requestImage(with assest: PHAsset,
size: CGSize? = nil,
inQueue: DispatchQueue = DispatchQueue.global(),
completion: @escaping (_ image: UIImage?, _ isTempImage: Bool) -> Void) {
let finish: (_ image: UIImage?, _ info: [AnyHashable: Any]?) -> Void = { image, info in
DispatchQueue.main.async {
......@@ -153,13 +228,16 @@ extension MRAlbumListViewController {
}
let options = PHImageRequestOptions()
options.isNetworkAccessAllowed = true
options.isSynchronous = true
if let size = size {
return imageCache.requestImage(for: assest, targetSize: size,
contentMode: .aspectFill, options: options, resultHandler: finish)
} else {
return imageCache.requestImage(for: assest, targetSize: PHImageManagerMaximumSize,
contentMode: .default, options: options, resultHandler: finish)
inQueue.sync {
if let size = size {
self.imageCache.requestImage(for: assest, targetSize: size,
contentMode: .aspectFill, options: options, resultHandler: finish)
} else {
self.imageCache.requestImage(for: assest, targetSize: PHImageManagerMaximumSize,
contentMode: .default, options: options, resultHandler: finish)
}
}
}
......@@ -189,7 +267,7 @@ extension MRAlbumListViewController {
DispatchQueue.main.async {
progress?(Float(count/assests.count))
if count <= 0 {
if count >= assests.count {
completion(images, failedCount)
}
}
......@@ -237,7 +315,8 @@ extension MRAlbumListViewController {
private func fetchImages() {
DispatchQueue.global().async {
let options = PHFetchOptions()
options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
options.sortDescriptors = [.init(key: "creationDate", ascending: false)]
options.predicate = NSPredicate(format: "mediaType = %d",PHAssetMediaType.image.rawValue)
self.assests = PHAsset.fetchAssets(with: .image, options: options)
......@@ -342,10 +421,6 @@ extension MRAlbumListViewController: UICollectionViewDataSource {
extension MRAlbumListViewController: UICollectionViewDelegate {
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectedAssests.append(assests!.object(at: indexPath.row))
if !collectionView.allowsMultipleSelection {
collectionView.deselectItem(at: indexPath, animated: false)
confirm()
}
didSelectItem(collectionView, at: indexPath)
}
}
//
// SAMutableSelectionAlbum.swift
// MRFramework
//
// Created by Sarkizz on 2019/9/6.
// Copyright © 2019 sarkizz. All rights reserved.
//
import Foundation
public class SAMutableSelectionAlbum: MRAlbumListViewController {
public var maxCount = 1 {
didSet {
resetSelection()
}
}
public var maxImageSize: CGSize?
public var didFinish: ((_ vc: SAMutableSelectionAlbum, _ images: [UIImage], _ failedCount: Int) -> Void)?
public var didCancel: ((_ vc: SAMutableSelectionAlbum) -> Void)?
public override func confirm() {
ToastView.loading()
requestImages(with: selectedAssests, size: maxImageSize) { (images, count) in
ToastView.hide(animate: false)
self.didFinish?(self, images, count)
}
}
public override func cellSetting(_ cell: UICollectionViewCell, at indexPath: IndexPath) {
super.cellSetting(cell, at: indexPath)
if let cell = cell as? MRAlbumCell {
cell.checkbox.isUserInteractionEnabled = false
}
}
public override func cancel() {
didCancel?(self)
}
}
extension SAMutableSelectionAlbum {
private func resetSelection() {
if maxCount <= 0 {
collectionView.allowsSelection = false
selectedAssests.removeAll()
} else {
collectionView.allowsSelection = true
collectionView.allowsMultipleSelection = maxCount > 1
let count = selectedAssests.count - maxCount
if count > 0 {
selectedAssests.removeLast(count)
}
}
collectionView.reloadData()
}
}
extension SAMutableSelectionAlbum {
public override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if selectedAssests.count >= maxCount {
collectionView.deselectItem(at: indexPath, animated: false)
return
}
selectedAssests.append(assests![indexPath.row])
if !collectionView.allowsMultipleSelection {
confirm()
}
}
public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
if let assest = assests?[indexPath.row] {
selectedAssests.removeAll(where: { $0 == assest })
}
}
}
......@@ -18,7 +18,7 @@ public enum SAPhotoPickerType {
}
public typealias SAPhotoPickerComplateBlock = (_ images: [UIImage]?, _ imageURLs: [URL]?, _ failedCount: Int, _ error: Error?) -> Void
public typealias SAPhotoPickerMutableSelectionAlbumSetting = (_ picker: SAPhotoPicker, _ vc: SAMutableSelectionAlbum) -> Void
public typealias SAPhotoPickerAlbumSetting = (_ picker: SAPhotoPicker, _ vc: MRAlbumListViewController) -> Void
extension SAPhotoPicker {
//config keys
......@@ -49,7 +49,7 @@ public class SAPhotoPicker: NSObject {
.editable: false
]
public var mutableSelectionAlbumSetting: SAPhotoPickerMutableSelectionAlbumSetting?
public var customAlbumSetting: SAPhotoPickerAlbumSetting?
private var imageMaxSize: CGSize?
private var complateBlock: SAPhotoPickerComplateBlock?
......@@ -103,11 +103,11 @@ extension SAPhotoPicker {
}
private func showCustomAlbum(_ count: Int) {
let vc = SAMutableSelectionAlbum()
let vc = MRAlbumListViewController()
vc.title = config[.albumTitle] as? String
vc.maxCount = count
vc.maxImageSize = imageMaxSize
vc.didFinish = { vc, images, count in
vc.didConfirm = { vc, images, count in
self.complateBlock?(images, nil, count, nil)
vc.dismiss(animated: true)
}
......@@ -115,7 +115,7 @@ extension SAPhotoPicker {
self.complateBlock?(nil, nil, 0, nil)
vc.dismiss(animated: true)
}
mutableSelectionAlbumSetting?(self, vc)
customAlbumSetting?(self, vc)
let nav = UINavigationController(rootViewController: vc)
UIApplication.shared.keyWindow?.rootViewController?.present(nav, animated: true, completion: nil)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment