HI Guys CMP: how to consume widgets written in com...
# compose
m
HI Guys CMP: how to consume widgets written in compose inside ios. Example textfield where we want update value and get new value to composable function ? Thanks in advance
k
What is wrong with the documentation about the topic?
m
You don't consume "widgets" directly. You consume a composable that can be placed inside a ComposeUIViewController, and state can be propogated with UIViewControllerRepresentable. Generally this is going to be full screens, not individual widgets. https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-swiftui-integration.html
👍 1
FWIW, I tried this very early on in compose multiplatform and had hoped to build a cross platform design system to share things like buttons and whatnot, but that does not seem like it's possible at the moment. while you do have some degree of ability to call swiftui views in compose multiplatform via
UIKitViewController
, I don't think there's an equivalent function to other way to call an artibrary composable from swiftUI.
a
You can wrap the data that your composable need to you can update it from iOS. I didn't find any clear documentation about how to do this so I wrote a quick blog post about it. It's for SwiftUI but if you use UIKit it should work similarly: https://medium.com/@a.desentenac/sharing-a-state-between-swiftui-and-compose-multiplatform-407b8ade07cd