Ganesh Sonawane
02/05/2024, 8:01 AMJoel Denke
02/05/2024, 8:25 AMGanesh Sonawane
02/05/2024, 9:13 AMJoel Denke
02/05/2024, 9:21 AMJoel Denke
02/05/2024, 9:23 AMJoel Denke
02/05/2024, 9:24 AMGanesh Sonawane
02/05/2024, 11:32 AMPatil Vaibhav2147 Vp
02/08/2024, 12:25 PMstruct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController(createUIView: { () -> UIView in
SwiftUIInUIView(
content: SignInWithAppleView()
)
}
)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
now this is the only function of this kind that is there by default and calls the entry point function from iosMain
now whatever swfit ui views that I want to pass to my compose code, say a button , or some other swift ui view DO I NEED TO PASS THEM ALL AS DIFFERENT PARAMETERS IN THIS(MainViewController) FUNCTION ONLY?
2nd question
This is the defination of MainViewController function in Kotlin
@OptIn(ExperimentalForeignApi::class)
fun MainViewController(
createUIView: () -> UIView
):UIViewController = _ComposeUIViewController_ *{*
_App_(swiftUIView = *{*
_UIKitView_(
factory = createUIView,
modifier = Modifier._wrapContentWidth_()
)
*}*)
}
In above function I have createUIView as parameter which is the swift view that I am passing from swift code
But the issue is I only have it available in the scope of this function
Now I have passed it to my App() composable in common code and I can use it, but how do I use that createUiVIew paramter in some other function which I can call using expect actual in any part of my compose screen,
Right now it seems like I will have to pass it from screen to screen
for eg: App() -> SignInScreen()-> OnboardingScreens() (4-5)->HomeScreen()
Now what If I want to use that createUIVIew in Homescreen?
I dont want to pass it from App() composable all the way to Homescreen