Arjan van Wieringen
05/12/2023, 12:55 PMicons
package I have added the resources under commonMain/resources
. I added the experimental compose.components.resources
dependency and I created a barebones composable in that package:
@OptIn(ExperimentalResourceApi::class)
@Composable
fun Icon() {
Image(
painter = painterResource("icons/create-new-folder.svg"), // i also tried with leading slashe
contentDescription = null
)
}
However, if I consume this package in my desktop application package (compose desktop for JVM) it can not find the resource. What am I missing here?
I used the following repo as a starting point: https://github.com/Kotlin/kotlin-wasm-examples/tree/main/compose-imageviewerChrimaeon
05/12/2023, 1:25 PMpainterResource
is an android concept that not part of the compose.components.resources
I think. have a look at the cutom implementation of painterResourceCached
in here https://github.com/Kotlin/kotlin-wasm-examples/blob/d28f7917848c24e26d40f8ec6b309d[…]ed/src/commonMain/kotlin/example/imageviewer/platform.common.kt? resources are bundled via a resource folder like this https://github.com/Kotlin/kotlin-wasm-examples/tree/d28f7917848c24e26d40f8ec6b309dcd9ba0e77f/compose-imageviewer/shared/src/commonMain/resourcespackageicons
Arjan van Wieringen
05/12/2023, 2:27 PMChrimaeon
05/12/2023, 2:35 PMresource
folder to jvmMain
?Arjan van Wieringen
05/12/2023, 3:32 PMChrimaeon
05/12/2023, 3:33 PMpainterResource
but load the resources from the resource
composable function.Arjan van Wieringen
05/12/2023, 3:33 PMpainterResource
is part of the org.jetbrains.compose.resources
package btwChrimaeon
05/12/2023, 3:59 PMArjan van Wieringen
05/12/2023, 4:00 PMError(exception=org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: icons/create-new-folder.svg)
so, that is clearChrimaeon
05/12/2023, 4:00 PMArjan van Wieringen
05/12/2023, 5:25 PMChrimaeon
05/12/2023, 5:32 PMCompose Image Vectors
,like the Material Icons library, out of your SVG’s https://plugins.jetbrains.com/plugin/18619-svg-to-composeArjan van Wieringen
05/13/2023, 5:40 AMChrimaeon
05/13/2023, 9:16 AM.jar
file if the resources are all bundled correctly?Arjan van Wieringen
05/13/2023, 9:54 AM