|
@@ -9,6 +9,7 @@ import Foundation
|
|
|
import UIKit
|
|
|
import FMDB
|
|
|
import NotificationBannerSwift
|
|
|
+import Toast_Swift
|
|
|
|
|
|
public class APIS: NSObject {
|
|
|
public static func connect(apiKey: String, delegate: ConnectDelegate, showButton: Bool = true) {
|
|
@@ -119,6 +120,39 @@ public class APIS: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static func startChat(name: String) {
|
|
|
+ if name.isEmpty {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("92:Username is empty".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let user = User.getDataFromNameCanNil(name: name)
|
|
|
+ if user == nil {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("91:Invalid name or you must add Username to your contact first".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
|
|
|
+ editorPersonalVC.hidesBottomBarWhenPushed = true
|
|
|
+ editorPersonalVC.unique_l_pin = user!.pin
|
|
|
+ editorPersonalVC.fromNotification = true
|
|
|
+ let navigationController = UINavigationController(rootViewController: editorPersonalVC)
|
|
|
+ navigationController.modalPresentationStyle = .fullScreen
|
|
|
+ navigationController.navigationBar.tintColor = .white
|
|
|
+ navigationController.navigationBar.barTintColor = .mainColor
|
|
|
+ navigationController.navigationBar.isTranslucent = false
|
|
|
+ navigationController.navigationBar.overrideUserInterfaceStyle = .dark
|
|
|
+ navigationController.navigationBar.barStyle = .black
|
|
|
+ let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white]
|
|
|
+ UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
|
|
|
+ let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
|
|
|
+ navigationController.navigationBar.titleTextAttributes = textAttributes
|
|
|
+ navigationController.view.backgroundColor = .mainColor
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static func openCall() {
|
|
|
let isChangeProfile = Utils.getSetProfile()
|
|
|
if !isChangeProfile {
|
|
@@ -182,6 +216,34 @@ public class APIS: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static func startAudioCall(name: String) {
|
|
|
+ if name.isEmpty {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("92:Username is empty".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let user = User.getDataFromNameCanNil(name: name)
|
|
|
+ if user == nil {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("91:Invalid name or you must add Username to your contact first".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !CheckConnection.isConnectedToNetwork() {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ banner.show()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let controller = QmeraAudioViewController()
|
|
|
+ controller.user = user
|
|
|
+ controller.isOutgoing = true
|
|
|
+ controller.modalPresentationStyle = .overFullScreen
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(controller, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(controller, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static func openVideoCall() {
|
|
|
let isChangeProfile = Utils.getSetProfile()
|
|
|
if !isChangeProfile {
|
|
@@ -199,6 +261,42 @@ public class APIS: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static func startVideoCall(name: String) {
|
|
|
+ if name.isEmpty {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("92:Username is empty".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let user = User.getDataFromNameCanNil(name: name)
|
|
|
+ if user == nil {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("91:Invalid name or you must add Username to your contact first".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !CheckConnection.isConnectedToNetwork() {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ banner.show()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let videoVC = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "videoVCQmera") as! QmeraVideoViewController
|
|
|
+ var data: [String: String?] = [:]
|
|
|
+ data["f_pin"] = user!.pin
|
|
|
+ data["name"] = user!.fullName
|
|
|
+ data["picture"] = user!.thumb
|
|
|
+ data["isOfficial"] = user!.official
|
|
|
+ data["deviceId"] = user!.device_id
|
|
|
+ data["isOffline"] = user!.offline_mode
|
|
|
+ data["user_type"] = user!.userType
|
|
|
+ videoVC.dataPerson.append(data)
|
|
|
+ videoVC.isPresent = true
|
|
|
+ videoVC.modalPresentationStyle = .overFullScreen
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(videoVC, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(videoVC, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static func openBroadcastForm() {
|
|
|
let isChangeProfile = Utils.getSetProfile()
|
|
|
if !isChangeProfile {
|
|
@@ -357,6 +455,34 @@ public class APIS: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static func startWhiteboard(name: String) {
|
|
|
+ if name.isEmpty {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("92:Username is empty".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let user = User.getDataFromNameCanNil(name: name)
|
|
|
+ if user == nil {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("91:Invalid name or you must add Username to your contact first".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !CheckConnection.isConnectedToNetwork() {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ banner.show()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "wbVC") as! WhiteboardViewController
|
|
|
+ controller.modalPresentationStyle = .overFullScreen
|
|
|
+ controller.fromContact = 0
|
|
|
+ controller.user = user
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(controller, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(controller, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static func openScreenSharing() {
|
|
|
let isChangeProfile = Utils.getSetProfile()
|
|
|
if !isChangeProfile {
|
|
@@ -373,6 +499,52 @@ public class APIS: NSObject {
|
|
|
UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static func startScreenSharing(name: String) {
|
|
|
+ if name.isEmpty {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("92:Username is empty".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let user = User.getDataFromNameCanNil(name: name)
|
|
|
+ if user == nil {
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("91:Invalid name or you must add Username to your contact first".localized(), duration: 2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !CheckConnection.isConnectedToNetwork() {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ banner.show()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let controller = ScreenSharingViewController()
|
|
|
+ controller.modalPresentationStyle = .overFullScreen
|
|
|
+ controller.fromContact = 0
|
|
|
+ controller.user = user
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(controller, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(controller, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static func openWhiteboardAndScreenSharing() {
|
|
|
+ let isChangeProfile = Utils.getSetProfile()
|
|
|
+ if !isChangeProfile {
|
|
|
+ APIS.showChangeProfile()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let callContact = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactSID") as! ContactCallViewController
|
|
|
+ callContact.startSS = true
|
|
|
+ callContact.startWhiteBoard = true
|
|
|
+ let navigationController = UINavigationController(rootViewController: callContact)
|
|
|
+ navigationController.defaultStyle()
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ } else {
|
|
|
+ UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension UINavigationController {
|