icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.12k stars 125 forks source link

Support for camelCase generation #404

Open mustafaozhan opened 1 year ago

mustafaozhan commented 1 year ago

Currently, when we have a resource, the generated variable name in Kotlin file is same as the one in xml.

Currently: ie. I have a string defined in xml <string name="name_of_string">Some string</string> and we reach it in Kotlin and Swift code with same name, respectively MR.strings.name_of_string, MR.strings().name_of_string

We should generate them in camelCase which respect to the naming convention, ie. Android ViewBinding does this for ids, or from KMP world sqldeleight does it for table names.

so expected way to reach resources in Kotlin and Swift codes should be respectively MR.strings.nameOfString, MR.strings().nameOfString

Alex009 commented 1 year ago

we can add flag for it in gradle config

mustafaozhan commented 1 year ago

I think that would work! Thank you 🙂

ExNDY commented 6 months ago

I think that will be very sensitive, because for: same_values_of_string and sameValuesOfString we get identical property: sameValuesOfString. When i'm rewrite generation, when that happines kotlin poet simply lose one of values. I'm not sure of that good flag for plugin.