Browse Source

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 <ivan.matkov@jetbrains.com>
pull/3618/head
dima.avdeev 1 year ago committed by GitHub
parent
commit
255c36a0ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj
  2. 4
      examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift
  3. 6
      examples/chat/iosApp/iosApp/GradientTemplate.swift
  4. 30
      examples/chat/iosApp/iosApp/iOSApp.swift
  5. 26
      examples/chat/iosApp/iosApp/iosApp.swift
  6. 4
      examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj
  7. 21
      examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift
  8. 27
      examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift
  9. 4
      examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj
  10. 21
      examples/codeviewer/iosApp/iosApp/ContentView.swift
  11. 27
      examples/codeviewer/iosApp/iosApp/iOSApp.swift
  12. 4
      examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj
  13. 37
      examples/imageviewer/iosApp/iosApp/ContentView.swift
  14. 41
      examples/imageviewer/iosApp/iosApp/iOSApp.swift
  15. 8
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp.xcodeproj/project.pbxproj
  16. 25
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift
  17. 9
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift
  18. 6
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift
  19. 20
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iOSApp.swift
  20. 17
      examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift
  21. 2
      examples/interop/ios-swiftui-in-compose/README.md
  22. 8
      examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj
  23. 10
      examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iOSApp.swift
  24. 12
      examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj
  25. 13
      examples/interop/ios-uikit-in-compose/iosApp/iosApp/iOSApp.swift
  26. 13
      examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift
  27. 4
      examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj
  28. 21
      examples/todoapp-lite/iosApp/iosApp/ContentView.swift
  29. 22
      examples/todoapp-lite/iosApp/iosApp/iOSApp.swift
  30. 4
      examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj
  31. 21
      examples/widgets-gallery/iosApp/iosApp/ContentView.swift
  32. 22
      examples/widgets-gallery/iosApp/iosApp/iOSApp.swift

8
examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj

@ -12,7 +12,7 @@
184881FBE98BA5BF02A0A186 /* GradientTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1848892FA748717E4087E7D7 /* GradientTemplate.swift */; }; 184881FBE98BA5BF02A0A186 /* GradientTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1848892FA748717E4087E7D7 /* GradientTemplate.swift */; };
1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; }; 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; };
184882D8AF2A7A3642004010 /* ComposeInsideSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -21,7 +21,7 @@
1848892FA748717E4087E7D7 /* GradientTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientTemplate.swift; sourceTree = "<group>"; }; 1848892FA748717E4087E7D7 /* GradientTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientTemplate.swift; sourceTree = "<group>"; };
18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInsideSwiftUIScreen.swift; sourceTree = "<group>"; }; 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInsideSwiftUIScreen.swift; sourceTree = "<group>"; };
18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KotlinToSwiftHelper.swift; sourceTree = "<group>"; }; 18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KotlinToSwiftHelper.swift; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* Chat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Chat.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
@ -59,7 +59,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iosApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */,
18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */, 18488D89B8500CD7696A04EB /* KotlinToSwiftHelper.swift */,
18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */, 18488CAB0978B80826E5BBB4 /* ComposeInsideSwiftUIScreen.swift */,
@ -167,7 +167,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */,
184880BA0E9910C2B5012412 /* KotlinToSwiftHelper.swift in Sources */, 184880BA0E9910C2B5012412 /* KotlinToSwiftHelper.swift in Sources */,
184882D8AF2A7A3642004010 /* ComposeInsideSwiftUIScreen.swift in Sources */, 184882D8AF2A7A3642004010 /* ComposeInsideSwiftUIScreen.swift in Sources */,

4
examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift

@ -30,8 +30,8 @@ struct TextInputLayer: View {
Spacer() Spacer()
HStack { HStack {
TextField("Type message...", text: $textState, axis: .vertical) TextField("Type message...", text: $textState, axis: .vertical)
.focused($textFieldFocused) .focused($textFieldFocused)
.lineLimit(3) .lineLimit(3)
if (!textState.isEmpty) { if (!textState.isEmpty) {
Button(action: { Button(action: {
sendMessage(textState) sendMessage(textState)

6
examples/chat/iosApp/iosApp/GradientTemplate.swift

@ -18,9 +18,9 @@ struct GradientTemplate<Content: View>: View {
Rectangle().frame(height: 0).background(gradient) Rectangle().frame(height: 0).background(gradient)
} }
} }
.navigationTitle(title) .navigationTitle(title)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.statusBar(hidden: false) .statusBar(hidden: false)
} }
} }
} }

30
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)
}
}
}

26
examples/chat/iosApp/iosApp/iosApp.swift

@ -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)
}
}
}

