I'm trying to write a custom client library for Co...
# compose
m
I'm trying to write a custom client library for Compose, but struggling to figure out how to implement Modifier and various layout components, because it seems I can't reuse the compose-foundation composables and Modifiers? Are there any references on how to approach this?
k
This is too vague. What are the specific things that you are seeing? Unresolved imports? Build error? Runtime error?
m
From what I can gather, the layout elements only support ComposeUiNode and not my custom node type, and modifiers seem to be tightly integrated with that system, so I'm not sure how I'd go about getting stuff like weight/alignment/padding/etc to work.
k
Again, too vague. You are dropping us into the middle of the conversation you’re having in your head. Post a snippet of what you tried to do, so that people can see what it is that is not working.
👍 2
Of course, if you go full custom, then (in theory again, since it’s all quite theoretical right now) it might mean that you don’t get the benefit of the integration with some foundational parts.
m
Right, so: I'm working with a game where UIs are done with essentially monocolored rectangles and text only, so I can't draw a canvas to a texture and just render that. As result, I've been trying to figure out how to use custom node types to create composables for this system. However, trying to use a Compose class like Row results in:
Copy code
Caused by: org.jetbrains.skiko.LibraryLoadException: Cannot find libskiko-linux-x64.so.sha256, proper native dependency missing.
	at knot/org.jetbrains.skiko.Library.findAndLoad(Library.kt:103) ~[skiko-awt-0.9.4.2.jar:?]
	at knot/org.jetbrains.skiko.Library.load(Library.kt:56) ~[skiko-awt-0.9.4.2.jar:?]
	at knot/org.jetbrains.skia.impl.Library$Companion.staticLoad(Library.jvm.kt:12) ~[skiko-awt-0.9.4.2.jar:?]
	at knot/org.jetbrains.skia.Paint.<clinit>(Paint.kt:10) ~[skiko-awt-0.9.4.2.jar:?]
	... 34 more
even though I'd assume layouting wouldn't need the rendering backend (especially when this is planned to be used on multiple platforms, I wouldn't want a 500mb artifact by bundling natives for all platforms and architectures)
s
I don't think you can decouple layout from drawing in this case, unless you are willing to fork compose ui/foundation and add a new custom rendering backend.
by default, compose multiplatform assumes skia dependency, and it sounds like you don't want it you probably have two ways to approach this: 1) implement your own node structure and modifiers like mosaic does 2) fork compose ui and implement the subset that you need as a different target platform / render backend 2) gets you foundation and other apis, but it takes much more work
i
by default, compose multiplatform assumes skia dependency
It's true for now, yes. However from multiplatform POV I agree that it's not ideal and we do want to change this assumption. But it requires a lot of internal refactoring work. No promises/commitments/etc for now
🙌 1