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

Prevent the done button from dismissing automatically the popover #121

Open
josselin-oudry opened this issue May 29, 2019 · 0 comments
Open

Comments

@josselin-oudry
Copy link

Hi there,

Thanks for making this great pod. We have a use case where we set the very first item of the popover datasource with an empty row because we do not want to have a default selected row. This is to make sure that the user consciously picks an option. Now if the Done button is tapped while the first row is selected we just want to display an error banner on top of the screen but NOT dismiss the popover.

I could not find a way to override the behaviour of setDoneButton so that on a particular condition is does NOT dismiss the popover. So for now even though this is not ideal because of the induced flickering effect I am doing this:

myPickerPopover
        .setSelectedRow(0)
        .setDoneButton(title: "OK"),
                       action: { popover, selectedRow, selectedID in

            if selectedRow == 0 {

                self.presentToast("Please select an option")

                popover
                .disappear(completion: {
                    popover.appear(originView: originView, baseViewController: self)
                })

            } else {

                self.pushSomeViewController(
                    with: selecteID)
            }
        })
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

No branches or pull requests

1 participant