https://kotlinlang.org logo
#compose
Title
# compose
x

xxfast

05/26/2022, 1:09 AM
Is there a nice way to convert `.svg`s to `@Composable`s?
2
n

Nick

05/26/2022, 2:12 AM
Is this more efficient than an svg
t

tad

05/26/2022, 3:42 AM
Compared to what?
coil-svg
?
c

Chris Sinco [G]

05/26/2022, 4:57 AM
Curious what is your use case for converting the SVGs to Composables? Theming, animation?
1
x

xxfast

05/26/2022, 6:28 AM
mostly theming/localisation
o

Oleksandr Balan

05/26/2022, 6:47 AM
I guess localisation could be solved with drawables and qualifiers, but yeah, theming I think do not work. I was wondering recently if it is possible to create own
AndroidVectorParser
which will “map”
?colorPrimary
(and others) attributes to used in MaterialTheme inside Compose 🤔 So that we could apply dynamic color to images https://m3.material.io/styles/color/dynamic-color/imagery
c

Colton Idle

05/26/2022, 12:33 PM
Doesn't the importer in Android studio convert from svg to a drawable-svg (or w/e its called).
o

Oleksandr Balan

05/26/2022, 12:36 PM
Default AS importer converts SVG to vector drawables, but OP wants image vectors, such as for example
Icons.Default.AccountCircle
is made
c

Chris Sinco [G]

05/26/2022, 4:29 PM
Gotcha, theming makes sense. I’m guessing then it’s tinting specific parts of an icon and not the whole thing all up?
Yes the Studio tool only does SVG -> Vector Drawable
But… we are exploring adding functionality to do SVG/VD -> Composable conversion. Basically shipping the same logic that builds the Material icons library into a tool in Studio
👌 1
👀 3
💯 4
t

tad

05/26/2022, 4:32 PM
I built a Gradle plugin to do it for our project. I can throw up a gist later
👀 4
🙏 1
c

Chris Sinco [G]

05/26/2022, 4:38 PM
Ohhh that would be cool to see. I can forward it to the team as well for consideration.
387 Views