Skip to content

Commit

Permalink
confirm button enable status
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyuexit committed Jan 18, 2018
1 parent 8131dc1 commit 157753f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LPAlbum/Controllers/LPAlbum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class LPAlbum: UIViewController {
fileprivate var collectionView: UICollectionView!
fileprivate var titleView: TitleView!
fileprivate var menuView: DropMenuView!
fileprivate var confirmItem: UIBarButtonItem!

fileprivate var currentAlbumIndex: Int = 0
fileprivate var albumModels = [AlbumModel]()
Expand Down Expand Up @@ -135,6 +136,8 @@ extension LPAlbum {
func setupUI() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: String.local("取消"), style: .plain, target: self, action: #selector(cancel))
navigationItem.rightBarButtonItem = UIBarButtonItem(title: String.local("完成"), style: .plain, target: self, action: #selector(confirm))
navigationItem.rightBarButtonItem!.isEnabled = false
confirmItem = navigationItem.rightBarButtonItem!

titleView = TitleView(frame: .zero)
navigationItem.titleView = titleView
Expand Down Expand Up @@ -272,12 +275,14 @@ extension LPAlbum: UICollectionViewDelegate, UICollectionViewDataSource {
}

func checkoutCount(willselect: Bool, asset: PHAsset? = nil, show vc: UIViewController) -> Bool {

if self.config.maxSelectCount == self.selectedAssets.count && willselect {
self.errorBlock?(vc,AlbumError.moreThanLargestChoiceCount)
return false
}
guard let asset = asset else { return true }
if willselect { self.selectedAssets.append(asset) } else { _ = self.selectedAssets.remove(asset) }
confirmItem.isEnabled = self.selectedAssets.count > 0
return true
}
}
Expand Down

0 comments on commit 157753f

Please sign in to comment.