Joel Denke
02/12/2024, 7:27 AMJoel Denke
02/12/2024, 7:33 AMJoel Denke
02/12/2024, 8:22 AMactual class PlatformResource(
private val path: String
): MyResource {
@Composable
override fun absolutePath(): String {
return LocalContext.current.packageResourcePath + "/" + path
}
@Composable
fun asUri(): Uri {
val absolutePath = absolutePath()
val file = File(absolutePath)
return Uri.parse("file:///android_asset/${file.name}")
}
}
And then in my androidLibrary convention plugin adding:
android {
sourceSets["main"].apply {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
assets.srcDir("src/commonMain/composeResources/files/assets")
}
}
Most probably helps someone else as well. Basically did same thing that Jetbrains doing for fonts, but also for treat everything as assets.
Had to put subfolder into /files/assets as cannot have folder named assets inside composeResources directly 🙂
This is very ugly, as I need to have resource("files/assets/audio.mp3") being resolved different per platform. But it works for now.