-
Notifications
You must be signed in to change notification settings - Fork 0
Kotlin DSL Component #95
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good, just had a couple questions. I'm wondering if there's a way to abstract out blocks like this:
title?.let {
setTitle(it)
} ?: run {
titleRes?.let {
setTitle(it)
}
}
I'm guessing there is, just wondering how to do it and make it understandable.
} | ||
|
||
content?.let { | ||
setTitle(it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be setMessage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch 👍
setTitle(it) | ||
} ?: run { | ||
contentRes?.let { | ||
setTitle(it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same here?
I couldn't figure out a better native way with scope functions, so I created a "quartus" extension function to simplify this, let me know your thoughts about it.
|
fun Fragment.dialog(setup: DialogBuilder.() -> Unit) { | ||
val builder = DialogBuilder(requireContext(), setup = setup) | ||
builder.build().show() | ||
private fun <T, U> Any.ternary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesss! Clever (in a good way)!
One Line Summary
Creating a component through the use of Kotlin DSL.
Issue(s) Addressed
Closes #90
Steps to Reproduce/Test
From the Home Screen Click on the "Dsl Dialog" menu, and a very generic Dialog should appear.
Checklist