alqindiirsyam 2 лет назад
Родитель
Сommit
d28de10511

+ 4 - 71
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -93,68 +93,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     }
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-        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()
-        } else {
-            var showButton = false
-            if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_FLOATING || PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_MIX {
-                showButton = true
-            }
-            Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: showButton, fromMAB: true) //AA6164AA13F0A6262677AC7443C37E3F6F0A342E8BEE84B700CB59C876166FE0(AWS) //1C4FA430BC9F44484AFBE99C8974D70B68CE7891DBE83505CBF01205DE51FC18(CBN)
-            if let response = Nexilis.writeSync(message: getPrefs(key: ""), timeout: 5000) {
-                if response.mBodies[CoreMessage_TMessageKey.ERRCOD] == "00" {
-                    let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
-                    if let json = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: []) as? [[String: Any?]] {
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_first_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_third_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_custom_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_base")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_qms")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_dock")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_ss")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_background")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_compressor")
-                        for j in json {
-                            if let firstTab = j["app_builder_url_first_tab"] as? String {
-                                PrefsUtil.setURLFirstTab(value: firstTab)
-                                ViewController.sURL = firstTab
-                            }
-                            if let thirdTab = j["app_builder_url_third_tab"] as? String {
-                                PrefsUtil.setURLThirdTab(value: thirdTab)
-                                ViewController.tab3 = thirdTab
-                            }
-                            if let customTab = j["app_builder_custom_tab"] as? String {
-                                PrefsUtil.setCustomTab(cust: customTab)
-                            }
-                            if let urlBase = j["app_builder_url_base"] as? String {
-                                PrefsUtil.setURLBase(value: urlBase)
-                            }
-                            if let urlQMS = j["app_builder_url_qms"] as? String {
-                                PrefsUtil.setURLQMS(value: urlQMS)
-                            }
-                            if let iconDock = j["app_builder_icon_dock"] as? String {
-                                PrefsUtil.setIconDock(value: iconDock)
-                            }
-                            if let iconSS = j["app_builder_icon_ss"] as? String {
-                                PrefsUtil.setIconSS(value: iconSS)
-                            }
-                            if let background = j["app_builder_background"] as? String {
-                                PrefsUtil.setBackground(value: background)
-                            }
-                            if let url_privacy_policy = j["app_builder_url_privacy_policy"] as? String {
-                                PrefsUtil.setURLPrivacyPolicy(value: url_privacy_policy)
-                            }
-                            if let enable_privacy_policy = j["app_builder_enable_privacy_policy"] as? String {
-                                PrefsUtil.setEnablePrivacyPolicy(value: enable_privacy_policy == "1" ? true : false)
-                            }
-                        }
-                    }
-                }
-            }
+        var showButton = false
+        if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_FLOATING || PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_MIX {
+            showButton = true
         }
+        Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: showButton, fromMAB: true) //AA6164AA13F0A6262677AC7443C37E3F6F0A342E8BEE84B700CB59C876166FE0(AWS) //1C4FA430BC9F44484AFBE99C8974D70B68CE7891DBE83505CBF01205DE51FC18(CBN)
         let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
         tabBarAppearance.configureWithTransparentBackground()
         if Bundle.main.displayName == "DigiNetS" {
@@ -190,16 +133,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
     }
     
-    func getPrefs(key: String) -> TMessage {
-        let tMessage = NexilisLite.TMessage()
-        let me = UserDefaults.standard.string(forKey: "me")
-        tMessage.mCode = "PPR"
-        tMessage.mStatus = CoreMessage_TMessageUtil.getTID()
-        tMessage.mBodies[CoreMessage_TMessageKey.F_PIN] = me
-        tMessage.mBodies[CoreMessage_TMessageKey.KEY] = key
-        return tMessage
-    }
-    
     private func registerForPushNotifications() {
         if #available(iOS 10.0, *) {
             let center  = UNUserNotificationCenter.current()

+ 10 - 5
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -457,10 +457,15 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
                             tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
                             tableView.endUpdates()
                         } else {
-                            chats.insert(newChat[0], at: 0)
-                            tableView.beginUpdates()
-                            tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
-                            tableView.endUpdates()
+                            if noData {
+                                chats.insert(newChat[0], at: 0)
+                                tableView.reloadData()
+                            } else {
+                                chats.insert(newChat[0], at: 0)
+                                tableView.beginUpdates()
+                                tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
+                                tableView.endUpdates()
+                            }
                         }
                     }
                 }
