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

Anko support #23

Closed
fmatosqg opened this issue Apr 15, 2018 · 2 comments
Closed

Anko support #23

fmatosqg opened this issue Apr 15, 2018 · 2 comments

Comments

@fmatosqg
Copy link

Hi,

Any ideas on how to plug it with Kotlin Anko library? I tend to use it and skip data binding, so not sure how I'd put the annotations.

@wellingtoncosta
Copy link
Owner

Hi, @fmatosqg. It seems like a good idea, but I never worked with Anko and don't quite know how it works, but I will learn more about it and analyse if is possible to provide support to use the Convalida with Anko.

@wellingtoncosta
Copy link
Owner

I was sawing the Anko example on the GitHub repository:

verticalLayout {
    val name = editText()
    button("Say Hello") {
        onClick { toast("Hello, ${name.text}!") }
    }
}

And I think the solution below works:

@RequiredValidation
lateinit var name: EditText

@ValidateOnClick
lateinit var validateButton: Button

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    verticalLayout {
        name = editText()
        validateButton = button("Say Hello")
    }

    SampleActiityFieldsValidation.init(this) // the generated class
}

@OnValidationSuccess
fun success() = Toast.makeText(this, "${name.text}", Toast.LENGTH_LONG).show()

Can you try it?

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

No branches or pull requests

2 participants