From 255c36a0ad041dc27bdb759611e84ce9441ee52b Mon Sep 17 00:00:00 2001 From: "dima.avdeev" Date: Mon, 4 Sep 2023 17:39:51 +0300 Subject: [PATCH] iOS Simplify Swift code in examples (#3609) * COMPOSE-351, iOS Simplify Swift code in examples - change indent from tabs to spaces - simplify and inline SwiftUI ContentView structure https://youtrack.jetbrains.com/issue/COMPOSE-351/remove-redundant-struct-ContentView Co-authored-by: Ivan Matkov --- .../iosApp/iosApp.xcodeproj/project.pbxproj | 8 ++-- .../iosApp/ComposeInsideSwiftUIScreen.swift | 4 +- .../chat/iosApp/iosApp/GradientTemplate.swift | 6 +-- examples/chat/iosApp/iosApp/iOSApp.swift | 30 +++++++++++++ examples/chat/iosApp/iosApp/iosApp.swift | 26 ----------- .../iosApp/iosApp.xcodeproj/project.pbxproj | 4 -- .../iosApp/iosApp/ContentView.swift | 21 --------- .../iosApp/iosApp/iOSApp.swift | 29 +++++++++---- .../iosApp/iosApp.xcodeproj/project.pbxproj | 4 -- .../iosApp/iosApp/ContentView.swift | 21 --------- .../codeviewer/iosApp/iosApp/iOSApp.swift | 29 +++++++++---- .../iosApp/iosApp.xcodeproj/project.pbxproj | 4 -- .../iosApp/iosApp/ContentView.swift | 37 ---------------- .../imageviewer/iosApp/iosApp/iOSApp.swift | 43 ++++++++++++++++--- .../iosApp/iosApp.xcodeproj/project.pbxproj | 8 ++-- .../iosApp/ComposeInSwiftUIScreen.swift | 25 +++++------ .../ComposeViewControllerInSwiftUI.swift | 9 ++++ .../iosApp/iosApp/ScreenTemplate.swift | 6 +-- .../iosApp/iosApp/iOSApp.swift | 20 +++++++++ .../iosApp/iosApp/iosApp.swift | 17 -------- .../interop/ios-swiftui-in-compose/README.md | 2 +- .../iosApp/iosApp.xcodeproj/project.pbxproj | 8 ++-- .../iosApp/{iosApp.swift => iOSApp.swift} | 10 ++--- .../iosApp/iosApp.xcodeproj/project.pbxproj | 12 ++---- ...ControllerToSwiftUI.swift => iOSApp.swift} | 13 +++++- .../iosApp/iosApp/iosApp.swift | 13 ------ .../iosApp/iosApp.xcodeproj/project.pbxproj | 4 -- .../iosApp/iosApp/ContentView.swift | 21 --------- .../todoapp-lite/iosApp/iosApp/iOSApp.swift | 24 ++++++++--- .../iosApp/iosApp.xcodeproj/project.pbxproj | 4 -- .../iosApp/iosApp/ContentView.swift | 21 --------- .../iosApp/iosApp/iOSApp.swift | 24 ++++++++--- 32 files changed, 223 insertions(+), 284 deletions(-) create mode 100644 examples/chat/iosApp/iosApp/iOSApp.swift delete mode 100644 examples/chat/iosApp/iosApp/iosApp.swift delete mode 100644 examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift delete mode 100644 examples/codeviewer/iosApp/iosApp/ContentView.swift delete mode 100644 examples/imageviewer/iosApp/iosApp/ContentView.swift create mode 100644 examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iOSApp.swift delete mode 100644 examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift rename examples/interop/ios-swiftui-in-compose/iosApp/iosApp/{iosApp.swift => iOSApp.swift} (53%) rename examples/interop/ios-uikit-in-compose/iosApp/iosApp/{ComposeViewControllerToSwiftUI.swift => iOSApp.swift} (65%) delete mode 100644 examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift delete mode 100644 examples/todoapp-lite/iosApp/iosApp/ContentView.swift delete mode 100644 examples/widgets-gallery/iosApp/iosApp/ContentView.swift diff --git a/examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj index f764beb0c3..98d28b8f43 100644 --- a/examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj @@ -12,7 +12,7 @@ 184881FBE98BA5BF02A0A186 /* GradientTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1848892FA748717E4087E7D7 /* GradientTemplate.swift */; }; 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; }; 184882D8AF2A7A3642004010 /* ComposeInsideSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */; }; - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -21,7 +21,7 @@ 1848892FA748717E4087E7D7 /* GradientTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientTemplate.swift; sourceTree = ""; }; 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInsideSwiftUIScreen.swift; sourceTree = ""; }; 18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KotlinToSwiftHelper.swift; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* Chat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Chat.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; @@ -59,7 +59,7 @@ isa = PBXGroup; children = ( 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iosApp.swift */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */, 18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */, 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */, @@ -167,7 +167,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */, 184880BA0E9910C2B5012412 /* KotlinToSwiftHelper.swift in Sources */, 184882D8AF2A7A3642004010 /* ComposeInsideSwiftUIScreen.swift in Sources */, diff --git a/examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift b/examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift index 826d425203..a9745427f3 100644 --- a/examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift +++ b/examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift @@ -30,8 +30,8 @@ struct TextInputLayer: View { Spacer() HStack { TextField("Type message...", text: $textState, axis: .vertical) - .focused($textFieldFocused) - .lineLimit(3) + .focused($textFieldFocused) + .lineLimit(3) if (!textState.isEmpty) { Button(action: { sendMessage(textState) diff --git a/examples/chat/iosApp/iosApp/GradientTemplate.swift b/examples/chat/iosApp/iosApp/GradientTemplate.swift index 6feea90f63..f59de24107 100644 --- a/examples/chat/iosApp/iosApp/GradientTemplate.swift +++ b/examples/chat/iosApp/iosApp/GradientTemplate.swift @@ -18,9 +18,9 @@ struct GradientTemplate: View { Rectangle().frame(height: 0).background(gradient) } } - .navigationTitle(title) - .navigationBarTitleDisplayMode(.inline) - .statusBar(hidden: false) + .navigationTitle(title) + .navigationBarTitleDisplayMode(.inline) + .statusBar(hidden: false) } } } diff --git a/examples/chat/iosApp/iosApp/iOSApp.swift b/examples/chat/iosApp/iosApp/iOSApp.swift new file mode 100644 index 0000000000..66517720be --- /dev/null +++ b/examples/chat/iosApp/iosApp/iOSApp.swift @@ -0,0 +1,30 @@ +import SwiftUI + +let gradient = LinearGradient( + colors: [ + Color(red: 0.933, green: 0.937, blue: 0.953), + Color(red: 0.902, green: 0.941, blue: 0.949) + ], + startPoint: .topLeading, endPoint: .bottomTrailing +) + +@main +struct iOSApp: App { + var body: some Scene { + WindowGroup { + TabView { + ComposeInsideSwiftUIScreen() + .tabItem { + Label("Group Chat", systemImage: "rectangle.3.group.bubble.left") + } + + YetAnotherSwiftUIScreen() + .tabItem { + Label("Settings", systemImage: "gear") + } + + } + .accentColor(Color(red: 0.671, green: 0.365, blue: 0.792)).preferredColorScheme(.light) + } + } +} diff --git a/examples/chat/iosApp/iosApp/iosApp.swift b/examples/chat/iosApp/iosApp/iosApp.swift deleted file mode 100644 index 20e038ef7f..0000000000 --- a/examples/chat/iosApp/iosApp/iosApp.swift +++ /dev/null @@ -1,26 +0,0 @@ -import SwiftUI - -let gradient = LinearGradient( - colors: [ - Color(red: 0.933, green: 0.937, blue: 0.953), - Color(red: 0.902, green: 0.941, blue: 0.949) - ], - startPoint: .topLeading, endPoint: .bottomTrailing -) - -@main -struct iOSApp: App { - var body: some Scene { - WindowGroup { - TabView { - ComposeInsideSwiftUIScreen() - .tabItem { Label("Group Chat", systemImage: "rectangle.3.group.bubble.left") } - - YetAnotherSwiftUIScreen() - .tabItem { Label("Settings", systemImage: "gear") } - - } - .accentColor(Color(red: 0.671, green: 0.365, blue: 0.792)).preferredColorScheme(.light) - } - } -} diff --git a/examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj index df8fc264e7..6ff871146f 100644 --- a/examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; CFDB58B53BB94DE262B13C24 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */; }; /* End PBXBuildFile section */ @@ -21,7 +20,6 @@ 4FF3202A603A284706412EDC /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF7B242A565900829871 /* My application.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "My application.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; FF8CA3F5360CEAB49D74065F /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; }; @@ -78,7 +76,6 @@ isa = PBXGroup; children = ( 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, @@ -218,7 +215,6 @@ buildActionMask = 2147483647; files = ( 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift b/examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift deleted file mode 100644 index 64e7056864..0000000000 --- a/examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -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(.all, edges: .bottom) // Compose has own keyboard handler - } -} - - - diff --git a/examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift b/examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift index 1f23b442a3..063945cdc3 100644 --- a/examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift +++ b/examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift @@ -1,13 +1,24 @@ +import UIKit import SwiftUI +import shared @main struct iOSApp: App { - var body: some Scene { - WindowGroup { - ZStack { - Color.white.ignoresSafeArea(.all) // status bar color - ContentView() - }.preferredColorScheme(.light) - } - } -} \ No newline at end of file + var body: some Scene { + WindowGroup { + ZStack { + Color.white.ignoresSafeArea(.all) // status bar color + ComposeView() + .ignoresSafeArea(.all, edges: .bottom) // Compose has own keyboard handler + }.preferredColorScheme(.light) + } + } +} + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + Main_iosKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} +} diff --git a/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj index 59abea4a27..b11460f555 100644 --- a/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -18,7 +17,6 @@ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* Codeviewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Codeviewer.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -63,7 +61,6 @@ isa = PBXGroup; children = ( 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, @@ -172,7 +169,6 @@ buildActionMask = 2147483647; files = ( 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/codeviewer/iosApp/iosApp/ContentView.swift b/examples/codeviewer/iosApp/iosApp/ContentView.swift deleted file mode 100644 index 64e7056864..0000000000 --- a/examples/codeviewer/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -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(.all, edges: .bottom) // Compose has own keyboard handler - } -} - - - diff --git a/examples/codeviewer/iosApp/iosApp/iOSApp.swift b/examples/codeviewer/iosApp/iosApp/iOSApp.swift index a116c5289f..2a1d6e105b 100644 --- a/examples/codeviewer/iosApp/iosApp/iOSApp.swift +++ b/examples/codeviewer/iosApp/iosApp/iOSApp.swift @@ -1,13 +1,24 @@ +import UIKit import SwiftUI +import shared @main struct iOSApp: App { - var body: some Scene { - WindowGroup { - ZStack { - Color(#colorLiteral(red: 0.235, green: 0.247, blue: 0.255, alpha: 1)).ignoresSafeArea(.all) - ContentView() - }.preferredColorScheme(.dark) - } - } -} \ No newline at end of file + var body: some Scene { + WindowGroup { + ZStack { + Color(#colorLiteral(red: 0.235, green: 0.247, blue: 0.255, alpha: 1)).ignoresSafeArea(.all) + ComposeView() + .ignoresSafeArea(.all, edges: .bottom) // Compose has own keyboard handler + }.preferredColorScheme(.dark) + } + } +} + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + Main_iosKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} +} diff --git a/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj index 81c7d54677..6b01442206 100644 --- a/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -18,7 +17,6 @@ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* My Memories.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "My Memories.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -64,7 +62,6 @@ isa = PBXGroup; children = ( 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, @@ -180,7 +177,6 @@ buildActionMask = 2147483647; files = ( 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/imageviewer/iosApp/iosApp/ContentView.swift b/examples/imageviewer/iosApp/iosApp/ContentView.swift deleted file mode 100644 index 89d0d1ad0c..0000000000 --- a/examples/imageviewer/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,37 +0,0 @@ -import UIKit -import SwiftUI -import shared - -let gradient = LinearGradient( - colors: [ - Color.black.opacity(0.6), - Color.black.opacity(0.6), - Color.black.opacity(0.5), - Color.black.opacity(0.3), - Color.black.opacity(0.0), - ], - startPoint: .top, endPoint: .bottom -) - -struct ComposeView: UIViewControllerRepresentable { - func makeUIViewController(context: Context) -> UIViewController { - let controller = Main_iosKt.MainViewController() - controller.overrideUserInterfaceStyle = .light - return controller - } - - func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} -} - -struct ContentView: View { - var body: some View { - ZStack { - ComposeView() - .ignoresSafeArea(.all) // Compose has own keyboard handler - VStack { - gradient.ignoresSafeArea(edges: .top).frame(height: 0) - Spacer() - } - }.preferredColorScheme(.dark) - } -} diff --git a/examples/imageviewer/iosApp/iosApp/iOSApp.swift b/examples/imageviewer/iosApp/iosApp/iOSApp.swift index 0648e8602f..dfb369e039 100644 --- a/examples/imageviewer/iosApp/iosApp/iOSApp.swift +++ b/examples/imageviewer/iosApp/iosApp/iOSApp.swift @@ -1,10 +1,41 @@ +import UIKit import SwiftUI +import shared + +let gradient = LinearGradient( + colors: [ + Color.black.opacity(0.6), + Color.black.opacity(0.6), + Color.black.opacity(0.5), + Color.black.opacity(0.3), + Color.black.opacity(0.0), + ], + startPoint: .top, endPoint: .bottom +) @main struct iOSApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} \ No newline at end of file + var body: some Scene { + WindowGroup { + ZStack { + ComposeView() + .ignoresSafeArea(.all) // Compose has own keyboard handler + VStack { + gradient.ignoresSafeArea(edges: .top).frame(height: 0) + Spacer() + } + }.preferredColorScheme(.dark) + } + } +} + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + let controller = Main_iosKt.MainViewController() + controller.overrideUserInterfaceStyle = .light + return controller + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + } +} diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp.xcodeproj/project.pbxproj index 105f0d81d7..bbff3905d0 100644 --- a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 184881FBE98BA5BF02A0A186 /* ScreenTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1848892FA748717E4087E7D7 /* ScreenTemplate.swift */; }; 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; }; 184882D8AF2A7A3642004010 /* ComposeInSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */; }; - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -19,7 +19,7 @@ 18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerInSwiftUI.swift; sourceTree = ""; }; 1848892FA748717E4087E7D7 /* ScreenTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScreenTemplate.swift; sourceTree = ""; }; 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInSwiftUIScreen.swift; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* ComposeInSwiftUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ComposeInSwiftUI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; @@ -57,7 +57,7 @@ isa = PBXGroup; children = ( 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iosApp.swift */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */, 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */, 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */, @@ -164,7 +164,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerInSwiftUI.swift in Sources */, 184882D8AF2A7A3642004010 /* ComposeInSwiftUIScreen.swift in Sources */, 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */, diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift index 921a4d8ef1..9da8066d56 100644 --- a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift +++ b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift @@ -5,19 +5,11 @@ struct ComposeInSwiftUIScreen: View { ZStack { ComposeLayer() TextInputLayer() - }.onTapGesture { - // Hide keyboard on tap outside of TextField - UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) - } - } -} - -struct ComposeLayer: View { - var body: some View { - ScreenTemplate(title: "Compose in SwiftUI") { - ComposeViewControllerInSwiftUI() - .ignoresSafeArea(.keyboard) // Compose has its own keyboard handler } + .onTapGesture { + // Hide keyboard on tap outside of TextField + UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) + } } } @@ -30,9 +22,12 @@ struct TextInputLayer: View { Spacer() VStack { TextField("empty TextField", text: $textState, axis: .vertical) - .focused($textFieldFocused) - .lineLimit(3) - }.padding(12).background(RoundedRectangle(cornerRadius: 10).colorInvert().opacity(0.6)).padding(32) + .focused($textFieldFocused) + .lineLimit(3) + } + .padding(12) + .background(RoundedRectangle(cornerRadius: 10).colorInvert().opacity(0.6)) + .padding(32) } } } diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift index 7677749385..043d0f26a9 100644 --- a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift +++ b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift @@ -3,6 +3,15 @@ import SwiftUI import shared import MapKit +struct ComposeLayer: View { + var body: some View { + ScreenTemplate(title: "Compose in SwiftUI") { + ComposeViewControllerInSwiftUI() + .ignoresSafeArea(.keyboard) // Compose has its own keyboard handler + } + } +} + struct ComposeViewControllerInSwiftUI: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { return Main_iosKt.ComposeEntryPoint() diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift index 8ab696c4b9..57050a46fd 100644 --- a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift +++ b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift @@ -15,9 +15,9 @@ struct ScreenTemplate: View { Spacer() } } - .navigationTitle(title) - .navigationBarTitleDisplayMode(.inline) - .statusBar(hidden: false) + .navigationTitle(title) + .navigationBarTitleDisplayMode(.inline) + .statusBar(hidden: false) } } } diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iOSApp.swift b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iOSApp.swift new file mode 100644 index 0000000000..4567acbc56 --- /dev/null +++ b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iOSApp.swift @@ -0,0 +1,20 @@ +import SwiftUI + +@main +struct iOSApp: App { + var body: some Scene { + WindowGroup { + TabView { + ComposeInSwiftUIScreen() + .tabItem { + Label("Compose in SwiftUI", systemImage: "star.fill") + } + + YetAnotherSwiftUIScreen() + .tabItem { + Label("SwiftUI", systemImage: "gear") + } + } + } + } +} diff --git a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift b/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift deleted file mode 100644 index dc7238bb9b..0000000000 --- a/examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift +++ /dev/null @@ -1,17 +0,0 @@ -import SwiftUI - -@main -struct iOSApp: App { - var body: some Scene { - WindowGroup { - TabView { - ComposeInSwiftUIScreen() - .tabItem { Label("Compose in SwiftUI", systemImage: "star.fill") } - - YetAnotherSwiftUIScreen() - .tabItem { Label("SwiftUI", systemImage: "gear") } - - } - } - } -} diff --git a/examples/interop/ios-swiftui-in-compose/README.md b/examples/interop/ios-swiftui-in-compose/README.md index bc4b0683f8..a32c16e04e 100644 --- a/examples/interop/ios-swiftui-in-compose/README.md +++ b/examples/interop/ios-swiftui-in-compose/README.md @@ -1,7 +1,7 @@ # SwiftUI in Compose This example shows how to use a SwiftUI view in a Compose application. -Pay attention to file [main.ios.kt](shared%2Fsrc%2FiosMain%2Fkotlin%2Fmain.ios.kt) and [ComposeViewControllerToSwiftUI.swift](iosApp%2FiosApp%2FComposeViewControllerToSwiftUI.swift) +Pay attention to file [main.ios.kt](shared%2Fsrc%2FiosMain%2Fkotlin%2Fmain.ios.kt) and [ComposeViewControllerRepresentable.swift](iosApp%2FiosApp%2FComposeViewControllerRepresentable.swift) ![screenshot.png](screenshot.png) diff --git a/examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj index 84713c6f5c..246f0f5a9a 100644 --- a/examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj @@ -8,12 +8,12 @@ /* Begin PBXBuildFile section */ 1848810122D49D4AD3668D91 /* ComposeViewControllerRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */; }; - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerRepresentable.swift; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* SwiftUIInCompose.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUIInCompose.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; @@ -51,7 +51,7 @@ isa = PBXGroup; children = ( 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iosApp.swift */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */, ); path = iosApp; @@ -155,7 +155,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerRepresentable.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iosApp.swift b/examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iOSApp.swift similarity index 53% rename from examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iosApp.swift rename to examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iOSApp.swift index 6410937b27..840b083eee 100644 --- a/examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iosApp.swift +++ b/examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iOSApp.swift @@ -4,10 +4,10 @@ import UIKit @main struct iOSApp: App { - var body: some Scene { - WindowGroup { + var body: some Scene { + WindowGroup { ComposeViewControllerRepresentable() - .ignoresSafeArea(.all) - } - } + .ignoresSafeArea(.all) + } + } } diff --git a/examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj index 18abb321d4..dda4ca8b86 100644 --- a/examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj @@ -7,13 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */; }; - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iosApp.swift */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerToSwiftUI.swift; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* UIKitInCompose.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIKitInCompose.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; @@ -51,8 +49,7 @@ isa = PBXGroup; children = ( 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iosApp.swift */, - 18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, ); path = iosApp; sourceTree = ""; @@ -155,8 +152,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, - 1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */, + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/interop/ios-uikit-in-compose/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift b/examples/interop/ios-uikit-in-compose/iosApp/iosApp/iOSApp.swift similarity index 65% rename from examples/interop/ios-uikit-in-compose/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift rename to examples/interop/ios-uikit-in-compose/iosApp/iosApp/iOSApp.swift index a774f3ff89..89d2827af1 100644 --- a/examples/interop/ios-uikit-in-compose/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift +++ b/examples/interop/ios-uikit-in-compose/iosApp/iosApp/iOSApp.swift @@ -1,7 +1,16 @@ -import UIKit import SwiftUI import shared -import MapKit +import UIKit + +@main +struct iOSApp: App { + var body: some Scene { + WindowGroup { + ComposeViewControllerToSwiftUI() + .ignoresSafeArea(.all) + } + } +} struct ComposeViewControllerToSwiftUI: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { diff --git a/examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift b/examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift deleted file mode 100644 index 37963da634..0000000000 --- a/examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift +++ /dev/null @@ -1,13 +0,0 @@ -import SwiftUI -import shared -import UIKit - -@main -struct iOSApp: App { - var body: some Scene { - WindowGroup { - ComposeViewControllerToSwiftUI() - .ignoresSafeArea(.all) - } - } -} diff --git a/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj index 83325240f4..8dcd5224ec 100644 --- a/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -18,7 +17,6 @@ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* TodoAppLite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TodoAppLite.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -63,7 +61,6 @@ isa = PBXGroup; children = ( 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, @@ -172,7 +169,6 @@ buildActionMask = 2147483647; files = ( 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/todoapp-lite/iosApp/iosApp/ContentView.swift b/examples/todoapp-lite/iosApp/iosApp/ContentView.swift deleted file mode 100644 index f7f6457b31..0000000000 --- a/examples/todoapp-lite/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -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 - } -} - - - diff --git a/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift b/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift index 0648e8602f..c659acb3d0 100644 --- a/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift +++ b/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift @@ -1,10 +1,22 @@ +import UIKit import SwiftUI +import shared @main struct iOSApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} \ No newline at end of file + var body: some Scene { + WindowGroup { + ComposeView() + .ignoresSafeArea(.keyboard) // Compose has own keyboard handler + } + } +} + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + Main_iosKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + } +} diff --git a/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj index f384c7a0b1..372dae9a78 100644 --- a/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -18,7 +17,6 @@ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 7555FF7B242A565900829871 /* WidgetsGallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WidgetsGallery.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -64,7 +62,6 @@ isa = PBXGroup; children = ( 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, 7555FF8C242A565B00829871 /* Info.plist */, 2152FB032600AC8F00CF470E /* iOSApp.swift */, 058557D7273AAEEB004C7B11 /* Preview Content */, @@ -180,7 +177,6 @@ buildActionMask = 2147483647; files = ( 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/widgets-gallery/iosApp/iosApp/ContentView.swift b/examples/widgets-gallery/iosApp/iosApp/ContentView.swift deleted file mode 100644 index f7f6457b31..0000000000 --- a/examples/widgets-gallery/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -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 - } -} - - - diff --git a/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift b/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift index 0648e8602f..c659acb3d0 100644 --- a/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift +++ b/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift @@ -1,10 +1,22 @@ +import UIKit import SwiftUI +import shared @main struct iOSApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} \ No newline at end of file + var body: some Scene { + WindowGroup { + ComposeView() + .ignoresSafeArea(.keyboard) // Compose has own keyboard handler + } + } +} + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + Main_iosKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + } +}