Skip to content

Commit c1fa331

Browse files
committed
Add SwiftUI usage
1 parent b93aa5c commit c1fa331

File tree

17 files changed

+46
-747
lines changed

17 files changed

+46
-747
lines changed

Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
295D77431C07122700C43B07 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 295D77411C07122700C43B07 /* LaunchScreen.storyboard */; };
1414
29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FC0C2A1C07268100B66E11 /* FeedTableViewCell.swift */; };
1515
938EF94E073488BB7B5AE1F1 /* Pods_ImaginaryDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C16C258DB463D5FFF1DD607 /* Pods_ImaginaryDemo.framework */; };
16+
F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F560478928621EC1008ED0AC /* SwiftUIViewController.swift */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXFileReference section */
@@ -27,6 +28,7 @@
2728
311B2CD8C66C552F516784F2 /* Pods-ImaginaryDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImaginaryDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-ImaginaryDemo/Pods-ImaginaryDemo.release.xcconfig"; sourceTree = "<group>"; };
2829
46273A36A5534213CB1EF279 /* Pods-ImaginaryDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImaginaryDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ImaginaryDemo/Pods-ImaginaryDemo.debug.xcconfig"; sourceTree = "<group>"; };
2930
F0A3FBC34DFEEC7A04F84F11 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
31+
F560478928621EC1008ED0AC /* SwiftUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewController.swift; sourceTree = "<group>"; };
3032
/* End PBXFileReference section */
3133

3234
/* Begin PBXFrameworksBuildPhase section */
@@ -68,6 +70,7 @@
6870
295D773F1C07122700C43B07 /* Assets.xcassets */,
6971
295D77411C07122700C43B07 /* LaunchScreen.storyboard */,
7072
295D77441C07122700C43B07 /* Info.plist */,
73+
F560478928621EC1008ED0AC /* SwiftUIViewController.swift */,
7174
);
7275
path = ImaginaryDemo;
7376
sourceTree = "<group>";
@@ -203,6 +206,7 @@
203206
isa = PBXSourcesBuildPhase;
204207
buildActionMask = 2147483647;
205208
files = (
209+
F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */,
206210
295D773B1C07122700C43B07 /* ViewController.swift in Sources */,
207211
29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */,
208212
295D77391C07122700C43B07 /* AppDelegate.swift in Sources */,

Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import UIKit
22

33
@UIApplicationMain
44
class AppDelegate: UIResponder, UIApplicationDelegate {
5-
6-
lazy var viewController: ViewController = ViewController()
7-
8-
var window: UIWindow?
9-
5+
lazy var viewController: ViewController = ViewController()
6+
lazy var swiftUIViewController: SwiftUIViewController = SwiftUIViewController()
7+
8+
var window: UIWindow?
9+
1010
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
11-
let navigationController = UINavigationController(rootViewController: viewController)
12-
viewController.title = "Imaginary".uppercased()
13-
14-
window = UIWindow()
15-
window?.rootViewController = navigationController
16-
window?.makeKeyAndVisible()
17-
18-
return true
19-
}
11+
let tabVC = UITabBarController()
12+
viewController.tabBarItem.title = "UIKit"
13+
swiftUIViewController.tabBarItem.title = "SwiftUI"
14+
tabVC.setViewControllers([viewController, swiftUIViewController], animated: true)
15+
16+
window = UIWindow()
17+
window?.rootViewController = tabVC
18+
window?.makeKeyAndVisible()
19+
20+
return true
21+
}
2022
}

Example/ImaginarySwiftUIDemo/ImaginarySwiftUIDemo/ContentView.swift renamed to Example/ImaginaryDemo/ImaginaryDemo/SwiftUIViewController.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
//
2-
// ContentView.swift
3-
// ImaginarySwiftUIDemo
2+
// SwiftUIViewController.swift
3+
// ImaginaryDemo
44
//
55
// Created by Arslan Rafique on 2022-06-21.
6+
// Copyright © 2022 Ramon Gilabert Llop. All rights reserved.
67
//
78

89
import SwiftUI
910
import Imaginary
1011

1112
struct ContentView: SwiftUI.View {
12-
13+
1314
struct Constants {
1415
static let imageWidth = 500
1516
static let imageHeight = 500
@@ -28,7 +29,7 @@ struct ContentView: SwiftUI.View {
2829

2930
return array
3031
}()
31-
32+
3233
var body: some SwiftUI.View {
3334
ScrollView {
3435
VStack {
@@ -41,8 +42,11 @@ struct ContentView: SwiftUI.View {
4142
}
4243
}
4344

44-
struct ContentView_Previews: PreviewProvider {
45-
static var previews: some SwiftUI.View {
46-
ContentView()
45+
class SwiftUIViewController: UITableViewController {
46+
override func viewDidLoad() {
47+
let hosting = UIHostingController(rootView: ContentView())
48+
self.addChild(hosting)
49+
self.view.addSubview(hosting.view)
50+
hosting.view.frame = UIScreen.main.bounds
4751
}
4852
}

0 commit comments

Comments
 (0)