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
Support library difficulties and ugliness #66
Comments
@graknol I tried to make a discussion about it some time ago - #29 There are a few constraints:
Of course, this is an easy option to leave it all to the end user, who is always welcome to wrap layouts into friendlier function names, e.g. you can always make an alias for your button as:
|
@zserge hmm, it's not an easy feat. I'll see if I can write a kotlin (as that's what I'm using) wrapper for the DSL (kinda a DSL for a DSL lol), handwritten to route the calls to the correct library depending on the view type. It will take some time, but I'd rather write this library than having to write |
That would be awesome! I'm sure there is no generic solution to this in Java which lacks traits so much. There is a number of name conflicts between base DSL and support DSL - in both, view names and property setters. And I'm strongly reluctant to giving custom (unpredictable) names to views, because the benefit of Anvil is that you already know the DSL - just use property or view names from the SDK in camel-case and without "set" prefix. The only exception so far has been "switchView", because "switch" is a keyword in both Java and Kotlin. Again, I'm pretty happy with writing DSL class names in Java, because Java is verbose anyway, so excplicit is better than implicit. I tend to wrap common repeatitive parts into small functions, so I don't notice that I type it too often. Kotlin is different in its style, so a good-looking wrapper is more than welcome. |
@zserge Care to explain what the return type |
@graknol Sure, each view has two types of "builder" functions. When lambdas are available (Java 8, Kotlin) the lambda function should be used, e.g. When lambdas are not available one can still use Anvil like:
For Kotlin-only it's safe to wrap lambda methods only. Answering your question, |
Ahhh I see, that's really clever :) Well, I've completed the BaseDSL class, modified your generator (ugly as h***, but works for manual work, haha). And am currently in the process of writing a converter in python, crossing fingers I'll be able to do it :) |
Also, the DSL functions aren't supposed to be used outside of a |
@graknol Exactly, all DSL functions must be called only within |
So I finished the core wrapper (the support libraries can be done the same way, but I want to have some better form for automation in place, will probably have to write a |
Hi, I love this library so far, it's so refreshing! But, there is one thing holding me back and making me wanna go back to XML, which is that the appcompat-v7 and support-v4 DSLs have conflicting methods with the core DSL. Also, it kills me that we have to write
appCompatButton
instead of justbutton
and have it automatically use the appropriate version.I would gladly work with someone on the issue (I'm not too good at making APIs on my own, hehe).
Thanks in advance,
Graknol
The text was updated successfully, but these errors were encountered: