I need to in a position to name a way of native iOS from shared module and do platform particular issues within the background, by doing so I additionally need to get again a consequence. Right here is my present code.
I’ve tried the next:
@Composable
enjoyable App(callBack: () -> Unit) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Association.SpaceAround
) {
var counter by bear in mind { mutableIntStateOf(0) }
Button(
onClick = {
counter++
}
) {
Textual content("Click on Me")
callBack.invoke()
}
Textual content("Counter : $counter")
android.util.Log.d(
"TAG",
"ProcessData consequence : ${processData("Good day from : ${getPlatform()}")}"
)
}
}
import UIKit
import SwiftUI
import shared
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
return Main_iosKt.MainViewController(callBack:myCallback)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
let myCallback: @conference(block) () -> Void = {
// Deal with the callback in your iOS code
print("Callback from Compose UI")
}
struct ContentView: View {
init(){
}
var physique: some View {
ComposeView()
.ignoresSafeArea(.all, edges: .backside) // Compose has personal keyboard handler
}
}
I do know that on this circumstances, we now have to make use of anticipate/precise, however it’s not calling native iOS facet code from shared module. Anybody have any solutions?