4
examples/cocoapods-ios-example/iosApp/iosApp.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview 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 */; }; 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 */; }; CFDB58B53BB94DE262B13C24 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */; };
/* End PBXBuildFile section */ /* 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 = "<group>"; }; 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 = "<group>"; };
6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 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; }; 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 = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
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 = "<group>"; }; 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 = "<group>"; };
@ -78,7 +76,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */, 058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ContentView.swift */,
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */, 058557D7273AAEEB004C7B11 /* Preview Content */,
@ -218,7 +215,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

21
examples/cocoapods-ios-example/iosApp/iosApp/ContentView.swift

@ -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
}
}

27
examples/cocoapods-ios-example/iosApp/iosApp/iOSApp.swift

@ -1,13 +1,24 @@
import UIKit
import SwiftUI import SwiftUI
import shared
@main @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ZStack { ZStack {
Color.white.ignoresSafeArea(.all) // status bar color Color.white.ignoresSafeArea(.all) // status bar color
ContentView() ComposeView()
}.preferredColorScheme(.light) .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) {}
} }

4
examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview 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 */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -18,7 +17,6 @@
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* Codeviewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Codeviewer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -63,7 +61,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */, 058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ContentView.swift */,
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */, 058557D7273AAEEB004C7B11 /* Preview Content */,
@ -172,7 +169,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

21
examples/codeviewer/iosApp/iosApp/ContentView.swift

@ -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
}
}

27
examples/codeviewer/iosApp/iosApp/iOSApp.swift

@ -1,13 +1,24 @@
import UIKit
import SwiftUI import SwiftUI
import shared
@main @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ZStack { ZStack {
Color(#colorLiteral(red: 0.235, green: 0.247, blue: 0.255, alpha: 1)).ignoresSafeArea(.all) Color(#colorLiteral(red: 0.235, green: 0.247, blue: 0.255, alpha: 1)).ignoresSafeArea(.all)
ContentView() ComposeView()
}.preferredColorScheme(.dark) .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) {}
} }

4
examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview 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 */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -18,7 +17,6 @@
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* My Memories.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "My Memories.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -64,7 +62,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */, 058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ContentView.swift */,
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */, 058557D7273AAEEB004C7B11 /* Preview Content */,
@ -180,7 +177,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

37
examples/imageviewer/iosApp/iosApp/ContentView.swift

@ -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)
}
}

41
examples/imageviewer/iosApp/iosApp/iOSApp.swift

@ -1,10 +1,41 @@
import UIKit
import SwiftUI 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 @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() 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) {
}
} }

8
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 */; }; 184881FBE98BA5BF02A0A186 /* ScreenTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1848892FA748717E4087E7D7 /* ScreenTemplate.swift */; };
1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; }; 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */; };
184882D8AF2A7A3642004010 /* ComposeInSwiftUIScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -19,7 +19,7 @@
18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerInSwiftUI.swift; sourceTree = "<group>"; }; 18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerInSwiftUI.swift; sourceTree = "<group>"; };
1848892FA748717E4087E7D7 /* ScreenTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScreenTemplate.swift; sourceTree = "<group>"; }; 1848892FA748717E4087E7D7 /* ScreenTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScreenTemplate.swift; sourceTree = "<group>"; };
18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInSwiftUIScreen.swift; sourceTree = "<group>"; }; 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeInSwiftUIScreen.swift; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* ComposeInSwiftUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ComposeInSwiftUI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
@ -57,7 +57,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iosApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerInSwiftUI.swift */,
18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */, 18488CAB0978B80826E5BBB4 /* ComposeInSwiftUIScreen.swift */,
18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */, 18488451271FAAD8FA34A2FB /* YetAnotherSwiftUIScreen.swift */,
@ -164,7 +164,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
1848810122D49D4AD3668D91 /* ComposeViewControllerInSwiftUI.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerInSwiftUI.swift in Sources */,
184882D8AF2A7A3642004010 /* ComposeInSwiftUIScreen.swift in Sources */, 184882D8AF2A7A3642004010 /* ComposeInSwiftUIScreen.swift in Sources */,
1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */, 1848823F43E447F9A8B4AC7C /* YetAnotherSwiftUIScreen.swift in Sources */,

25
examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeInSwiftUIScreen.swift

@ -5,19 +5,11 @@ struct ComposeInSwiftUIScreen: View {
ZStack { ZStack {
ComposeLayer() ComposeLayer()
TextInputLayer() 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() Spacer()
VStack { VStack {
TextField("empty TextField", text: $textState, axis: .vertical) TextField("empty TextField", text: $textState, axis: .vertical)
.focused($textFieldFocused) .focused($textFieldFocused)
.lineLimit(3) .lineLimit(3)
}.padding(12).background(RoundedRectangle(cornerRadius: 10).colorInvert().opacity(0.6)).padding(32) }
.padding(12)
.background(RoundedRectangle(cornerRadius: 10).colorInvert().opacity(0.6))
.padding(32)
} }
} }
} }

9
examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ComposeViewControllerInSwiftUI.swift

