https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
k

Kashismails

11/22/2023, 7:35 AM
I have this swift ui textfield how can i use this in compose multiplatform ? MaterialDesignTextField( $text1, placeholder: "Placeholder", hint: $hint, valid: $isValid, leadingIcon: "ret", trailingIcon: "ret", textLimit: 34){text in print("moye moye \(text)") }
a

Andrei Salavei

11/22/2023, 9:44 AM
Did you try combo of
UIViewRepresentable
(Swift) +
fun <T : UIView> UIKitView(...)
(Kotlin) ?
k

Kashismails

11/22/2023, 9:46 AM
i have to use this at multiple places in compose so looking for a better way to integrate it all over the app, since its a textfield i dont just want to show this but want to access all the internals
a

Andrei Salavei

11/22/2023, 10:01 AM
Am I right, that you want to access SwiftUI struct from KMM? Also, what are the internals you want get access to?
k

Kashismails

11/22/2023, 10:04 AM
so currently i am able to access this swift ui view using the technique you mentioned above and i am able to integrate it in compose by saving in another variable and accessing that where ever i need but this is a speghetti. so what i want is a better way to do it and also its a blackbox uiview and if i want to read the value coming in closure or accesing leading icon i cant do that
a

Andrei Salavei

11/22/2023, 11:36 AM
Unfortunately apart this trick there is nothing I can recommend. You can play with the way you're embedding SwiftUI views into Compose, for instance, make the view fully driven from Kotlin code via some interface, and map Kotlin signals into Combine/SwiftUI events. So, keep iOS code as thin as possible (and views should be isolated as possible) and put all logic on the Kotlin/Compose side.
5 Views