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

Input Bottom Sheet - Ability to disable positive button programatically #20

Closed
russellbanks opened this issue Dec 27, 2020 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@russellbanks
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I've been migrating from Aiden Follestad's bottom sheets to this library and one thing I was able to do from that was if an input is incorrect, I could disable the positive button. For example, I need to ensure in my app that the input does not contain the characters "//". I had achieved this previously by doing:
if input.contains("//") { dialog.getActionButton(WhichButton.POSITIVE).isEnabled = false }

Describe the solution you'd like
The ability to disable the positive button programatically

@russellbanks russellbanks added the enhancement New feature or request label Dec 27, 2020
@maxkeppeler
Copy link
Owner

The Issue is requesting basically the same as the issue #21 if I see that correctly. I don't think it's necessary to allow disabling / hiding the positive button, but to define if the current input is valid. If it is valid, alongside all the other inputs, the positive button will be displayed, or when not it won't be displayed.

fun isInputValid(inputText: String): Boolean {
 return inputText.contains("//") // if true, positive button will be displayed, otherwise not.
}

Would this work how you imagine it? For custom bottom sheet implementations, the visibility of the buttons can be changed. But I think it would be easier if developers could just specify the validation logic & hint/ error messages if it's not valid.
Let me know your opinion!

@russellbanks
Copy link
Contributor Author

This functionality to verify an input would be perfect, thank you!

@maxkeppeler
Copy link
Owner

With the coming version, check the sample setup - I added a password example with the InputSheet with custom validation logic. That's how it will look.

InputSheet().show(this) {
            ...
            with(InputEditText {
                ...
                endIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE)
                passwordVisible(false /* Don't display password in clear text. */)
                validationListener { value ->
                    val valid = <Add custom validation logic>
                    if (valid) Validation.success()
                    else Validation.failed("Custom error text")
                }
                ...
            })
            ...
}

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

No branches or pull requests

2 participants