https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

jQrgen

09/22/2023, 11:52 AM
How to draw images/icons from .xml files in multiplatform? What dependencies do I need?
z

zsmb

09/22/2023, 1:02 PM
There's a first-party (experimental) solution, with this dependency which is added by default in the multiplatform templates (like this one):
Copy code
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
Then you just call the
painterResource
method and pass in the path of the image to draw, as seen here. --- Another option is moko-resources which can work with SVG images.
thank you color 1
🙌 1
j

jQrgen

09/26/2023, 1:42 PM
Nice! Is there a way to follow the development of this first-party solution for images in multiplatform? First-party, meaning that JetBrains is developing this? Do you think this supports all platforms? Especially iOS?
z

zsmb

09/26/2023, 1:45 PM
The template linked above is for Android and iOS, so yes it does work on iOS. There's unfortunately no proper docs for it yet (again, it's still experimental), but we're working on creating documentation for it!
j

jQrgen

09/26/2023, 1:46 PM
Nice
s

streetsofboston

09/26/2023, 1:52 PM
@zsmb Would this solution also support KMP solutions that don't use multiplatform Compose, that stick with the pure native UI implementations?
z

zsmb

09/26/2023, 1:55 PM
This is specific to using resources in Compose. If you're building native UI then using the respective resource systems of each platform is the way to go.
thank you color 1
j

jQrgen

09/26/2023, 3:48 PM
I guess
AnimatedVisibility
is a nice to have based from the example?
How can I import this?
Add this to commonMain? @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) implementation(compose.components.resources)
..yep
Now we are using this in production =)))
3 Views