Joel Denke
05/30/2023, 1:14 PMsourceSets["main"].apply {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/res", "src/commonMain/resources")
resources.srcDirs("src/commonMain/resources")
}
IF you want both font and images, need to having root folder to resources, but for Android specifics need to have a font folder inside resources and all files being snake case.
Also need to add
implementation(compose.components.resources)
into both commonMain, iosMain and androidMain and other platforms.
As of example needed to provide actual vs expect for iOS and Android return Font.
Not entirely sure if I got it right for iOS yet, but on Android it works by using:
@SuppressLint("DiscouragedApi")
@Composable
actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font {
val context = LocalContext.current
val id = context.resources.getIdentifier(res, "font", context.packageName)
return remember(context) {
Font(id, weight, style)
}
}