I’m trying out compose multiplatform resources, bu...
# compose
a
I’m trying out compose multiplatform resources, but seeing a few missing features that MOKO resources provides such as support for colors and SVGs. MOKO uses
com.android.ide.common.vectordrawable.Svg2Vector
to transform SVGs. It’s a lot more convenient that manually importing them, which isn’t supported in the shared module anyway. https://github.com/icerockdev/moko-resources/blob/master/resources-generator/src/m[…]/dev/icerock/gradle/generator/android/AndroidImagesGenerator.kt
🙌 1
👀 1
1
i
cc @Konstantin Tskhovrebov
a
I know it’s fairly common to define colors in compose code, but having resources is useful for sharing it with android themes (navigation bar and status bar colors)
k
I believe it should be an ide feature to propose to user convert svgs to xml format. As it's done in Android studio IIRC. First of all, not every svg can be converted to xml icon. And users may want to have svgs in the project anyway to display them with external libraries
You cannot use the same resources for the compose multiplatform and for android API. They have different types
a
ah so they aren’t translated to android resources, as in the don’t translated to references in R.java?
🚫 1
k
@Florian Kistner [JB]
a
that’s good to know 🙂
o
Hi! Are there any updates on themed colors for drawable multiplatform resources in Compose? @Konstantin Tskhovrebov For example: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1724493674688489
a
I wrote a small plugin to do it, but it's embedded into our monorepo. It hooks into the compose resources plugin
o
For both day and night themes?
a
Yea
Or custom
However I wanted to improve it more for custom themes
I doubt it'll ever see the light of day though, company isn't keen on open source 🙈
Let's just say I got a little carried away experimenting with convention plugins and wanted to test the waters with XML parsing and KotlinPoet 😂
o
Let's at least create an issue! 😉
a
good idea 😅
I also added an SVG to AVD converter in the plugin
🙌 1
using SvgToVector, soI dump them here
then it would generate them here, prior to compose resources running
this was a bigger time saver than the colors, the colors was just a nice to have more than anything
I used the MOKO plugin as reference, but it diverged a lot as MOKO is way more complex and feature complete (exports the resource for use on the native side as well)