Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

nayaks2019
Copy link

…sed for ObjectiveC

1.Exposed few params to ObjectiveC
2.Added callback for selectionLimitReach as the delegate never worked.

…sed for ObjectiveC

1.Exposed few params to ObjectiveC
2.Added callback for selectionLimitReach as the delegate never worked.
@mikaoj
Copy link
Owner

mikaoj commented Jul 17, 2020

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.
Otherwise I'll end up having a bunch of different closures in the common api that most people will never use.
It might be a bad idea, but it's what I've got right now :)

Would you mind just fixing the bug that the delegate is never called on reaching max instead of adding more closures?

…erControllerDelegate and few Settings parameters to objectiveC

mikaoj#1.didReachSelectionLimit was not getting called-Fixed
mikaoj#2.Exposed some parameters of settings to ObjectiveC.
mikaoj#3.Exposed  ImagePickerControllerDelegate to objective C
@nayaks2019
Copy link
Author

@mikaoj -Found out why the delegate method was not getting called and fixed and pushed the changes in the above pull request.
Please review and approve.

@nayaks2019
Copy link
Author

@mikaoj -Did you get a chance to look at this pull request?.I made the required changes.Please review and Let me know

Copy link
Owner

@mikaoj mikaoj left a 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 :)

@@ -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
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

let start = Date()
self.presentImagePicker(imagePicker, select: { (asset) in
Copy link
Owner

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.

Copy link
Author

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 {
Copy link
Owner

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?

Copy link
Author

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) {
Copy link
Owner

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.

Copy link
Author

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)?,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Author

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Author

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)?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove what?

@objc public lazy var unselectOnReachingMax : Bool = false

/// If it reaches the max limit, notify
@objc public lazy var notifyReachingMaxLimit : Bool = false
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

mikaoj#1.Removed all white spaces
mikaoj#2.Changed the name  from notifyReachingMaxLimit  to onReachMaxSelectionLimit
@mikaoj mikaoj closed this Sep 26, 2020
@nayaks2019
Copy link
Author

@mikaoj hey I am wondering why it is not merged?is there any concern?

@mikaoj
Copy link
Owner

mikaoj commented Sep 29, 2020

Something might have got lost in translation, but I tried to explain that I didn't want the closures but only the delegate.

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.
Otherwise I'll end up having a bunch of different closures in the common api that most people will never use.
It might be a bad idea, but it's what I've got right now :)

Would you mind just fixing the bug that the delegate is never called on reaching max instead of adding more closures?

But you kept the closures. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants