Skip to content

Commit f2e0008

Browse files
Merge pull request #1367 from QuickBlox/Release-UIKit-Sample-1.1.1
Release UIKit Sample 1.1.0
2 parents 05e50e8 + 3d686bf commit f2e0008

File tree

6 files changed

+131
-106
lines changed

6 files changed

+131
-106
lines changed

sample-ui-kit/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Quickblox.initWithApplicationId(92,
5656

5757
# QBAIAnswerAssistant
5858

59+
[Video tutorial](https://youtu.be/1HaTipnH2VY)
60+
5961
QBAIAnswerAssistant is a Swift package that helps generate answers in a chat based on the history.
6062

6163
Installation

sample-ui-kit/UIKitSample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
"$(inherited)",
485485
"$(SRCROOT)/../ios-ui-kit-private/Sources/QuickBloxUIKit/**",
486486
);
487-
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
487+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
488488
LIBRARY_SEARCH_PATHS = (
489489
"$(inherited)",
490490
"$(SRCROOT)/../ios-ui-kit-private/Sources/QuickBloxUIKit/**",
@@ -551,7 +551,7 @@
551551
"$(inherited)",
552552
"$(SRCROOT)/../ios-ui-kit-private/Sources/QuickBloxUIKit/**",
553553
);
554-
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
554+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
555555
LIBRARY_SEARCH_PATHS = (
556556
"$(inherited)",
557557
"$(SRCROOT)/../ios-ui-kit-private/Sources/QuickBloxUIKit/**",
@@ -595,7 +595,7 @@
595595
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeRight";
596596
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
597597
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
598-
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
598+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
599599
LD_RUNPATH_SEARCH_PATHS = (
600600
"$(inherited)",
601601
"@executable_path/Frameworks",
@@ -643,7 +643,7 @@
643643
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeRight";
644644
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
645645
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
646-
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
646+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
647647
LD_RUNPATH_SEARCH_PATHS = (
648648
"$(inherited)",
649649
"@executable_path/Frameworks",

sample-ui-kit/UIKitSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"kind" : "remoteSourceControl",
4242
"location" : "https://github.com/QuickBlox/ios-ui-kit.git",
4343
"state" : {
44-
"revision" : "8e2dc71ee9fe53fcdc65b7c4b0a7215fec41f0e6",
45-
"version" : "0.3.0"
44+
"revision" : "a59acec737b49b2a0c069016179644703b3374f1",
45+
"version" : "0.3.1"
4646
}
4747
}
4848
],

sample-ui-kit/UIKitSample/Connect.swift

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import SwiftUI
10+
import Combine
1011
import Quickblox
1112

1213
enum ConnectState {
@@ -19,16 +20,22 @@ enum ConnectState {
1920

2021
enum AuthState {
2122
case authorized
23+
case authorization
2224
case unAuthorized
2325
}
2426

2527
class Connect: ObservableObject {
26-
@Published var authState: AuthState = .unAuthorized
27-
@Published var state: ConnectState = .waiting
28+
29+
public let objectWillChange = PassthroughSubject<AuthState, Never>()
30+
31+
@Published var authState: AuthState = .unAuthorized {
32+
didSet {
33+
objectWillChange.send(authState)
34+
}
35+
}
2836
@Published var isConnected: Bool = false
2937

3038
init(state: ConnectState = .disconnected) {
31-
self.state = state
3239

3340
Quickblox.initWithApplicationId(0,
3441
authKey: "",
@@ -40,32 +47,35 @@ class Connect: ObservableObject {
4047
}
4148

4249
func login(withLogin login: String, password: String) {
43-
state = .waiting
50+
authState = .authorization
4451
QBRequest.logIn(withUserLogin: login.trimmingCharacters(in: .whitespacesAndNewlines),
4552
password: password.trimmingCharacters(in: .whitespacesAndNewlines)) { [weak self] response, user in
4653
guard QBSession.current.sessionDetails?.token != nil else {
4754
print("Login Error: \(response)")
48-
self?.state = .disconnected
49-
self?.authState = .unAuthorized
55+
DispatchQueue.main.async {
56+
self?.authState = .unAuthorized
57+
}
5058
return
5159
}
52-
self?.authState = .authorized
60+
DispatchQueue.main.async {
61+
self?.authState = .authorized
62+
}
5363
} errorBlock: { [weak self] response in
5464
if response.status == QBResponseStatusCode.unAuthorized {
5565
// The user with existent login was created earlier
56-
self?.state = .unAuthorized
5766
self?.authState = .unAuthorized
5867
return
5968
}
6069
print("Login Error: \(response)")
61-
self?.authState = .unAuthorized
62-
self?.state = .disconnected
70+
DispatchQueue.main.async {
71+
self?.authState = .unAuthorized
72+
}
6373
return
6474
}
6575
}
6676

6777
func signUp(withLogin login: String, displayName: String, password: String) {
68-
state = .waiting
78+
authState = .authorization
6979
let newUser = QBUUser()
7080
newUser.login = login.trimmingCharacters(in: .whitespacesAndNewlines)
7181
newUser.fullName = displayName
@@ -76,35 +86,23 @@ class Connect: ObservableObject {
7686
if response.status == QBResponseStatusCode.validationFailed {
7787
// The user with existent login was created earlier
7888
self?.login(withLogin: login, password: password)
79-
self?.state = .waiting
8089
return
8190
}
8291
print("Login Error: \(response)")
83-
self?.state = .disconnected
92+
DispatchQueue.main.async {
93+
self?.authState = .unAuthorized
94+
}
8495
return
8596
})
8697
}
8798

88-
func connect(withUserID userId: UInt) {
89-
state = .waiting
90-
guard let token = QBSession.current.sessionDetails?.token else {
91-
self.state = .disconnected
92-
return
93-
}
94-
QBChat.instance.connect(withUserID: userId, password: token) { [weak self] _ in
95-
self?.isConnected = true
96-
self?.state = .connected
97-
print("Success connect")
98-
}
99-
}
100-
10199
func disconnect() {
102-
state = .waiting
103100
QBChat.instance.disconnect() {_ in
104101
self.isConnected = false
105-
self.state = .disconnected
106102
QBRequest.logOut { [weak self] response in
107-
self?.authState = .unAuthorized
103+
DispatchQueue.main.async {
104+
self?.authState = .unAuthorized
105+
}
108106
print("Success disconnect")
109107
}
110108
}

0 commit comments

Comments
 (0)