@@ -473,7 +478,7 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
             let data:[AnyHashable : Any] = notification.userInfo!
             if let dataMessage = data["message"] as? TMessage {
                 let chatData = dataMessage.mBodies
-                let indexChat = chats.firstIndex(where: { $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
+                let indexChat = chats.firstIndex(where: { (chatData[CoreMessage_TMessageKey.MESSAGE_ID] ?? "").contains(",") ? $0.messageId == (chatData[CoreMessage_TMessageKey.MESSAGE_ID]!).components(separatedBy: ",")[1]  : $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
                 if indexChat != nil {
                     tableView.beginUpdates()
                     tableView.reloadRows(at: [IndexPath(row: indexChat!, section: 0)], with: .none)

+ 60 - 0
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -58,6 +58,56 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
 
     override func viewDidLoad() {
         super.viewDidLoad()
+        if let response = Nexilis.writeSync(message: getPrefs(key: ""), timeout: 5000) {
+            if response.mBodies[CoreMessage_TMessageKey.ERRCOD] == "00" {
+                let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
+                if let json = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: []) as? [[String: Any?]] {
+                    UserDefaults.standard.removeObject(forKey: "app_builder_url_first_tab")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_url_third_tab")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_custom_tab")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_url_base")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_url_qms")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_icon_dock")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_icon_ss")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_background")
+                    UserDefaults.standard.removeObject(forKey: "app_builder_compressor")
+                    for j in json {
+                        if let firstTab = j["app_builder_url_first_tab"] as? String {
+                            PrefsUtil.setURLFirstTab(value: firstTab)
+                            ViewController.sURL = firstTab
+                        }
+                        if let thirdTab = j["app_builder_url_third_tab"] as? String {
+                            PrefsUtil.setURLThirdTab(value: thirdTab)
+                            ViewController.tab3 = thirdTab
+                        }
+                        if let customTab = j["app_builder_custom_tab"] as? String {
+                            PrefsUtil.setCustomTab(cust: customTab)
+                        }
+                        if let urlBase = j["app_builder_url_base"] as? String {
+                            PrefsUtil.setURLBase(value: urlBase)
+                        }
+                        if let urlQMS = j["app_builder_url_qms"] as? String {
+                            PrefsUtil.setURLQMS(value: urlQMS)
+                        }
+                        if let iconDock = j["app_builder_icon_dock"] as? String {
+                            PrefsUtil.setIconDock(value: iconDock)
+                        }
+                        if let iconSS = j["app_builder_icon_ss"] as? String {
+                            PrefsUtil.setIconSS(value: iconSS)
+                        }
+                        if let background = j["app_builder_background"] as? String {
+                            PrefsUtil.setBackground(value: background)
+                        }
+                        if let url_privacy_policy = j["app_builder_url_privacy_policy"] as? String {
+                            PrefsUtil.setURLPrivacyPolicy(value: url_privacy_policy)
+                        }
+                        if let enable_privacy_policy = j["app_builder_enable_privacy_policy"] as? String {
+                            PrefsUtil.setEnablePrivacyPolicy(value: enable_privacy_policy == "1" ? true : false)
+                        }
+                    }
+                }
+            }
+        }
         ViewController.def = self
         title = Bundle.main.displayName
         let customTab = PrefsUtil.getCustomTab().split(separator: ",")
@@ -175,6 +225,16 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         checkCounter()
     }
     
+    func getPrefs(key: String) -> TMessage {
+        let tMessage = NexilisLite.TMessage()
+        let me = UserDefaults.standard.string(forKey: "me")
+        tMessage.mCode = "PPR"
+        tMessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tMessage.mBodies[CoreMessage_TMessageKey.F_PIN] = me
+        tMessage.mBodies[CoreMessage_TMessageKey.KEY] = key
+        return tMessage
+    }
+    
     @objc func checkCounter() {
         DispatchQueue.main.async { [self] in
             if self.viewControllers?.firstIndex(of: secondTab!) != nil {

+ 43 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -89,6 +89,7 @@ public class EditorGroup: UIViewController {
     var lastTouchPoint: CGPoint = .zero
     var isLinkCopied = false
     var touchedSubview = UIView()
+    var listViewOnSection: [UIView] = []
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -112,6 +113,15 @@ public class EditorGroup: UIViewController {
             self.navigationController?.setNavigationBarHidden(false, animated: false)
         }
         updateProfile()
+        let indexPath = tableChatView.indexPathsForVisibleRows?.first
+        if indexPath != nil {
+            let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+            let isPinned = headerRect.origin.y <= tableChatView.contentOffset.y
+            if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && isPinned {
+                let headerView = listViewOnSection[currentIndexpath!.section]
+                headerView.isHidden = true
+            }
+        }
     }
     
     public override func viewDidLoad() {
@@ -1532,6 +1542,13 @@ public class EditorGroup: UIViewController {
                     }
                 }
             }
+            let indexPathFirst = tableChatView.indexPathsForVisibleRows?.first
+            if indexPathFirst != nil && listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPathFirst!.section{
+                let headerView = listViewOnSection[indexPathFirst!.section]
+                if headerView.isHidden {
+                    headerView.isHidden = false
+                }
+            }
             if dataMessages.count - 1 < currentIndexpath!.row {
                 return
             }
@@ -4490,6 +4507,32 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
             }
         }
     }
+    
+    public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
+        let indexPath = tableChatView.indexPathsForVisibleRows?.first
+        if indexPath != nil {
+            let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+            let isPinned = headerRect.origin.y <= scrollView.contentOffset.y
+            if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && indexPath!.row > 0 {
+                let headerView = listViewOnSection[currentIndexpath!.section]
+                headerView.isHidden = true
+            }
+        }
+    }
+    
+    public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
+        if !decelerate {
+            let indexPath = tableChatView.indexPathsForVisibleRows?.first
+            if indexPath != nil {
+                let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+                let isPinned = headerRect.origin.y <= scrollView.contentOffset.y
+                if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && isPinned {
+                    let headerView = listViewOnSection[currentIndexpath!.section]
+                    headerView.isHidden = true
+                }
+            }
+        }
+    }
 }
 
 extension EditorGroup: UISearchBarDelegate {

+ 49 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -99,6 +99,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     var lastTouchPoint: CGPoint = .zero
     var isLinkCopied = false
     var touchedSubview = UIView()
+    var listViewOnSection: [UIView] = []
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -127,6 +128,15 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
         }
         updateProfile()
         gettingDataMessage = false
