diff --git a/Demo/DemoListViewController.swift b/Demo/DemoListViewController.swift index 7492821..93bae8b 100644 --- a/Demo/DemoListViewController.swift +++ b/Demo/DemoListViewController.swift @@ -117,7 +117,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController func showDisableToPickAssetsPicker() { let picker = NohanaImagePickerController() picker.delegate = self - picker.canPickAsset = { (asset:AssetType) -> Bool in + picker.canPickAsset = { (asset:Asset) -> Bool in return asset.identifier % 2 == 0 } present(picker, animated: true, completion: nil) diff --git a/NohanaImagePicker.podspec b/NohanaImagePicker.podspec index 9fe7a44..c08ce5c 100644 --- a/NohanaImagePicker.podspec +++ b/NohanaImagePicker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NohanaImagePicker' - s.version = '0.7.0' + s.version = '0.7.1' s.summary = 'A multiple image picker for iOS app.' s.homepage = 'https://github.com/nohana/NohanaImagePicker' s.license = { :type => 'Apache License v2', :file => 'LICENSE' } diff --git a/NohanaImagePicker/AssetCell.swift b/NohanaImagePicker/AssetCell.swift index d4fa91b..0215bdf 100644 --- a/NohanaImagePicker/AssetCell.swift +++ b/NohanaImagePicker/AssetCell.swift @@ -22,7 +22,7 @@ class AssetCell: UICollectionViewCell { @IBOutlet weak var overlayView: UIView! weak var nohanaImagePickerController: NohanaImagePickerController? - var asset: AssetType? + var asset: Asset? override func willMove(toSuperview newSuperview: UIView?) { super.willMove(toSuperview: newSuperview) @@ -52,7 +52,7 @@ class AssetCell: UICollectionViewCell { self.overlayView.isHidden = !pickButton.isSelected } - func update(asset: AssetType, nohanaImagePickerController: NohanaImagePickerController) { + func update(asset: Asset, nohanaImagePickerController: NohanaImagePickerController) { self.asset = asset self.nohanaImagePickerController = nohanaImagePickerController self.pickButton.isSelected = nohanaImagePickerController.pickedAssetList.isPicked(asset) diff --git a/NohanaImagePicker/ItemListType.swift b/NohanaImagePicker/ItemListType.swift index 633cf72..9be8a04 100644 --- a/NohanaImagePicker/ItemListType.swift +++ b/NohanaImagePicker/ItemListType.swift @@ -14,20 +14,20 @@ * limitations under the License. */ -public protocol ItemListType: Collection { +public protocol ItemList: Collection { associatedtype Item var title:String { get } func update(_ handler:(() -> Void)?) subscript (index: Int) -> Item { get } } -extension ItemListType { +extension ItemList { public func index(after i: Int) -> Int { return i + 1 } } -public protocol AssetType { +public protocol Asset { var identifier:Int { get } func image(targetSize:CGSize, handler: @escaping (ImageData?) -> Void) } diff --git a/NohanaImagePicker/NohanaImagePickerController.swift b/NohanaImagePicker/NohanaImagePickerController.swift index 26e7184..e679070 100644 --- a/NohanaImagePicker/NohanaImagePickerController.swift +++ b/NohanaImagePicker/NohanaImagePickerController.swift @@ -46,7 +46,7 @@ open class NohanaImagePickerController: UIViewController { open var shouldShowMoment: Bool = true open var shouldShowEmptyAlbum: Bool = false open var toolbarHidden: Bool = false - open var canPickAsset = { (asset:AssetType) -> Bool in + open var canPickAsset = { (asset:Asset) -> Bool in return true } lazy var assetBundle:Bundle = { @@ -127,11 +127,11 @@ open class NohanaImagePickerController: UIViewController { albumListViewController.nohanaImagePickerController = self } - open func pickAsset(_ asset: AssetType) { + open func pickAsset(_ asset: Asset) { _ = pickedAssetList.pick(asset: asset) } - open func dropAsset(_ asset: AssetType) { + open func dropAsset(_ asset: Asset) { _ = pickedAssetList.drop(asset: asset) } } diff --git a/NohanaImagePicker/PhotoKitAlbumList.swift b/NohanaImagePicker/PhotoKitAlbumList.swift index 73efeda..27d1011 100644 --- a/NohanaImagePicker/PhotoKitAlbumList.swift +++ b/NohanaImagePicker/PhotoKitAlbumList.swift @@ -15,7 +15,7 @@ */ import Photos -public class PhotoKitAlbumList: ItemListType { +public class PhotoKitAlbumList: ItemList { private var albumList:[Item] = [] private let assetCollectionTypes: [PHAssetCollectionType] @@ -37,7 +37,7 @@ public class PhotoKitAlbumList: ItemListType { } } - // MARK: - ItemListType + // MARK: - ItemList public typealias Item = PhotoKitAssetList diff --git a/NohanaImagePicker/PhotoKitAsset.swift b/NohanaImagePicker/PhotoKitAsset.swift index 768442b..4e7fc0c 100644 --- a/NohanaImagePicker/PhotoKitAsset.swift +++ b/NohanaImagePicker/PhotoKitAsset.swift @@ -15,7 +15,7 @@ */ import Photos -public class PhotoKitAsset :AssetType { +public class PhotoKitAsset :Asset { let asset: PHAsset @@ -27,7 +27,7 @@ public class PhotoKitAsset :AssetType { return asset as PHAsset } - // MARK: - AssetType + // MARK: - Asset public var identifier:Int { return asset.localIdentifier.hash diff --git a/NohanaImagePicker/PhotoKitAssetList.swift b/NohanaImagePicker/PhotoKitAssetList.swift index 15a5aad..338a432 100644 --- a/NohanaImagePicker/PhotoKitAssetList.swift +++ b/NohanaImagePicker/PhotoKitAssetList.swift @@ -16,7 +16,7 @@ import Photos -open class PhotoKitAssetList :ItemListType { +open class PhotoKitAssetList :ItemList { fileprivate let mediaType: MediaType open let assetList: PHAssetCollection @@ -28,7 +28,7 @@ open class PhotoKitAssetList :ItemListType { update() } - // MARK: - ItemListType + // MARK: - ItemList public typealias Item = PhotoKitAsset diff --git a/NohanaImagePicker/PickedAssetList.swift b/NohanaImagePicker/PickedAssetList.swift index 5d6b6be..1d70178 100644 --- a/NohanaImagePicker/PickedAssetList.swift +++ b/NohanaImagePicker/PickedAssetList.swift @@ -16,14 +16,14 @@ import Foundation -class PickedAssetList: ItemListType { +class PickedAssetList: ItemList { - var assetlist: Array = [] + var assetlist: Array = [] weak var nohanaImagePickerController: NohanaImagePickerController? - // MARK: - ItemListType + // MARK: - ItemList - typealias Item = AssetType + typealias Item = Asset var title: String { return "Selected Assets" @@ -49,7 +49,7 @@ class PickedAssetList: ItemListType { // MARK: - Manage assetlist - func pick(asset: AssetType) -> Bool { + func pick(asset: Asset) -> Bool { guard !isPicked(asset) else { return false } @@ -83,7 +83,7 @@ class PickedAssetList: ItemListType { } - func drop(asset: AssetType) -> Bool { + func drop(asset: Asset) -> Bool { let assetsCountBeforeDropping = self.count if asset is PhotoKitAsset { if let canDrop = nohanaImagePickerController!.delegate?.nohanaImagePicker?(nohanaImagePickerController!, willDropPhotoKitAsset: (asset as! PhotoKitAsset).originalAsset, pickedAssetsCount: assetsCountBeforeDropping) , !canDrop { @@ -109,7 +109,7 @@ class PickedAssetList: ItemListType { return true } - func isPicked(_ asset: AssetType) -> Bool { + func isPicked(_ asset: Asset) -> Bool { return assetlist.contains{ $0.identifier == asset.identifier } } diff --git a/README.md b/README.md index 4fa245e..3c28fba 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ picker.shouldShowMoment = shouldShowEmptyAlbum = true picker.shouldShowEmptyAlbum = true // Disable to pick asset -picker.canPickAsset = { (asset:AssetType) -> Bool in +picker.canPickAsset = { (asset:Asset) -> Bool in return false } @@ -76,7 +76,7 @@ ColorConfig.backgroundColor = UIColor.redColor() Use [Carthage](https://github.com/Carthage/Carthage). - Add `github "nohana/NohanaImagePicker"` to your Cartfile. - - If you want to use Swift2.3, add `github "nohana/NohanaImagePicker", "0.6.0"` instead. + - If you want to use Swift2.3, add `github "nohana/NohanaImagePicker", "0.6.1"` instead. - If you want to use Swift2.2, add `github "nohana/NohanaImagePicker", "0.5.0"` instead. - Run `carthage update`. @@ -91,7 +91,7 @@ Use [CocoaPods](https://cocoapods.org/). pod "NohanaImagePicker" ``` - - If you want to use Swift2.3 write `pod "NohanaImagePicker", "0.6.0"` instead of `pod "NohanaImagePicker"`. + - If you want to use Swift2.3 write `pod "NohanaImagePicker", "0.6.1"` instead of `pod "NohanaImagePicker"`. - Run `pod install`.