diff --git a/README.md b/README.md index 9c48f9c8..c5c7c6f3 100644 --- a/README.md +++ b/README.md @@ -295,10 +295,16 @@ public struct TLPhotosPickerConfigure { public var fetchCollectionTypes: [(PHAssetCollectionType,PHAssetCollectionSubtype)]? = nil public var groupByFetch: PHFetchedResultGroupedBy? = nil // cannot be used prefetch options public var supportedInterfaceOrientations: UIInterfaceOrientationMask = .portrait + public var popup: [PopupConfigure] = [] public init() { } } +public enum PopupConfigure { + //Popup album view animation duration + case animation(TimeInterval) +} + // PHFetchedResultGroupedBy // // CGrouped by date, cannot be used prefetch options diff --git a/TLPhotoPicker.podspec b/TLPhotoPicker.podspec index 44d7ff5e..7fcd6789 100644 --- a/TLPhotoPicker.podspec +++ b/TLPhotoPicker.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'TLPhotoPicker' - s.version = '1.9.3' + s.version = '1.9.4' s.summary = 'multiple phassets picker for iOS lib. like facebook' # This description is used to generate tags and improve search results. diff --git a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift index 07b20948..0eda51b1 100644 --- a/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift +++ b/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift @@ -82,18 +82,20 @@ public struct TLPhotosPickerConfigure { public var fetchCollectionTypes: [(PHAssetCollectionType,PHAssetCollectionSubtype)]? = nil public var groupByFetch: PHFetchedResultGroupedBy? = nil public var supportedInterfaceOrientations: UIInterfaceOrientationMask = .portrait + public var popup: [PopupConfigure] = [] public init() { } } +public enum PopupConfigure { + case animation(TimeInterval) +} public struct Platform { - public static var isSimulator: Bool { return TARGET_OS_SIMULATOR != 0 // Use this line in Xcode 7 or newer } - } @@ -415,7 +417,7 @@ extension TLPhotosPickerViewController { self.focusedCollection?.fetchResult = self.photoLibrary.fetchResult(collection: collection, configure: self.configure) reloadIndexPaths.append(IndexPath(row: getfocusedIndex(), section: 0)) self.albumPopView.tableView.reloadRows(at: reloadIndexPaths, with: .none) - self.albumPopView.show(false, duration: 0.2) + self.albumPopView.show(false, duration: self.configure.popup.duration) self.updateTitle() self.reloadCollectionView() self.collectionView.contentOffset = collection.recentPosition @@ -431,7 +433,7 @@ extension TLPhotosPickerViewController { // User Action @objc func titleTap() { guard collections.count > 0 else { return } - self.albumPopView.show(self.albumPopView.isHidden) + self.albumPopView.show(self.albumPopView.isHidden, duration: self.configure.popup.duration) } @IBAction open func cancelButtonTap() { @@ -1084,3 +1086,15 @@ extension TLPhotosPickerViewController: UITableViewDelegate,UITableViewDataSourc return cell } } + +extension Array where Element == PopupConfigure { + var duration: TimeInterval { + var result: TimeInterval = 0.1 + self.compactMap{ $0 as? PopupConfigure }.forEach{ + if case let .animation(duration) = $0 { + result = duration + } + } + return result + } +}