Skip to content

Commit 939b444

Browse files
SwiftUI wrappers for the UIKit framework
1 parent 4420291 commit 939b444

39 files changed

+1240
-43
lines changed

DemoAppUIKit/AppDelegate.swift

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Copyright © 2022 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import UIKit
6+
import StreamVideo
7+
import StreamVideoSwiftUI
8+
import StreamVideoUIKit
9+
10+
@main
11+
class AppDelegate: UIResponder, UIApplicationDelegate {
12+
13+
func application(
14+
_ application: UIApplication,
15+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
16+
) -> Bool {
17+
return true
18+
}
19+
20+
// MARK: UISceneSession Lifecycle
21+
22+
func application(
23+
_ application: UIApplication,
24+
configurationForConnecting connectingSceneSession: UISceneSession,
25+
options: UIScene.ConnectionOptions
26+
) -> UISceneConfiguration {
27+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "40.png",
5+
"idiom" : "iphone",
6+
"scale" : "2x",
7+
"size" : "20x20"
8+
},
9+
{
10+
"filename" : "60.png",
11+
"idiom" : "iphone",
12+
"scale" : "3x",
13+
"size" : "20x20"
14+
},
15+
{
16+
"filename" : "29.png",
17+
"idiom" : "iphone",
18+
"scale" : "1x",
19+
"size" : "29x29"
20+
},
21+
{
22+
"filename" : "58.png",
23+
"idiom" : "iphone",
24+
"scale" : "2x",
25+
"size" : "29x29"
26+
},
27+
{
28+
"filename" : "87.png",
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "29x29"
32+
},
33+
{
34+
"filename" : "80.png",
35+
"idiom" : "iphone",
36+
"scale" : "2x",
37+
"size" : "40x40"
38+
},
39+
{
40+
"filename" : "120.png",
41+
"idiom" : "iphone",
42+
"scale" : "3x",
43+
"size" : "40x40"
44+
},
45+
{
46+
"filename" : "57.png",
47+
"idiom" : "iphone",
48+
"scale" : "1x",
49+
"size" : "57x57"
50+
},
51+
{
52+
"filename" : "114.png",
53+
"idiom" : "iphone",
54+
"scale" : "2x",
55+
"size" : "57x57"
56+
},
57+
{
58+
"filename" : "120.png",
59+
"idiom" : "iphone",
60+
"scale" : "2x",
61+
"size" : "60x60"
62+
},
63+
{
64+
"filename" : "180.png",
65+
"idiom" : "iphone",
66+
"scale" : "3x",
67+
"size" : "60x60"
68+
},
69+
{
70+
"filename" : "20.png",
71+
"idiom" : "ipad",
72+
"scale" : "1x",
73+
"size" : "20x20"
74+
},
75+
{
76+
"filename" : "40.png",
77+
"idiom" : "ipad",
78+
"scale" : "2x",
79+
"size" : "20x20"
80+
},
81+
{
82+
"filename" : "29.png",
83+
"idiom" : "ipad",
84+
"scale" : "1x",
85+
"size" : "29x29"
86+
},
87+
{
88+
"filename" : "58.png",
89+
"idiom" : "ipad",
90+
"scale" : "2x",
91+
"size" : "29x29"
92+
},
93+
{
94+
"filename" : "40.png",
95+
"idiom" : "ipad",
96+
"scale" : "1x",
97+
"size" : "40x40"
98+
},
99+
{
100+
"filename" : "80.png",
101+
"idiom" : "ipad",
102+
"scale" : "2x",
103+
"size" : "40x40"
104+
},
105+
{
106+
"filename" : "50.png",
107+
"idiom" : "ipad",
108+
"scale" : "1x",
109+
"size" : "50x50"
110+
},
111+
{
112+
"filename" : "100.png",
113+
"idiom" : "ipad",
114+
"scale" : "2x",
115+
"size" : "50x50"
116+
},
117+
{
118+
"filename" : "72.png",
119+
"idiom" : "ipad",
120+
"scale" : "1x",
121+
"size" : "72x72"
122+
},
123+
{
124+
"filename" : "144.png",
125+
"idiom" : "ipad",
126+
"scale" : "2x",
127+
"size" : "72x72"
128+
},
129+
{
130+
"filename" : "76.png",
131+
"idiom" : "ipad",
132+
"scale" : "1x",
133+
"size" : "76x76"
134+
},
135+
{
136+
"filename" : "152.png",
137+
"idiom" : "ipad",
138+
"scale" : "2x",
139+
"size" : "76x76"
140+
},
141+
{
142+
"filename" : "167.png",
143+
"idiom" : "ipad",
144+
"scale" : "2x",
145+
"size" : "83.5x83.5"
146+
},
147+
{
148+
"filename" : "appstore.png",
149+
"idiom" : "ios-marketing",
150+
"scale" : "1x",
151+
"size" : "1024x1024"
152+
}
153+
],
154+
"info" : {
155+
"author" : "xcode",
156+
"version" : 1
157+
}
158+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>

