I have this swift ui textfield how can i use this ...
# compose-ios
k
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
Did you try combo of
UIViewRepresentable
(Swift) +
fun <T : UIView> UIKitView(...)
(Kotlin) ?
k
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
Am I right, that you want to access SwiftUI struct from KMM? Also, what are the internals you want get access to?
k
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
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.