+        let indexPath = tableChatView.indexPathsForVisibleRows?.first
+        if indexPath != nil {
+            let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+            let isPinned = headerRect.origin.y <= tableChatView.contentOffset.y
+            if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && isPinned {
+                let headerView = listViewOnSection[currentIndexpath!.section]
+                headerView.isHidden = true
+            }
+        }
     }
     
     public override func viewDidLoad() {
@@ -2746,6 +2756,13 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     }
                 }
             }
+            let indexPathFirst = tableChatView.indexPathsForVisibleRows?.first
+            if indexPathFirst != nil && listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPathFirst!.section{
+                let headerView = listViewOnSection[indexPathFirst!.section]
+                if headerView.isHidden {
+                    headerView.isHidden = false
+                }
+            }
             var listData = dataMessages[0...currentIndexpath!.row]
             listData = listData.filter({$0["status"] as? String != "4" && $0["status"] as? String != "8"})
             if listData.count != 0 && !isContactCenter {
@@ -3955,6 +3972,12 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
         labelDate.textColor = .secondaryColor
         labelDate.font = UIFont.systemFont(ofSize: 12, weight: .medium)
         labelDate.text = dataDates[section]
+        if listViewOnSection.count == 0 || listViewOnSection.count - 1 < section {
+            listViewOnSection.append(containerView)
+        } else {
+            listViewOnSection.remove(at: section)
+            listViewOnSection.insert(containerView, at: section)
+        }
         return containerView
     }
     
@@ -5788,6 +5811,32 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
             }
         }
     }
+    
+    public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
+        let indexPath = tableChatView.indexPathsForVisibleRows?.first
+        if indexPath != nil {
+            let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+            let isPinned = headerRect.origin.y <= scrollView.contentOffset.y
+            if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && indexPath!.row > 0 {
+                let headerView = listViewOnSection[currentIndexpath!.section]
+                headerView.isHidden = true
+            }
+        }
+    }
+    
+    public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
+        if !decelerate {
+            let indexPath = tableChatView.indexPathsForVisibleRows?.first
+            if indexPath != nil {
+                let headerRect = tableChatView.rectForHeader(inSection: indexPath!.section)
+                let isPinned = headerRect.origin.y <= scrollView.contentOffset.y
+                if listViewOnSection.count != 0 && listViewOnSection.count - 1 <= indexPath!.section && isPinned {
+                    let headerView = listViewOnSection[currentIndexpath!.section]
+                    headerView.isHidden = true
+                }
+            }
+        }
+    }
 }
 
 extension UITableView {

+ 10 - 5
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -263,10 +263,15 @@ class ContactChatViewController: UITableViewController {
                             tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
                             tableView.endUpdates()
                         } else {
-                            chats.insert(newChat[0], at: 0)
-                            tableView.beginUpdates()
-                            tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
-                            tableView.endUpdates()
+                            if noData {
+                                chats.insert(newChat[0], at: 0)
+                                tableView.reloadData()
+                            } else {
+                                chats.insert(newChat[0], at: 0)
+                                tableView.beginUpdates()
+                                tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
+                                tableView.endUpdates()
+                            }
                         }
                     }
                 }
@@ -279,7 +284,7 @@ class ContactChatViewController: UITableViewController {
             let data:[AnyHashable : Any] = notification.userInfo!
             if let dataMessage = data["message"] as? TMessage {
                 let chatData = dataMessage.mBodies
-                let indexChat = chats.firstIndex(where: { $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
+                let indexChat = chats.firstIndex(where: { (chatData[CoreMessage_TMessageKey.MESSAGE_ID] ?? "").contains(",") ? $0.messageId == (chatData[CoreMessage_TMessageKey.MESSAGE_ID]!).components(separatedBy: ",")[1]  : $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
                 if indexChat != nil {
                     tableView.beginUpdates()
                     tableView.reloadRows(at: [IndexPath(row: indexChat!, section: 0)], with: .none)