Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to make the generated Res class public #4193

Closed
asapha opened this issue Jan 28, 2024 · 7 comments
Closed

Add the possibility to make the generated Res class public #4193

asapha opened this issue Jan 28, 2024 · 7 comments
Labels
enhancement New feature or request resources

Comments

@asapha
Copy link

asapha commented Jan 28, 2024

Right now, it's internal, which makes it not accessible by other modules.

Taking the :resources:demo project as an example, the app's name needs to be duplicated in
shared/src/commonMain/composeResources/values/strings.xml, desktopApp/src/jvmMain/kotlin/Main.kt

singleWindowApplication(
        title = "Resources demo",
        state = WindowState(size = DpSize(800.dp, 800.dp))
    ) {
        MainView()
    }

and androidApp/src/main/res/values/strings.xml

<resources>
    <string name="app_name">Resources demo</string>
</resources>

It could be parameterized like in moko-resources

cf.

): FileSpec = FileSpec.builder(packageName, "Res").apply {
addType(TypeSpec.objectBuilder("Res").apply {
addModifiers(KModifier.INTERNAL)

@asapha asapha added enhancement New feature or request submitted labels Jan 28, 2024
@terrakok
Copy link
Member

terrakok commented Jan 29, 2024

Right now, it's internal, which makes it not accessible by other modules.

yes. it is the current design decision. module's resources are isolated from each other. if you want to provide it outside you are suppose to declare explicit API in the module.

@m0rtis
Copy link

m0rtis commented Feb 20, 2024

yes. it is the current design decision. module's resources are isolated from each other. if you want to provide it outside you are suppose to declare explicit API in the module.

Konstantin I'm so grateful for your answer! I finally got how to get my resources from my compose ui design system library in my applications! But I have a question - why that design decision was made? I want to extract my compose elements to separate library and reuse it in several applications. May be I'm doing something wrong?

@m0rtis
Copy link

m0rtis commented Feb 20, 2024

@terrakok sorry, I tagged you to attract your attention to my question:))

@MatkovIvan
Copy link
Member

https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html

  • Multimodule projects are not supported yet. The JetBrains team is working on adding this functionality in future releases. For now, store all resources in the main application module.

  • The publication of Compose Multiplatform libraries with resources is not supported yet. The JetBrains team is working on adding this functionality in future releases.

Currently, there are some limitations in underlying things that block us from doing this. We're working with Kotlin and other teams to make this happen.

@m0rtis
Copy link

m0rtis commented Feb 21, 2024

Ivan thank you a lot! Will wait quietly:))

@terrakok
Copy link
Member

#4327 (comment)

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request resources
Projects
None yet
Development

No branches or pull requests

5 participants