Skip to content

Commit

Permalink
Delegate callback when reaching max selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaoj committed Sep 26, 2020
1 parent d45aea7 commit 5485840
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/Controller/ImagePickerController+Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ extension ImagePickerController: AssetsViewControllerDelegate {
}
updatedDoneButton()
imagePickerDelegate?.imagePicker(self, didSelectAsset: asset)

if assetStore.count >= settings.selection.max {
imagePickerDelegate?.imagePicker(self, didReachSelectionLimit: assetStore.count)
}
}

func assetsViewController(_ assetsViewController: AssetsViewController, didDeselectAsset asset: PHAsset) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Model/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Photos
public lazy var min: Int = 1

/// If it reaches the max limit, unselect the first selection, and allow the new selection
public lazy var unselectOnReachingMax : Bool = false
@objc public lazy var unselectOnReachingMax : Bool = false
}

public class List : NSObject {
Expand Down

0 comments on commit 5485840

Please sign in to comment.