Hello buys, with compose multiplatform 1.6.0, can ...
# compose
b
Hello buys, with compose multiplatform 1.6.0, can we still access image ressource by name instead of using generated class
*Res*
k
Only as a byte array. Put it to the files directory
m
For me these two lines seem to produce the same result:
Copy code
val headerGraphicsPainter = painterResource(Res.drawable.header_graphics)
val headerGraphicsPainter = painterResource(DrawableResource(("drawable/header_graphics.png")))
1
k
It is internal API. Don't use it. And the first variant supports qualifiers (e.g. density and theme)
m
Don’t blame me. Blame it on the (missing) documentation 😉. How shall a user distinguish between official and internal API?
k
You use the beta1 version 🤷‍♂️ 🙂
m
Even worse I use the latest dev version 1.6.0-dev1397 😇
k
@brabo-hi why do you need it?
b
i need to display country flags, those assets are stored as resources. However the list to display will dynamically changing based on some api calls that returns a name of countries to display. It means i need to read image resources by name
k
I don't get the last part. Why don't you want to use IDs instead of strings?
b
1. i have an api that returns a list of country codes as strings
US, UK, CA
. .. 2. i have country flags stored as png ressources. How can i display those flags when the api only returns country code as strings? It if was only android, i can get resource with something like
context.resources.getIdentifier(imageName, "drawable", context.packageName)
k
You are supposed to have a response to id mapper. And a proper error handling for unknown responses
Otherwise it will crash unpredictable
b
yes it looks a better solution, thanks
👍 1
@Konstantin Tskhovrebov it does look Res isn’t generated when used on a multi module project
👌 1
😭 1
@Konstantin Tskhovrebov is there any dev release that has this fix?
k
It's not implemented