moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

VectorDrawable

Open cl3m opened this issue 3 years ago • 4 comments

Thank you for this great library!

I have two suggestions for the drawables:

First, you should add the xml extension support with would allow to share VectorDrawable in android and iOS (with the library https://github.com/uber/cyborg)

Second, you should allow the images in the android structure instead of @2x @3x etc. The rest are android file format and it would be more consistent. Moreover that it would allow to just move android resource to kotlin multi platform resource.

cl3m avatar Jan 20 '21 08:01 cl3m

For backward compatibility, you can keep the images folder and allow the new folders that works the other way:

  • drawable (xml)
  • drawable-mdpi (png/jpg)
  • drawable-xxhdpi(png/jpg)
  • drawable-hdpi (png/jpg)
  • drawable-xhdpi (png/jpg)
  • drawable-xxxhdpi(png/jpg)

cl3m avatar Jan 20 '21 08:01 cl3m

hi! thanks. vector images issue here #29 , you can move your info about cyborg to this issue. but we have no plan to implement it in near future...maybe you want do it? in this case i can support it by share own knowledge about plugin and runtime lib

about second - we have not goal "just move android resources", so maybe implement same structure later. name drawable will be invalid because we support only images, not xml drawables, and on iOS not exist any drawable at all.

Alex009 avatar Jan 20 '21 08:01 Alex009

I don't know much about plugins yet so maybe not soon but I'll look into it if you don't.

Another thing that is weird with your library is that the color are in RGBA in MR but are in ARGB in android colors.xml. That was quite confusing. Maybe you should write something about it in the readme.

cl3m avatar Jan 20 '21 09:01 cl3m

Using vector graphics directly at runtime can be desirable, especially for Multiplatform projects where image-sizing hell becomes even more prevalent. However coercing all platforms to use Android's proprietary VectorDrawable XML format, feels uncomfortable. Plain SVG is a more neutral format and has 3rd party library support on both platforms e.g. SVGKit and AndroidSVG - and if Moko extends to web projects later, browsers support it out-of-the-box.

As I understand, the reason for VectorDrawable to exist is to narrow-down on a sub-set of the SVG format that's guaranteed to perform better on Android. This is something you can manage for yourself if you're in control of the SVG asset preparation.

Hence, we could achieve vector on both platforms just by using the file resources feature of MokoResources, although this is undocumented #161.

chris-hatton avatar Jan 24 '21 19:01 chris-hatton

will be released in 0.22.0

Alex009 avatar Apr 25 '23 06:04 Alex009

However coercing all platforms to use Android's proprietary VectorDrawable XML format, feels uncomfortable.

It turns out the Android vector image format is now part of Compose Multiplatform. Vector images can already be loaded from code on all supported platforms. What is missing is the ability to parse vector resource files on iOS in order to build an ImageVector object.

cbeyls avatar May 06 '24 18:05 cbeyls