Stefan Oltmann
04/18/2023, 9:44 AMandroidx.compose.ui.graphics.painter.Painter
for my SVG & bitmap resource images. For JVM we have loadXmlImageVector()
and BitmapPainter
, which are not available for Compose for iOS. I have them in a folder, but I wouldn't mind (for now) to further use the Assets.xcassets
as SwiftUI requires me to.
I looked at https://github.com/Kotlin/kmm-production-sample/tree/compose-app which uses https://github.com/Skeptick/libres to do that, but this unfortunately requires CocoaPods, which I don't want in my project setup.
What are other options to use SVG & Bitmaps for my Icons with Compose for iOS?Stefan Oltmann
04/18/2023, 9:52 AMImage.makeFromEncoded(nsData.toByteArray()).toComposeImageBitmap()
, but I would like to continue using SVGs for my icons.Stefan Oltmann
04/18/2023, 10:01 AMMichael Paus
04/18/2023, 1:14 PMorg.jetbrains.compose.resources.painterResource
which you can get via
implementation(compose.components.resources)
and for SVG a modified version of
androidx.compose.ui.res.SVGPainter and
androidx.compose.ui.graphics.vector.DrawCache
from the desktop implementation. It is actually quite simple because both desktop and iOS are based on Skia. I just had to modify the loader so that it can read from a ByteArray instead of a Java stream. You can read the raw ByteArray as a resource via the resource package mentioned above.Stefan Oltmann
04/18/2023, 1:23 PMalex009
04/18/2023, 1:40 PMStefan Oltmann
04/18/2023, 1:40 PMalex009
04/18/2023, 1:41 PMStefan Oltmann
04/18/2023, 1:41 PMayodele
04/18/2023, 10:35 PMpainterResource