https://kotlinlang.org logo
Title
s

SrSouza

11/08/2020, 4:55 PM
Hi folks, I want to share the project that I'm working on focus mainly in Compose for Desktop because it does not support Vectors yet, no SVG, no Android's Vector Drawable. So a create a simple project to convert SVG and Android's Vector Drawable to Compose code. https://github.com/DevSrSouza/svg-to-compose For now, this will help port simple vectors and icon packs to Compose for Desktop, allowing you to share it with Desktop and Android app. Here you can see the Jetnews Logo in the Compose for Desktop version
🎉 17
j

jim

11/08/2020, 5:04 PM
Cool project! In the early days of thinking about how to support SVG in Compose, converting them to composables was an approach we considered. One of the benefits is that they become very easy to parameterize and can support arbitrary behaviors (ie. once the SVG is in Kotlin, you have the full power of Kotlin available). The downside was that designers work with SVG files, and when they make a change to the graphic, merging that back into modified Kotlin code is messy. If the argument is that the Kotlin code should never be modified, then the question becomes "well why didn't you just load the vector graphic from the SVG file then?". Anyway, food for thought. I wonder if a path of less resistance might be to contribute a change that adds support in Compose Desktop. Compose is open source, after all, and most of the loading code is already there in aosp for Android.
👍 1
That said, if your current approach is a preferred direction for you, by all means, I don't want to discourage your explorations. Perhaps you'll find benefits we didn't think of! Thanks for sharing!
j

Javier

11/08/2020, 5:17 PM
@jim then SVG support is planned? (without android drawables)
j

jim

11/08/2020, 5:20 PM
Yeah, I think likely both SVG and android drawables will be supported eventually. Just a matter of prioritization. Compose is open source and community contributions can help accelerate the process. We would happily accept a CL/PR that adds support.
👍 3
s

SrSouza

11/08/2020, 5:24 PM
Tkx @jim. I agree with that this is not a good approach for files that will frequently be changed. Currently was the fastest way that I can think to support svg and drawables in Compose for Desktop. The use case that I see in long term is for icon pack tooling, I really like the way that we use Material Icons in Compose and that could be expanded to any icon pack available, for example, Linea icon.
c

caelum19

11/09/2020, 10:44 AM
If the reverse conversion were implemented it could be a pretty great workflow for designers - could even have variable inputs that can be configured in the design tool, would be easy enough to make a figma plugin for
👀 1