Is there any way to use the views dsl without cons...
# splitties
p
Is there any way to use the views dsl without constantly invoking
add()
for nesting
Copy code
verticalLayout {
        add(textView {
            textResource = R.string.some_text
        }, lParams())
}
Coming from other dsl’s it feels a bit cumbersome to me, I’d expect to be able to write something like
Copy code
verticalLayout {
    textview {
        textResource = R.string.some_text
    }
}
Am I missing something? I don’t have much experience with android
r
That other way may feel simpler but also hides more operations and gives you less freedom
1
l
@patrickdelconte After over 2 years, this is still the best I've got without messing with the compiler or dooing some unmaintainable hack. I'm not unhappy with it though, I like to know when the view is being added. I usually keep my views in private properties in the
Ui
implementations, so there's the declaration of the views, and then the layout in
root
initialization or in an
init
block. FYI, Anko Layouts didn't have
add
, but it meant being less flexible when it comes to custom views, viewgroups and their layout parameters, and wya bigger runtime, while Splitties runtime is almost nonexistent given most of it is inlined.
m
What about annotating all View-returning methods with
@CheckResult
?
l
That's a good idea, can you open an issue for that?