-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectionLimitReach callback added with few important params now expo… #286
Conversation
…sed for ObjectiveC 1.Exposed few params to ObjectiveC 2.Added callback for selectionLimitReach as the delegate never worked.
Thanks for taking the time to help out, but I don't think I'll be able to merge this PR. The idea behind the delegate was to have the closure api simple and covering the most common use cases and let user who wanted more 'advanced' features use the delegate. Would you mind just fixing the bug that the delegate is never called on reaching max instead of adding more closures? |
@mikaoj -Found out why the delegate method was not getting called and fixed and pushed the changes in the above pull request. |
@mikaoj -Did you get a chance to look at this pull request?.I made the required changes.Please review and Let me know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to add this. But the PR could probably do with a little cleaning :)
Example/ViewController.swift
Outdated
@@ -31,21 +31,22 @@ class ViewController: UIViewController { | |||
imagePicker.settings.selection.max = 5 | |||
imagePicker.settings.theme.selectionStyle = .numbered | |||
imagePicker.settings.fetch.assets.supportedMediaTypes = [.image, .video] | |||
imagePicker.settings.selection.unselectOnReachingMax = true | |||
|
|||
// imagePicker.settings.selection.unselectOnReachingMax = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't comment out code. Maybe create a new example that uses the delegate instead of closures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
Example/ViewController.swift
Outdated
let start = Date() | ||
self.presentImagePicker(imagePicker, select: { (asset) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes here seem to be whitespace/indentation? Don't commit stuff like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@@ -31,6 +31,11 @@ extension ImagePickerController: AssetsViewControllerDelegate { | |||
imagePickerDelegate?.imagePicker(self, didDeselectAsset: first) | |||
} | |||
} | |||
else if settings.selection.notifyReachingMaxLimit && assetStore.count > settings.selection.max { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here seems wrong. Firstly it should probably be an if instead of an else if as a user can have both notify and unselect set to true.
And I don't think we should do any asset removal or unselection in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed else if to if.
Remove and unselect has to be there.Because-
Suppose maxselection is 2
When didSelectAsset gets called when we are on 3rd selection, then only this loop will get executed.so that asset has to be removed.If we are not removing that asset.then we will have 3 assets selected instead of 2 assets.
@@ -37,14 +37,13 @@ import Photos | |||
/// - cancel: Cancel callback | |||
/// - finish: Finish callback | |||
/// - completion: Presentation completion callback | |||
public func presentImagePicker(_ imagePicker: ImagePickerController, animated: Bool = true, select: ((_ asset: PHAsset) -> Void)?, deselect: ((_ asset: PHAsset) -> Void)?, cancel: (([PHAsset]) -> Void)?, finish: (([PHAsset]) -> Void)?, completion: (() -> Void)? = nil) { | |||
public func presentImagePicker(_ imagePicker: ImagePickerController, animated: Bool = true, select: ((_ asset: PHAsset) -> Void)?, deselect: ((_ asset: PHAsset) -> Void)?, cancel: (([PHAsset]) -> Void)?, finish: (([PHAsset]) -> Void)?,completion: (() -> Void)? = nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't commit whitespace/indentation changes. The log will be horrible if every committer does that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@@ -64,6 +63,7 @@ import Photos | |||
} | |||
} | |||
} | |||
//selectionLimitReach: ((_ count:Int) -> Void)?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@@ -90,6 +90,6 @@ extension ImagePickerController: ImagePickerControllerDelegate { | |||
} | |||
|
|||
public func imagePicker(_ imagePicker: ImagePickerController, didReachSelectionLimit count: Int) { | |||
|
|||
onReachMaxSelectionLimit?(count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove what?
@@ -49,7 +49,7 @@ import Photos | |||
var onDeselection: ((_ asset: PHAsset) -> Void)? | |||
var onCancel: ((_ assets: [PHAsset]) -> Void)? | |||
var onFinish: ((_ assets: [PHAsset]) -> Void)? | |||
|
|||
var onReachMaxSelectionLimit: ((_ count: Int) -> Void)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove what?
Sources/Model/Settings.swift
Outdated
@objc public lazy var unselectOnReachingMax : Bool = false | ||
|
||
/// If it reaches the max limit, notify | ||
@objc public lazy var notifyReachingMaxLimit : Bool = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow the naming of the previous property...maybe change to notifyOnReachingMax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@mikaoj hey I am wondering why it is not merged?is there any concern? |
Something might have got lost in translation, but I tried to explain that I didn't want the closures but only the delegate.
But you kept the closures. :) |
…sed for ObjectiveC
1.Exposed few params to ObjectiveC
2.Added callback for selectionLimitReach as the delegate never worked.