JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.28k stars 1.18k forks source link

Swift UI screen inside compose #3874

Closed ismai117 closed 10 months ago

ismai117 commented 1 year ago

I know there's examples showing Compose UI elements inside a Swift UI screen, but how do I do the opposite?

I've got a full compose multiplatform app with precompose navigation. I've got a splash screen with Lottie animation on the Android side.

How do I create a separate splash screen using SwiftUI so I can use Lottie-ios and other SwiftUI components?

dima-avdeev-jb commented 1 year ago

Hello! Right now we are preparing a way how you can experiment with that. Please stay tuned...

sunny-chung commented 1 year ago

And how about native views inside compose, would that be possible? I would like to use both Compose and third-party map views.

dima-avdeev-jb commented 1 year ago

@sunny-chung Yes, you can use UIKitView for it. Please take a look to our sample with MKMapView: https://github.com/JetBrains/compose-multiplatform/blob/master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt#L17

sunny-chung commented 1 year ago

This works because there is a Kotlin binding for the Apple MapKit. How about if I want to use views provided by third parties, e.g. a Mapbox map? Mapbox does not even have a SwiftUI implementation, just native views.

(Sorry for the distraction but this is the first question I seen about compose interoperability with iOS UI)

dima-avdeev-jb commented 1 year ago

@sunny-chung You can add thridparty libraries to project with cocapods https://kotlinlang.org/docs/native-cocoapods.html#add-and-configure-kotlin-cocoapods-gradle-plugin In this way you can use cocapods Compose project setup https://github.com/JetBrains/compose-multiplatform/tree/master/examples/cocoapods-ios-example

anaesthez commented 12 months ago

Hello, is there still no way to do it? Haven't you already have docs referring it? https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-ios-ui-integration.html#use-swiftui-inside-compose-multiplatform Or I just misinterpreted your messages?...

dima-avdeev-jb commented 12 months ago

Hello, is there still no way to do it? Haven't you already have docs referring it? https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-ios-ui-integration.html#use-swiftui-inside-compose-multiplatform Or I just misinterpreted your messages?...

You can use this doc.

ismai117 commented 11 months ago

I was checking out the ios-swiftui-in-compose project, this is what i've been looking for but how do we use it for isolated components e.g. a bottom navigation or top bar

from looking at the sample project, the container is inside the window group - IosApp struct

dima-avdeev-jb commented 10 months ago

You can take a look to chat sample with SwiftUI bottom tab bar https://github.com/JetBrains/compose-multiplatform/tree/master/examples/chat

It uses bottom tab bar as a separate SwiftUI view outside of Compose.

dima-avdeev-jb commented 10 months ago

Published documentation available here https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-ios-ui-integration.html

akardas16 commented 10 months ago

Published documentation available here https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-ios-ui-integration.html

last title says Use SwiftUI inside Compose Multiplatform but the example still shows swiftUI view in ContentView.swift file. How can I use ComposeEntryPointWithUIView kotlin function in my compose function?

kumarmohit5189 commented 8 months ago

Published documentation available here https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-ios-ui-integration.html

last title says Use SwiftUI inside Compose Multiplatform but the example still shows swiftUI view in ContentView.swift file. How can I use ComposeEntryPointWithUIView kotlin function in my compose function?

@akardas16 are you able to use it? I am also interested in this. Say my first screen is compose multiplatform but second screen after navigation in in swiftUI for iOS. Any help here?

michalguspiel commented 8 months ago

This is doable in a completely different way than it is shown in the documentation.

https://gist.github.com/michalguspiel/9d0ae407ca7f2cd0234f6879a1f08290

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.