@ -3,6 +3,15 @@ import SwiftUI
import shared import shared
import MapKit 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 { struct ComposeViewControllerInSwiftUI: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController { func makeUIViewController(context: Context) -> UIViewController {
return Main_iosKt.ComposeEntryPoint() return Main_iosKt.ComposeEntryPoint()

6
examples/interop/ios-compose-in-swiftui/iosApp/iosApp/ScreenTemplate.swift

@ -15,9 +15,9 @@ struct ScreenTemplate<Content: View>: View {
Spacer() Spacer()
} }
} }
.navigationTitle(title) .navigationTitle(title)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.statusBar(hidden: false) .statusBar(hidden: false)
} }
} }
} }

20
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")
}
}
}
}
}

17
examples/interop/ios-compose-in-swiftui/iosApp/iosApp/iosApp.swift

@ -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") }
}
}
}
}

2
examples/interop/ios-swiftui-in-compose/README.md

@ -1,7 +1,7 @@
# SwiftUI in Compose # SwiftUI in Compose
This example shows how to use a SwiftUI view in a Compose application. 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) ![screenshot.png](screenshot.png)

8
examples/interop/ios-swiftui-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj

@ -8,12 +8,12 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1848810122D49D4AD3668D91 /* ComposeViewControllerRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerRepresentable.swift; sourceTree = "<group>"; }; 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerRepresentable.swift; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* SwiftUIInCompose.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUIInCompose.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
@ -51,7 +51,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iosApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */, 18488656503C85EEDA66341D /* ComposeViewControllerRepresentable.swift */,
); );
path = iosApp; path = iosApp;
@ -155,7 +155,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
1848810122D49D4AD3668D91 /* ComposeViewControllerRepresentable.swift in Sources */, 1848810122D49D4AD3668D91 /* ComposeViewControllerRepresentable.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

10
examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iosApp.swift → examples/interop/ios-swiftui-in-compose/iosApp/iosApp/iOSApp.swift

@ -4,10 +4,10 @@ import UIKit
@main @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ComposeViewControllerRepresentable() ComposeViewControllerRepresentable()
.ignoresSafeArea(.all) .ignoresSafeArea(.all)
} }
} }
} }

12
examples/interop/ios-uikit-in-compose/iosApp/iosApp.xcodeproj/project.pbxproj

@ -7,13 +7,11 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComposeViewControllerToSwiftUI.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* UIKitInCompose.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIKitInCompose.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
@ -51,8 +49,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iosApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
18488656503C85EEDA66341D /* ComposeViewControllerToSwiftUI.swift */,
); );
path = iosApp; path = iosApp;
sourceTree = "<group>"; sourceTree = "<group>";
@ -155,8 +152,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iosApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
1848810122D49D4AD3668D91 /* ComposeViewControllerToSwiftUI.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

13
examples/interop/ios-uikit-in-compose/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift → examples/interop/ios-uikit-in-compose/iosApp/iosApp/iOSApp.swift

@ -1,7 +1,16 @@
import UIKit
import SwiftUI import SwiftUI
import shared import shared
import MapKit import UIKit
@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
ComposeViewControllerToSwiftUI()
.ignoresSafeArea(.all)
}
}
}
struct ComposeViewControllerToSwiftUI: UIViewControllerRepresentable { struct ComposeViewControllerToSwiftUI: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController { func makeUIViewController(context: Context) -> UIViewController {

13
examples/interop/ios-uikit-in-compose/iosApp/iosApp/iosApp.swift

@ -1,13 +0,0 @@
import SwiftUI
import shared
import UIKit
@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
ComposeViewControllerToSwiftUI()
.ignoresSafeArea(.all)
}
}
}

4
examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview 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 */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -18,7 +17,6 @@
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* TodoAppLite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TodoAppLite.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -63,7 +61,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */, 058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ContentView.swift */,
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */, 058557D7273AAEEB004C7B11 /* Preview Content */,
@ -172,7 +169,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

21
examples/todoapp-lite/iosApp/iosApp/ContentView.swift

@ -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
}
}

22
examples/todoapp-lite/iosApp/iosApp/iOSApp.swift

@ -1,10 +1,22 @@
import UIKit
import SwiftUI import SwiftUI
import shared
@main @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() 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) {
}
} }

4
examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview 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 */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -18,7 +17,6 @@
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* WidgetsGallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WidgetsGallery.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -64,7 +62,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */, 058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ContentView.swift */,
7555FF8C242A565B00829871 /* Info.plist */, 7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */, 2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */, 058557D7273AAEEB004C7B11 /* Preview Content */,
@ -180,7 +177,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

21
examples/widgets-gallery/iosApp/iosApp/ContentView.swift

@ -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
}
}

22
examples/widgets-gallery/iosApp/iosApp/iOSApp.swift

@ -1,10 +1,22 @@
import UIKit
import SwiftUI import SwiftUI
import shared
@main @main
struct iOSApp: App { struct iOSApp: App {
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() 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) {
}
} }
Loading…
Cancel
Save