DemoAppUIKit/HomeViewController.swift

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Copyright © 2022 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import UIKit
6+
import StreamVideo
7+
import StreamVideoUIKit
8+
import StreamVideoSwiftUI
9+
import SwiftUI
10+
11+
class HomeViewController: UIViewController {
12+
13+
let startButton = UIButton(type: .system)
14+
var textField: UITextField!
15+
var text: String = ""
16+
17+
override func viewDidLoad() {
18+
super.viewDidLoad()
19+
let stackView = UIStackView(arrangedSubviews: [
20+
createInputField(), createStartButton()
21+
])
22+
stackView.spacing = 32
23+
stackView.axis = .vertical
24+
stackView.alignment = .center
25+
stackView.distribution = .fillProportionally
26+
stackView.translatesAutoresizingMaskIntoConstraints = false
27+
view.addSubview(stackView)
28+
NSLayoutConstraint.activate([
29+
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
30+
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
31+
])
32+
self.view.backgroundColor = UIColor.white
33+
}
34+
35+
func createInputField() -> UITextField {
36+
textField = UITextField()
37+
textField.placeholder = "Insert a call id"
38+
textField.translatesAutoresizingMaskIntoConstraints = false
39+
textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
40+
return textField
41+
}
42+
43+
func createStartButton() -> UIButton {
44+
startButton.translatesAutoresizingMaskIntoConstraints = false
45+
startButton.setTitle("Start Call", for: .normal)
46+
startButton.addTarget(self, action: #selector(didTapStartButton), for: .touchUpInside)
47+
startButton.isEnabled = false
48+
return startButton
49+
}
50+
51+
@objc func textFieldDidChange() {
52+
text = textField.text ?? ""
53+
startButton.isEnabled = !text.isEmpty
54+
}
55+
56+
@objc func didTapStartButton() {
57+
let next = CallViewController.make()
58+
next.modalPresentationStyle = .fullScreen
59+
next.startCall(callId: text, participants: [])
60+
self.navigationController?.present(next, animated: true)
61+
}
62+
}

DemoAppUIKit/Info.plist

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>UIApplicationSceneManifest</key>
6+
<dict>
7+
<key>UIApplicationSupportsMultipleScenes</key>
8+
<false/>
9+
<key>UISceneConfigurations</key>
10+
<dict>
11+
<key>UIWindowSceneSessionRoleApplication</key>
12+
<array>
13+
<dict>
14+
<key>UISceneConfigurationName</key>
15+
<string>Default Configuration</string>
16+
<key>UISceneDelegateClassName</key>
17+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
18+
</dict>
19+
</array>
20+
</dict>
21+
</dict>
22+
</dict>
23+
</plist>
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright © 2022 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import UIKit
6+
import StreamVideo
7+
import StreamVideoSwiftUI
8+
import SwiftUI
9+
10+
class LoginViewController: UIViewController {
11+
12+
var onUserSelected: ((UserCredentials) -> ())?
13+
14+
override func viewDidLoad() {
15+
super.viewDidLoad()
16+
}
17+
18+
override func viewWillAppear(_ animated: Bool) {
19+
super.viewWillAppear(animated)
20+
let loginView = LoginView { [weak self] credentials in
21+
self?.onUserSelected?(credentials)
22+
}
23+
let loginVC = UIHostingController(rootView: loginView)
24+
if let loginVCView = loginVC.view {
25+
view.embed(loginVCView.withoutAutoresizingMaskConstraints)
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)