Skip to content

Commit

Permalink
Add SwiftUI usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanRafique committed Jun 22, 2022
1 parent b93aa5c commit c1fa331
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 747 deletions.
4 changes: 4 additions & 0 deletions Example/ImaginaryDemo/ImaginaryDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
295D77431C07122700C43B07 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 295D77411C07122700C43B07 /* LaunchScreen.storyboard */; };
29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FC0C2A1C07268100B66E11 /* FeedTableViewCell.swift */; };
938EF94E073488BB7B5AE1F1 /* Pods_ImaginaryDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C16C258DB463D5FFF1DD607 /* Pods_ImaginaryDemo.framework */; };
F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F560478928621EC1008ED0AC /* SwiftUIViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -27,6 +28,7 @@
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>"; };
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>"; };
F0A3FBC34DFEEC7A04F84F11 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F560478928621EC1008ED0AC /* SwiftUIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -68,6 +70,7 @@
295D773F1C07122700C43B07 /* Assets.xcassets */,
295D77411C07122700C43B07 /* LaunchScreen.storyboard */,
295D77441C07122700C43B07 /* Info.plist */,
F560478928621EC1008ED0AC /* SwiftUIViewController.swift */,
);
path = ImaginaryDemo;
sourceTree = "<group>";
Expand Down Expand Up @@ -203,6 +206,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F560478A28621EC1008ED0AC /* SwiftUIViewController.swift in Sources */,
295D773B1C07122700C43B07 /* ViewController.swift in Sources */,
29FC0C2B1C07268100B66E11 /* FeedTableViewCell.swift in Sources */,
295D77391C07122700C43B07 /* AppDelegate.swift in Sources */,
Expand Down
30 changes: 16 additions & 14 deletions Example/ImaginaryDemo/ImaginaryDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

lazy var viewController: ViewController = ViewController()

var window: UIWindow?

lazy var viewController: ViewController = ViewController()
lazy var swiftUIViewController: SwiftUIViewController = SwiftUIViewController()
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let navigationController = UINavigationController(rootViewController: viewController)
viewController.title = "Imaginary".uppercased()

window = UIWindow()
window?.rootViewController = navigationController
window?.makeKeyAndVisible()

return true
}
let tabVC = UITabBarController()
viewController.tabBarItem.title = "UIKit"
swiftUIViewController.tabBarItem.title = "SwiftUI"
tabVC.setViewControllers([viewController, swiftUIViewController], animated: true)

window = UIWindow()
window?.rootViewController = tabVC
window?.makeKeyAndVisible()

return true
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
//
// ContentView.swift
// ImaginarySwiftUIDemo
// SwiftUIViewController.swift
// ImaginaryDemo
//
// Created by Arslan Rafique on 2022-06-21.
// Copyright © 2022 Ramon Gilabert Llop. All rights reserved.
//

import SwiftUI
import Imaginary

struct ContentView: SwiftUI.View {

struct Constants {
static let imageWidth = 500
static let imageHeight = 500
Expand All @@ -28,7 +29,7 @@ struct ContentView: SwiftUI.View {

return array
}()

var body: some SwiftUI.View {
ScrollView {
VStack {
Expand All @@ -41,8 +42,11 @@ struct ContentView: SwiftUI.View {
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some SwiftUI.View {
ContentView()
class SwiftUIViewController: UITableViewController {
override func viewDidLoad() {
let hosting = UIHostingController(rootView: ContentView())
self.addChild(hosting)
self.view.addSubview(hosting.view)
hosting.view.frame = UIScreen.main.bounds
}
}
Loading

0 comments on commit c1fa331

Please sign in to comment.