Skip to content

Commit

Permalink
added configure for popup
Browse files Browse the repository at this point in the history
  • Loading branch information
tilltue committed Aug 9, 2019
1 parent bdb091f commit 6fa3878
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion TLPhotoPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 18 additions & 4 deletions TLPhotoPicker/Classes/TLPhotosPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}


Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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
}
}

0 comments on commit 6fa3878

Please sign in to comment.