Joel Denke
01/05/2024, 3:04 PM/**
* Return a Painter from the given resource path.
* Can load either a BitmapPainter for rasterized images (.png, .jpg) or
* a VectorPainter for XML Vector Drawables (.xml).
*
* XML Vector Drawables have the same format as for Android
* (<https://developer.android.com/reference/android/graphics/drawable/VectorDrawable>)
* except that external references to Android resources are not supported.
*
* Note that XML Vector Drawables are not supported for Web target currently.
*/
@ExperimentalResourceApi
@Composable
fun painterResource(res: String): Painter =
if (isSyncResourceLoadingSupported()) {
painterResource(res, {rememberImageBitmapSync()}, {density->rememberImageVectorSync(density)})
} else {
painterResource(res, {rememberImageBitmap().orEmpty()}, {density->rememberImageVector(density).orEmpty()})
}
However almost impossible to see what is supported on which platforms etc.
I am thinking about doing my own thing support everything.
Whats the suggested idea if I want to use lets say .svg files on iOS and ANdroid, do I need to use like Kamel or Coil for that, and does that even work with svg?
Same question for Lottie, ANdorid drawables, iOS PDF, urls, local vs cloud files etc etc.
Its insane 😄
Hence doing my own CustomImage instead of using ImageBitMap, ImageVector etc, but providing support for all platforms and variants. Want to know how I should do this the right way? 🙂