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

Possibility to deselect assets when displaying picker for second time. #69

Closed
wants to merge 3 commits into from

Conversation

krodak
Copy link

@krodak krodak commented Feb 4, 2016

Added possibility to deselect assets when showing picker multiple times.

If DKImagePickerController is used in some VC multiple time it might be useful sometimes to clear selection on each use. Currently, if I want to show clean selection I'd need to create new instance of image picker, which is not memory efficient.

Use case:
There is VC to add new images with some custom titles, etc to 'posts feed'. User can choose maximum X posts, but he can display picker multiple time. As each time all selected photos are used in application VC, picker should show no selection each time it's shown.

If DKImagePickerController is used in some VC multiple time it might be useful sometimes to clear selection on each use.
i.e. There is VC to add new images with some custom titles, etc to 'posts feed'. User can choose maximum X posts, but he can display picker multiple time. As each time all selected photos are used in application VC, picker should show no selection each time it's shown.
If DKImagePickerController is used in some VC multiple time it might be useful sometimes to clear selection on each use.
i.e. There is VC to add new images with some custom titles, etc to 'posts feed'. User can choose maximum X posts, but he can display picker multiple time. As each time all selected photos are used in application VC, picker should show no selection each time it's shown.
@krodak
Copy link
Author

krodak commented Feb 4, 2016

@zhangao0086 I'm not sure whether this is the best approach, but I needed this one for my project.

@zhangao0086
Copy link
Owner

Thanks @krodak !
I already understand your needs and it's necessary function!!!
I've made a new commit that's trying to solve the problem:0e23cd6. Maybe its better :)

@zhangao0086 zhangao0086 closed this Feb 4, 2016
@krodak
Copy link
Author

krodak commented Feb 4, 2016

@zhangao0086 I see advantage of your approach but if I understand correctly, programmer needs to clear selection each time he shows image picker.
With mine approach you can just set it per instance - do you think this approach could be taken to yours? :-) Usually, when you create image picker for the use in specific VC and case, it will be used in consistent way, so those kind of settings would be nice to have per instance.

@zhangao0086
Copy link
Owner

@krodak
Yes, you're right. That case is very common. But I prefer to make a subclass like this:

public class DKMomentaryImagePickerController: DKImagePickerController {

    /// This allows to clear @selectedAssets without creating new picker each time
    public var shouldDeselectAssets: Bool = false

    override public func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        if shouldDeselectAssets {
            self.defaultSelectedAssets = nil
        }
    }

}

It will be quite easy to expand and not depend on the specific scene. What do you think?

@krodak
Copy link
Author

krodak commented Feb 4, 2016

Sounds great!
On Thu, 4 Feb 2016 at 23:32, Bannings [email protected] wrote:

@krodak https://github.com/krodak
Yes, you're right. That case is very common. But I prefer to make a
subclass like this:

public class DKMomentaryImagePickerController: DKImagePickerController {

/// This allows to clear @selectedAssets without creating new picker each time
public var shouldDeselectAssets: Bool = false

override public func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    if shouldDeselectAssets {
        self.defaultSelectedAssets = nil
    }
}

}

It will be quite easy to expand and not depend on the specific scene. What
do you think?


Reply to this email directly or view it on GitHub
#69 (comment)
.

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