|
|
@ -5,6 +5,7 @@ import androidx.compose.ui.Alignment |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.graphics.Color |
|
|
|
import androidx.compose.ui.graphics.Color |
|
|
|
import androidx.compose.ui.interop.UIKitView |
|
|
|
import androidx.compose.ui.interop.UIKitView |
|
|
|
|
|
|
|
import androidx.compose.ui.interop.UIKitViewController |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.window.ComposeUIViewController |
|
|
|
import androidx.compose.ui.window.ComposeUIViewController |
|
|
|
import kotlinx.cinterop.ExperimentalForeignApi |
|
|
|
import kotlinx.cinterop.ExperimentalForeignApi |
|
|
@ -12,7 +13,9 @@ import platform.UIKit.UIView |
|
|
|
import platform.UIKit.UIViewController |
|
|
|
import platform.UIKit.UIViewController |
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalForeignApi::class) |
|
|
|
@OptIn(ExperimentalForeignApi::class) |
|
|
|
fun ComposeEntryPointWithUIView(createUIView: () -> UIView): UIViewController = |
|
|
|
fun ComposeEntryPointWithUIViewController( |
|
|
|
|
|
|
|
createUIViewController: () -> UIViewController |
|
|
|
|
|
|
|
): UIViewController = |
|
|
|
ComposeUIViewController { |
|
|
|
ComposeUIViewController { |
|
|
|
Column( |
|
|
|
Column( |
|
|
|
Modifier |
|
|
|
Modifier |
|
|
@ -21,8 +24,8 @@ fun ComposeEntryPointWithUIView(createUIView: () -> UIView): UIViewController = |
|
|
|
horizontalAlignment = Alignment.CenterHorizontally |
|
|
|
horizontalAlignment = Alignment.CenterHorizontally |
|
|
|
) { |
|
|
|
) { |
|
|
|
Text("How to use SwiftUI inside Compose Multiplatform") |
|
|
|
Text("How to use SwiftUI inside Compose Multiplatform") |
|
|
|
UIKitView( |
|
|
|
UIKitViewController( |
|
|
|
factory = createUIView, |
|
|
|
factory = createUIViewController, |
|
|
|
modifier = Modifier.size(300.dp).border(2.dp, Color.Blue), |
|
|
|
modifier = Modifier.size(300.dp).border(2.dp, Color.Blue), |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|