Joel Denke
01/19/2024, 2:00 PMNSURL.fileURLWithPath(NSBundle.mainBundle.resourcePath + "/compose-resources/" + path)
Where path is relative path from the shared resources folder.
Source code for Android is:
@ExperimentalResourceApi
actual fun resource(path: String): Resource = AndroidResourceImpl(path)
@ExperimentalResourceApi
private class AndroidResourceImpl(path: String) : AbstractResourceImpl(path) {
override suspend fun readBytes(): ByteArray {
val classLoader = Thread.currentThread().contextClassLoader ?: (::AndroidResourceImpl.javaClass.classLoader)
val resource = classLoader.getResourceAsStream(path)
if (resource != null) {
return resource.readBytes()
} else {
throw MissingResourceException(path)
}
}
}
But I want to get the path and not the bytes 😄Mark Murphy
01/19/2024, 10:40 PMandroid.resource
scheme you can use for a Uri
, and it is just based off of the resource identifier.Joel Denke
01/20/2024, 8:36 AM