John Safwat
09/23/2025, 8:01 PMMoref
09/23/2025, 8:20 PMJohn Safwat
09/23/2025, 8:32 PMephemient
09/23/2025, 9:00 PM.ignoresSafeArea(.all)
as in the example https://github.com/JetBrains/compose-multiplatform/blob/master/examples/imageviewer/iosApp/iosApp/ContentView.swift, and use insets within composeephemient
09/23/2025, 9:00 PMephemient
09/23/2025, 9:01 PMSoumen pal
09/24/2025, 7:19 AMstruct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
struct ContentView: View {
var body: some View {
ComposeView()
.ignoresSafeArea() // Compose has own keyboard handler
}
}
the palce where the composeView is called in swift call this
.ignoresSafeArea()
John Safwat
09/24/2025, 7:40 AMJohn Safwat
09/24/2025, 7:41 AMimport UIKit
import SwiftUI
import ComposeApp
// This gradient is overlaid on the status bar to ensure text is readable.
let gradient = LinearGradient(
colors: [
Color.black.opacity(0.5),
Color.black.opacity(0.0),
],
startPoint: .top, endPoint: .bottom
)
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
// Create the view controller from the KMP module
let controller = MainViewControllerKt.MainViewController()
// Force the Compose content to always use a light theme
controller.overrideUserInterfaceStyle = .light
return controller
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
struct ContentView: View {
var body: some View {
ZStack {
// Display the Compose UI and have it extend into all safe areas
ComposeView()
.ignoresSafeArea(.all) // Compose has its own keyboard handler
// Overlay a gradient on top of the status bar
VStack {
gradient.ignoresSafeArea(edges: .top).frame(height: 0)
Spacer()
}
}
// Set the preferred color scheme for the SwiftUI container to dark
.preferredColorScheme(.dark)
}
}