Hi all. Is Compose Android-only ui library or can ...
# compose
a
Hi all. Is Compose Android-only ui library or can we use it for the kotlin multiplatform? Since this library will be delivered separately from Android, will it be possible to use it without the android framework?
s
Romain Guy has already answered on this channel that they will be providing the Compose compiler plugin & runtime outside of Compose UI, but has made no commitment as to when (stating that having Jetpack Compose UI working being their top priority). Furthermore, the description of Leland Richardson's talk at KotlinConf ends with: "In addition, this talk will describe how Compose can operate completely independent of the Android Platform and Compose UI, allowing it to be used as a general language feature for Incremental Computing and the management of tree-like data structures". No mention of Multiplatform though, so I'd be very intersted in @Leland Richardson [G] answer regarding Compose Multiplatform 😉 However, even if it where to happen (which would be awesome), Compose is only a tool. Should you would want to use it for UI, you would need a Kotlin/Multiplatform UI framework to manipulate with it (essentially an Multiplatform Compose UI). Creating such a thing is is quite a daunting task!
t
From what I understand, it will be possible. Even if they will not directly support an other platform, they will provide documentation about extending Compose and adapt the outputs.
s
Jetpack compose already supporting two different UI type; android view and compose UI. If Runtime pure kotlin/kotlin native it should be possible to add different UI support. But as I understand that is not the point at the moment because if it fails for Android it doesnt makes sense to invest in those areas. (that is what i understand from blogs and podcasts)
l
yeah - this is basically correct. compose runtime shouldn’t require anything android specific and was designed independently from the actual types of trees (like android views and compose UI) it emits, so it targeting a multiplatform view library would be reasonable. once things stabilize, i’ll talk more about how you can use compose in this way. You can see in our codebase today we are already using compose to target some more exotic tree types within compose UI - like vector graphics and text spans. But it’s worth keeping in mind that right now the proper support for this isn’t really landed in our compiler plugin, so mucking around with multiple tree types is sort of risky right now (it works, but it’s somewhat akin to dynamic typing at the moment) and the APIs for it are kind of gross as a result.
👍🏼 4
l
When proper support is ready, it will allow multiple things taking advantage of Compose to live in the same app, or even the same file, even if some of those things are custom?
l
yep, that’s the idea
m
I see that this is totally a game changer for Kotlin, with compose used in both platform, now we could totally write Android and iOS apps in Kotlin. I already played with flutter, and my only take that’s is not Kotlin 😄.