mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Wrap Compose baked UIViewController into SwiftUI instead of UIKit. (#2782)
- fixes also top bar appearance - removed constant offset workaround as a result
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; };
|
||||
C1FC908188C4E8695729CB06 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DE96E47030356CE6AD9794A /* Pods_iosApp.framework */; };
|
||||
D5DE79A846260A9C7654FCD6 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DE73F83209A8ECD8AB0ED9 /* ContentView.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -19,6 +20,7 @@
|
||||
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8DE96E47030356CE6AD9794A /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AB3632DC29227652001CCB65 /* TeamId.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = TeamId.xcconfig; sourceTree = "<group>"; };
|
||||
D5DE73F83209A8ECD8AB0ED9 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -57,6 +59,7 @@
|
||||
children = (
|
||||
7555FF8C242A565B00829871 /* Info.plist */,
|
||||
2152FB032600AC8F00CF470E /* iosApp.swift */,
|
||||
D5DE73F83209A8ECD8AB0ED9 /* ContentView.swift */,
|
||||
);
|
||||
path = iosApp;
|
||||
sourceTree = "<group>";
|
||||
@@ -199,6 +202,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */,
|
||||
D5DE79A846260A9C7654FCD6 /* ContentView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
import shared
|
||||
|
||||
struct ComposeView: UIViewControllerRepresentable {
|
||||
func makeUIViewController(context: Context) -> UIViewController {
|
||||
Main_iosKt.MainViewController()
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
ComposeView()
|
||||
.ignoresSafeArea(.keyboard) // Compose has own keyboard handler
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
import UIKit
|
||||
import shared
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
let mainViewController = Main_iosKt.MainViewController()
|
||||
window?.rootViewController = mainViewController
|
||||
window?.makeKeyAndVisible()
|
||||
return true
|
||||
struct iOSApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,5 @@ import platform.UIKit.UIViewController
|
||||
|
||||
fun MainViewController(): UIViewController =
|
||||
Application("Imageviewer") {
|
||||
Column {
|
||||
// To skip upper part of screen.
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(30.dp)
|
||||
)
|
||||
ImageViewerIos()
|
||||
}
|
||||
ImageViewerIos()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user