123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- //
- // ViewController.swift
- // TestQmeraLite
- //
- // Created by Qindi on 29/11/21.
- //
- import UIKit
- import NexilisLite
- import AVKit
- import AVFoundation
- import SwiftUI
- import Speech
- import Alamofire
- class ViewController: UITabBarController, UITabBarControllerDelegate {
- let playerController = AVPlayerViewController()
- static var sURL = "https://www.google.com"
- static var tab3 = "0"
- public var isShow: Bool = false
- public static var chatButton = UIButton()
- public static var callButton = UIButton()
- public static var ccButton = UIButton()
- public static var streamingButton = UIButton()
- public static var postButton = UIButton()
- public static var middleButton = UIButton()
- var buttonChatGR : UITapGestureRecognizer?
- var buttonCallGR : UITapGestureRecognizer?
- var buttonCCGR : UITapGestureRecognizer?
- var buttonStreamGR : UITapGestureRecognizer?
- var floating : FloatingButton?
- var firstTab : FirstTabViewController?
- var secondTab : SecondTabViewController?
- var thirdTab : ThirdTabViewController?
- var fourthTab : FourthTabViewController?
- let emptyTab = EmptyTabViewController()
- public static var isTab1 = true
- public static var isTab2 = false
- public static var isTab3 = false
- public static var isTab4 = false
- public static var isExpandButton = false
- public static var alwaysHideButton = false
-
- public static var def: ViewController?
- override func viewDidLoad() {
- super.viewDidLoad()
- ViewController.def = self
- title = Bundle.main.displayName
- let customTab = PrefsUtil.getCustomTab().split(separator: ",")
- let cpaasMode = PrefsUtil.getCpaasMode()
- var tabs : [UIViewController] = []
- firstTab = storyboard?.instantiateViewController(withIdentifier: "firstTabVC") as? FirstTabViewController
- secondTab = storyboard?.instantiateViewController(withIdentifier: "secondTabVC") as? SecondTabViewController
- thirdTab = storyboard?.instantiateViewController(withIdentifier: "thirdTabVC") as? ThirdTabViewController
- fourthTab = storyboard?.instantiateViewController(withIdentifier: "fourthTabVC") as? FourthTabViewController
-
- self.delegate = self
-
-
- firstTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
- firstTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
- secondTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
- secondTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
- thirdTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
- thirdTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
- fourthTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
- fourthTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
- var i = 0
- var j = 0
- while j < customTab.count {
- if(((i == 1 && customTab.count == 3) || i == 2) &&
- (cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)){
- tabs.append(emptyTab)
- }
- else {
- switch(customTab[j]){
- case "1":
- tabs.append(firstTab!)
- case "2":
- tabs.append(secondTab!)
- case "3":
- tabs.append(thirdTab!)
- case "4":
- tabs.append(fourthTab!)
- default:
- break
- }
- j += 1
- }
- i += 1
- }
- if(cpaasMode == PrefsUtil.CPAAS_MODE_BURGER){
- navigationController?.setNavigationBarHidden(false, animated: false)
- print("cpaas mode burger")
- let childrenMenu : [UIAction] = [
- UIAction(title: "Contact Center", handler: {[weak self](_) in
- self?.ccTap()
- }),
- UIAction(title: "Chat", handler: {[weak self](_) in
- self?.chatTap()
- }),
- UIAction(title: "Call", handler: {[weak self](_) in
- self?.callTap()
- }),
- // UIAction(title: "New Post", handler: {[weak self](_) in
- //
- // }),
- UIAction(title: "Live Streaming", handler: {[weak self](_) in
- self?.streamTap()
- }),
- // UIAction(title: "Settings", handler: {[weak self](_) in
- // self?.settingTap()
- // }),
- ]
- let menu = UIMenu(title: "", children: childrenMenu)
- navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
- }
- if((cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)){
- createMidFloatingButton()
- navigationController?.setNavigationBarHidden(true, animated: false)
- }
- if((cpaasMode == PrefsUtil.CPAAS_MODE_FLOATING || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)) {
- let rect = CGRect(x: self.view.bounds.width - 100, y: self.view.bounds.height / 2, width: 50, height: 250)
- floating = FloatingButton()
- floating?.frame = rect
- floating?.isShow = true
-
- view.addSubview(floating!)
- navigationController?.setNavigationBarHidden(true, animated: false)
- }
-
-
-
- self.setViewControllers(tabs, animated: false)
- if(cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX){
- if(customTab.count == 3){
- self.tabBar.items?[1].isEnabled = false
- }
- self.tabBar.items?[2].isEnabled = false
- }
- let numberOfItems = CGFloat(tabBar.items!.count)
- let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height)
- tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.grayColor, size: tabBarItemSize).resizableImage(withCapInsets: .zero)
- UIFont.overrideInitialize()
- }
-
- public static func checkIsChangePerson() -> Bool {
- let isChangeProfile = UserDefaults.standard.bool(forKey: "is_change_profile")
- if !isChangeProfile {
- let alert = UIAlertController(title: "Change Profile".localized(), message: "You must change your name to use this feature".localized().localized(), preferredStyle: .alert)
- alert.addAction(UIAlertAction(title: "Cancel".localized(), style: .destructive, handler: {_ in
- ViewController.def?.thirdTab?.webView?.evaluateJavaScript("if(resumeAll){resumeAll();}")
-
-
- }))
- alert.addAction(UIAlertAction(title: "Ok".localized(), style: UIAlertAction.Style.default, handler: {(_) in
- ViewController.resetTabSelected()
- let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeNS") as! ChangeNamePassswordViewController
- let navigationController = UINavigationController(rootViewController: controller)
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- ViewController.def?.show(b: false)
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.dismiss(animated: true, completion: nil)
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }))
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(alert, animated: true, completion: nil)
- return false
- }
- return true
- }
- public static func resetTabSelected(){
- ViewController.isTab1 = true
- ViewController.isTab2 = false
- ViewController.isTab3 = false
- ViewController.isTab4 = false
- // if ViewController.isTab1 {
- // ViewController.imageTab1.image = UIImage(named: "tab_1_nexilis")!
- // }
- // else {
- // ViewController.imageTab1.image = UIImage(named: "tab_1_nexilis_off")!
- // }
- // if ViewController.isTab2 {
- // ViewController.imageTab2.image = UIImage(named: "tab_2_nexilis")!
- // }
- // else {
- // ViewController.imageTab2.image = UIImage(named: "tab_2_nexilis_off")!
- // }
- // if ViewController.isTab3 {
- // ViewController.imageTab3.image = UIImage(named: "tab_3_nexilis")!
- // }
- // else {
- // ViewController.imageTab3.image = UIImage(named: "tab_3_nexilis_off")!
- // }
- // if ViewController.isTab4 {
- // ViewController.imageTab4.image = UIImage(named: "tab_4_nexilis")!
- // }
- // else {
- // ViewController.imageTab4.image = UIImage(named: "tab_4_nexilis_off")!
- // }
- }
-
- override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
- let cpaasMode = PrefsUtil.getCpaasMode()
- let customTab = PrefsUtil.getCustomTab().split(separator: ",")
- if(cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX){
- if(customTab.count == 2){
- ViewController.isTab1 = item == tabBar.items?[0]
- ViewController.isTab2 = item == tabBar.items?[2]
- }
- else if(customTab.count == 3){
- ViewController.isTab1 = item == tabBar.items?[0]
- ViewController.isTab2 = item == tabBar.items?[2]
- ViewController.isTab3 = item == tabBar.items?[3]
- }
- else if(customTab.count == 4){
- ViewController.isTab1 = item == tabBar.items?[0]
- ViewController.isTab2 = item == tabBar.items?[1]
- ViewController.isTab3 = item == tabBar.items?[3]
- ViewController.isTab4 = item == tabBar.items?[4]
- }
- }
- else{
- ViewController.isTab1 = item == tabBar.items?[0]
- ViewController.isTab2 = item == tabBar.items?[1]
- if(customTab.count > 2){
- ViewController.isTab3 = item == tabBar.items?[2]
- }
- if(customTab.count > 3){
- ViewController.isTab4 = item == tabBar.items?[3]
- }
- }
- }
-
- func createMidFloatingButton(){
- ViewController.chatButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
- ViewController.chatButton.setBackgroundImage(UIImage(named: "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
- ViewController.chatButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.chatButton.layer.shadowOpacity = 0.1
- ViewController.chatButton.layer.shadowOffset = CGSize(width: 4, height: 4)
- ViewController.chatButton.addTarget(self, action: #selector(chatTap), for: .touchUpInside)
- ViewController.callButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
- ViewController.callButton.setBackgroundImage(UIImage(named: "pb_button_call", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
- ViewController.callButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.callButton.layer.shadowOpacity = 0.1
- ViewController.callButton.layer.shadowOffset = CGSize(width: 4, height: 4)
- ViewController.callButton.addTarget(self, action: #selector(callTap), for: .touchUpInside)
- ViewController.ccButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
- ViewController.ccButton.setBackgroundImage(UIImage(named: "pb_button_cc", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
- ViewController.ccButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.ccButton.layer.shadowOpacity = 0.1
- ViewController.ccButton.layer.shadowOffset = CGSize(width: 4, height: 4)
- ViewController.ccButton.addTarget(self, action: #selector(ccTap), for: .touchUpInside)
- ViewController.streamingButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
- ViewController.streamingButton.setBackgroundImage(UIImage(named: "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
- ViewController.streamingButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.streamingButton.layer.shadowOpacity = 0.1
- ViewController.streamingButton.layer.shadowOffset = CGSize(width: 4, height: 4)
- ViewController.streamingButton.addTarget(self, action: #selector(streamTap), for: .touchUpInside)
- ViewController.postButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
- ViewController.postButton.setBackgroundImage(UIImage(named: "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
- ViewController.postButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.postButton.layer.shadowOpacity = 0.1
- ViewController.postButton.layer.shadowOffset = CGSize(width: 4, height: 4)
- ViewController.postButton.addTarget(self, action: #selector(streamTap), for: .touchUpInside)
- let buttonCenterX = self.view.bounds.width / 2
- let buttonCenterY = self.view.bounds.height - self.tabBar.bounds.height
- print("buttonCenterX \(buttonCenterX)")
- print("buttonCenterY \(buttonCenterY)")
- ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
- ViewController.middleButton.setBackgroundImage(UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
- ViewController.middleButton.layer.shadowColor = UIColor.black.cgColor
- ViewController.middleButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
- ViewController.middleButton.layer.shadowOpacity = 1.0
- ViewController.middleButton.layer.shadowRadius = 5.0
- ViewController.middleButton.layer.masksToBounds = false
- ViewController.middleButton.layer.cornerRadius = 4.0
- ViewController.middleButton.addTarget(self, action: #selector(middleBtnTapped), for: .touchUpInside)
- self.view.addSubview(ViewController.chatButton)
- self.view.addSubview(ViewController.callButton)
- self.view.addSubview(ViewController.ccButton)
- self.view.addSubview(ViewController.streamingButton)
- self.view.addSubview(ViewController.postButton)
- self.view.addSubview(ViewController.middleButton)
-
- ViewController.hideDockedButton()
- }
-
- func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
- if(viewController == secondTab){
- if(!ViewController.checkIsChangePerson()){
- return false
- }
- }
- return true
- }
-
- func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
- print("select tabbar")
- let cpaasMode = PrefsUtil.getCpaasMode()
- var childrenMenu = [UIAction]()
- if(cpaasMode == PrefsUtil.CPAAS_MODE_BURGER){
- print("cpaas mode burger")
- childrenMenu.append(contentsOf: [
- UIAction(title: "Contact Center", handler: {[weak self](_) in
- self?.ccTap()
- }),
- UIAction(title: "Chat", handler: {[weak self](_) in
- self?.chatTap()
- }),
- UIAction(title: "Call", handler: {[weak self](_) in
- self?.callTap()
- }),
- UIAction(title: "New Post", handler: {[weak self](_) in
- }),
- UIAction(title: "Live Streaming", handler: {[weak self](_) in
- self?.streamTap()
- }),
- // UIAction(title: "Settings", handler: {[weak self](_) in
- // self?.settingTap()
- // }),
- ])
- if let vc = viewController as? SecondTabViewController {
- childrenMenu.append(contentsOf: vc.childrenMenu)
- }
- let menu = UIMenu(title: "", children: childrenMenu)
- navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
- }
- }
-
- override func viewDidAppear(_ animated: Bool) {
-
- }
-
- @objc func middleBtnTapped() {
- ViewController.expandButton()
- }
- public func show(b: Bool) {
- if(!b){
- if(ViewController.isExpandButton){
- ViewController.expandButton()
- }
- }
- }
-
- @objc func qmeraLongPress() {
- let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
-
- @objc func ccTap() {
- print("ccTap")
- if(ViewController.checkIsChangePerson()){
- var isOfficer = false
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
- let idMe = UserDefaults.standard.string(forKey: "me") as String?
- if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT user_type, image_id FROM BUDDY where f_pin='\(idMe!)'"), cursorData.next() {
- if cursorData.string(forColumnIndex: 0) == "24" {
- isOfficer = true
- }
- cursorData.close()
- return
- }
- })
- show(b: false)
- if isOfficer {
- let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "myHistoryCC") as! HistoryCCViewController
- controller.isOfficer = true
- let navigationController = UINavigationController(rootViewController: controller)
- // navigationController.navigationBar.tintColor = .white
- navigationController.modalPresentationStyle = .fullScreen
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- } else {
- let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
- controller.isContactCenter = true
- let navigationController = UINavigationController(rootViewController: controller)
- navigationController.modalPresentationStyle = .fullScreen
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
- }
-
- }
-
- @objc func streamTap() {
- print("streamTap")
- if(ViewController.checkIsChangePerson()){
- show(b: false)
- let navigationController = UINavigationController(rootViewController: QmeraCreateStreamingViewController())
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
- }
-
- @objc func callTap() {
- print("callTap")
- if(ViewController.checkIsChangePerson()){
- show(b: false)
- let callContact = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactSID")
- let navigationController = UINavigationController(rootViewController: callContact)
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
- }
-
- @objc func chatTap() {
- print("chatTap")
- if(ViewController.checkIsChangePerson()){
- show(b: false)
- let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
- }
-
- @objc func settingTap() {
- let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
- navigationController.modalPresentationStyle = .fullScreen
- // navigationController.navigationBar.tintColor = .white
- navigationController.navigationBar.barTintColor = .mainColor
- navigationController.navigationBar.isTranslucent = false
- // let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
- // navigationController.navigationBar.titleTextAttributes = textAttributes
- navigationController.view.backgroundColor = .mainColor
- UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
- }
-
- public static func showDockedButton() {
- ViewController.chatButton.isHidden = false
- ViewController.callButton.isHidden = false
- ViewController.ccButton.isHidden = false
- ViewController.streamingButton.isHidden = false
- ViewController.postButton.isHidden = false
- }
-
- public static func hideDockedButton() {
- ViewController.chatButton.isHidden = true
- ViewController.callButton.isHidden = true
- ViewController.ccButton.isHidden = true
- ViewController.streamingButton.isHidden = true
- ViewController.postButton.isHidden = true
- }
-
- public static func expandButton() {
- if ViewController.alwaysHideButton && !ViewController.isExpandButton {
- return
- }
- if ViewController.isExpandButton {
- ViewController.isExpandButton = false
- let xChatPosition = ViewController.chatButton.frame.origin.x + 80
- let yChatPosition = ViewController.chatButton.frame.origin.y + 20
- let xCallPosition = ViewController.callButton.frame.origin.x + 50
- let yCallPosition = ViewController.callButton.frame.origin.y + 70
- let xCCPosition = ViewController.ccButton.frame.origin.x
- let yCCPosition = ViewController.ccButton.frame.origin.y + 90
- let xStreamingPosition = ViewController.streamingButton.frame.origin.x - 50
- let yStreamingPosition = ViewController.streamingButton.frame.origin.y + 70
- let xPostPosition = ViewController.postButton.frame.origin.x - 80
- let yPostPosition = ViewController.postButton.frame.origin.y + 20
- UIView.animate(withDuration: 0.5, animations: {
- // if !ViewController.isBlue {
- // ViewController.middleButton.transform = CGAffineTransform(rotationAngle: 0)
- // }
- ViewController.chatButton.frame.origin = CGPoint(x: xChatPosition, y: yChatPosition)
- ViewController.callButton.frame.origin = CGPoint(x: xCallPosition, y: yCallPosition)
- ViewController.ccButton.frame.origin = CGPoint(x: xCCPosition, y: yCCPosition)
- ViewController.streamingButton.frame.origin = CGPoint(x: xStreamingPosition, y: yStreamingPosition)
- ViewController.postButton.frame.origin = CGPoint(x: xPostPosition, y: yPostPosition)
- })
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
- if !ViewController.isExpandButton {
- ViewController.hideDockedButton()
- }
- })
- } else {
- ViewController.isExpandButton = true
- ViewController.showDockedButton()
- let xChatPosition = ViewController.chatButton.frame.origin.x - 80
- let yChatPosition = ViewController.chatButton.frame.origin.y - 20
- let xCallPosition = ViewController.callButton.frame.origin.x - 50
- let yCallPosition = ViewController.callButton.frame.origin.y - 70
- let xCCPosition = ViewController.ccButton.frame.origin.x
- let yCCPosition = ViewController.ccButton.frame.origin.y - 90
- let xStreamingPosition = ViewController.streamingButton.frame.origin.x + 50
- let yStreamingPosition = ViewController.streamingButton.frame.origin.y - 70
- let xPostPosition = ViewController.postButton.frame.origin.x + 80
- let yPostPosition = ViewController.postButton.frame.origin.y - 20
- UIView.animate(withDuration: 0.5, animations: {
- // if !ViewController.isBlue{
- // ViewController.middleButton.transform = CGAffineTransform(rotationAngle: .pi / 2)
- // }
- ViewController.chatButton.frame.origin = CGPoint(x: xChatPosition, y: yChatPosition)
- ViewController.callButton.frame.origin = CGPoint(x: xCallPosition, y: yCallPosition)
- ViewController.ccButton.frame.origin = CGPoint(x: xCCPosition, y: yCCPosition)
- ViewController.streamingButton.frame.origin = CGPoint(x: xStreamingPosition, y: yStreamingPosition)
- ViewController.postButton.frame.origin = CGPoint(x: xPostPosition, y: yPostPosition)
- })
- }
- }
-
- public static func removeMiddleButton() {
- ViewController.chatButton.removeFromSuperview()
- ViewController.callButton.removeFromSuperview()
- ViewController.ccButton.removeFromSuperview()
- ViewController.streamingButton.removeFromSuperview()
- ViewController.postButton.removeFromSuperview()
- ViewController.middleButton.removeFromSuperview()
- }
- }
- class EmptyTabViewController: UIViewController {
- override func viewDidLoad() {
-
- }
- }
-
- extension Bundle {
- // Name of the app - title under the icon.
- var displayName: String? {
- return object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ??
- object(forInfoDictionaryKey: "CFBundleName") as? String
- }
- }
- extension BinaryInteger {
- var degreesToRadians: CGFloat { CGFloat(self) * .pi / 180 }
- }
- extension FloatingPoint {
- var degreesToRadians: Self { self * .pi / 180 }
- var radiansToDegrees: Self { self * 180 / .pi }
- }
- extension UIImage {
- class func imageWithColor(color: UIColor, size: CGSize) -> UIImage {
- let rect: CGRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
- UIGraphicsBeginImageContextWithOptions(size, false, 0)
- color.setFill()
- UIRectFill(rect)
- let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
- UIGraphicsEndImageContext()
- return image
- }
- }
|