I guess my two questions are:
1. Is there a way to bring that annotation over into kmp? seems to be android specific?
2. painterResource isn't available?
c
curioustechizen
02/11/2024, 7:49 AM
Compose iOS has its own mechanism for providing drawables. Until very recently it used to be "stringly typed". A very recent beta of CMP 1.6 has introduced compile time safety similar to Android's R class.
curioustechizen
02/11/2024, 7:51 AM
I'm on mobile right now but if you search in the Compose repo you'll find examples for both
curioustechizen
02/11/2024, 7:52 AM
If you create a new KMP project using the online wizard it creates a screen with the Compose logo animation. That one already demonstrates how to use drawables in CMP.
a
agrosner
02/11/2024, 6:08 PM
If itโs a vector xml there is a handy tool you can covert to true compose vector that works on any platform.
The annotations not really Android specific itself, but androidx annotations only targetting Android I think. Also not really anything special about them, just regular Ints used ๐
To make it easier migrate to KMP I recommend creating new like ImageResource, TextResource, DimensionResource etc. Regular sealed classes/interfaces.
And then resolve the image in this case only when needed.
Then you can delegate it one way in Android and another way in iOS as of example.
As @curioustechizen mentioned compose multiplatform offers a component resources, solving this. WHere also painterResource exist but for DrawableResource class Jetbrains provide in their plugin.