浏览代码

Merge branch 'master' of http://192.168.0.7:3000/easySoft/AppBuilder

alqindiirsyam 3 年之前
父节点
当前提交
6577acacf7

+ 2 - 1
.gitignore

@@ -6,4 +6,5 @@ Pods/
 src/venv/
 .idea/
 .DS_Store
-Podfile.lock
+Podfile.lock
+src/__pycache__/

+ 3 - 3
appbuilder-ios/AppBuilder/AppBuilder/Base.lproj/Main.storyboard

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nD6-T3-59p">
-    <device id="retina6_7" orientation="portrait" appearance="light"/>
+    <device id="retina6_7" orientation="portrait" appearance="dark"/>
     <dependencies>
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
@@ -35,7 +35,7 @@
                         <subviews>
                             <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zT9-mO-2xu">
                                 <rect key="frame" x="0.0" y="44" width="428" height="882"/>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <color key="backgroundColor" red="0.36078431372549019" green="0.38823529411764707" blue="0.40392156862745099" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <wkWebViewConfiguration key="configuration">
                                     <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
                                     <wkPreferences key="preferences"/>
@@ -255,7 +255,7 @@
                         <subviews>
                             <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bvD-XN-Tvh">
                                 <rect key="frame" x="0.0" y="44" width="428" height="882"/>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <color key="backgroundColor" red="0.36078431372549019" green="0.38823529411764707" blue="0.40392156862745099" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <wkWebViewConfiguration key="configuration">
                                     <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
                                     <wkPreferences key="preferences"/>

+ 1 - 1
appbuilder-ios/AppBuilder/AppBuilder/FirstTabViewController.swift

@@ -18,7 +18,7 @@ class FirstTabViewController: UIViewController, WKUIDelegate, UIScrollViewDelega
         super.viewDidLoad()
         let cpaasMode = PrefsUtil.getCpaasMode()
         let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
-        navigationController?.navigationBar.backgroundColor = .white
+//        navigationController?.navigationBar.backgroundColor = .white
         navigationController?.setNavigationBarHidden(!isBurger, animated: false)
         let tapGesture = UITapGestureRecognizer(target: self, action: #selector(collapseDocked))
         tapGesture.cancelsTouchesInView = false

+ 0 - 1
appbuilder-ios/AppBuilder/AppBuilder/FourthTabViewController.swift

@@ -29,7 +29,6 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         tableView.dataSource = self
         
         self.navigationController?.navigationBar.topItem?.title = "Settings".localized();
-        view.backgroundColor = .white
         
         makeMenu()
         

+ 3 - 3
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -195,11 +195,11 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate {
     @objc func startConversation(){
         let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
         navigationController.modalPresentationStyle = .fullScreen
-        navigationController.navigationBar.tintColor = .white
+//        navigationController.navigationBar.tintColor = .white
         navigationController.navigationBar.barTintColor = .mainColor
         navigationController.navigationBar.isTranslucent = false
-        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-        navigationController.navigationBar.titleTextAttributes = textAttributes
+//        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+//        navigationController.navigationBar.titleTextAttributes = textAttributes
         navigationController.view.backgroundColor = .mainColor
         self.navigationController?.present(navigationController, animated: true, completion: nil)
     }

+ 1 - 1
appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift

@@ -64,7 +64,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         self.navigationController?.navigationBar.topItem?.title = Bundle.main.displayName
         let cpaasMode = PrefsUtil.getCpaasMode()
         let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
-        navigationController?.navigationBar.backgroundColor = .white
+//        navigationController?.navigationBar.backgroundColor = .white
         navigationController?.setNavigationBarHidden(!isBurger, animated: false)
     }
     

+ 25 - 25
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -114,7 +114,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
 //                }),
             ]
             let menu = UIMenu(title: "", children: childrenMenu)
-            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
+            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()
@@ -141,7 +141,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
         }
         let numberOfItems = CGFloat(tabBar.items!.count)
         let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height)
-        tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.white, size: tabBarItemSize).resizableImage(withCapInsets: .zero)
+        tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.grayColor, size: tabBarItemSize).resizableImage(withCapInsets: .zero)
         UIFont.overrideInitialize()
     }
     
@@ -159,11 +159,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeNS") as! ChangeNamePassswordViewController
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.modalPresentationStyle = .fullScreen
-                navigationController.navigationBar.tintColor = .white
+//                navigationController.navigationBar.tintColor = .white
                 navigationController.navigationBar.barTintColor = .mainColor
                 navigationController.navigationBar.isTranslucent = false
-                let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-                navigationController.navigationBar.titleTextAttributes = textAttributes
+//                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)
@@ -277,7 +277,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
         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_icon")!.withRenderingMode(.alwaysOriginal), for: .normal)
+        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
@@ -334,7 +334,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 childrenMenu.append(contentsOf: vc.childrenMenu)
             }
             let menu = UIMenu(title: "", children: childrenMenu)
-            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
+            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)
         }
     }
     
@@ -359,11 +359,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
     @objc func qmeraLongPress() {
         let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
         navigationController.modalPresentationStyle = .fullScreen
-        navigationController.navigationBar.tintColor = .white
+//        navigationController.navigationBar.tintColor = .white
         navigationController.navigationBar.barTintColor = .mainColor
         navigationController.navigationBar.isTranslucent = false
-        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-        navigationController.navigationBar.titleTextAttributes = textAttributes
+//        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)
     }
@@ -387,12 +387,12 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "myHistoryCC") as! HistoryCCViewController
                 controller.isOfficer = true
                 let navigationController = UINavigationController(rootViewController: controller)
-                navigationController.navigationBar.tintColor = .white
+//                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
+//                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 {
@@ -412,11 +412,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             show(b: false)
             let navigationController = UINavigationController(rootViewController: QmeraCreateStreamingViewController())
             navigationController.modalPresentationStyle = .fullScreen
-            navigationController.navigationBar.tintColor = .white
+//            navigationController.navigationBar.tintColor = .white
             navigationController.navigationBar.barTintColor = .mainColor
             navigationController.navigationBar.isTranslucent = false
-            let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-            navigationController.navigationBar.titleTextAttributes = textAttributes
+//            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)
         }
@@ -429,11 +429,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             let callContact = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactSID")
             let navigationController = UINavigationController(rootViewController: callContact)
             navigationController.modalPresentationStyle = .fullScreen
-            navigationController.navigationBar.tintColor = .white
+//            navigationController.navigationBar.tintColor = .white
             navigationController.navigationBar.barTintColor = .mainColor
             navigationController.navigationBar.isTranslucent = false
-            let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-            navigationController.navigationBar.titleTextAttributes = textAttributes
+//            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)
         }
@@ -445,11 +445,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             show(b: false)
             let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
             navigationController.modalPresentationStyle = .fullScreen
-            navigationController.navigationBar.tintColor = .white
+//            navigationController.navigationBar.tintColor = .white
             navigationController.navigationBar.barTintColor = .mainColor
             navigationController.navigationBar.isTranslucent = false
-            let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-            navigationController.navigationBar.titleTextAttributes = textAttributes
+//            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)
         }
@@ -458,11 +458,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
     @objc func settingTap() {
         let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
         navigationController.modalPresentationStyle = .fullScreen
-        navigationController.navigationBar.tintColor = .white
+//        navigationController.navigationBar.tintColor = .white
         navigationController.navigationBar.barTintColor = .mainColor
         navigationController.navigationBar.isTranslucent = false
-        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-        navigationController.navigationBar.titleTextAttributes = textAttributes
+//        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)
     }

+ 14 - 14
appbuilder-ios/NexilisLite/NexilisLite/Source/Model/User.swift

@@ -9,20 +9,20 @@ import Foundation
 
 public class User: Model {
     
-    let pin: String
-    let firstName: String
-    let lastName: String
-    var thumb: String
-    var official: String?
-    var userType: String?
-    var privacy_flag: String?
-    var offline_mode: String?
-    var ex_block: String?
-    var ex_offmp: String?
+    public let pin: String
+    public let firstName: String
+    public let lastName: String
+    public var thumb: String
+    public var official: String?
+    public var userType: String?
+    public var privacy_flag: String?
+    public var offline_mode: String?
+    public var ex_block: String?
+    public var ex_offmp: String?
     
-    var isSelected: Bool = false
+    public var isSelected: Bool = false
     
-    init(pin: String) {
+    public init(pin: String) {
         self.pin = pin
         self.firstName = ""
         self.lastName = ""
@@ -34,7 +34,7 @@ public class User: Model {
         self.ex_offmp = ""
     }
     
-    init(pin: String, firstName: String, lastName: String, thumb: String, userType: String = "0", privacy_flag: String = "", offline_mode: String = "", ex_block: String = "", official: String = "", ex_offmp: String = "") {
+    public init(pin: String, firstName: String, lastName: String, thumb: String, userType: String = "0", privacy_flag: String = "", offline_mode: String = "", ex_block: String = "", official: String = "", ex_offmp: String = "") {
         self.pin = pin
         self.firstName = firstName
         self.lastName = lastName
@@ -55,7 +55,7 @@ public class User: Model {
         return "\(pin) \(firstName) \(lastName) \(thumb)"
     }
     
-    var fullName: String {
+    public var fullName: String {
         return "\(firstName) \(lastName)".trimmingCharacters(in: .whitespaces)
     }
     

+ 29 - 32
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -14,9 +14,6 @@ import UIKit
 import FMDB
 import QuickLook
 import NotificationBannerSwift
-import MLKitFaceDetection
-import MLKitVision
-import MLImage
 
 public class Nexilis: NSObject {
     public static var sAPIKey = ""
@@ -2634,35 +2631,35 @@ extension Nexilis: MessageDelegate {
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "onTypingChat"), object: nil, userInfo: dataMessage)
     }
     
-    public static func faceDetect(fd: FaceDetector?,image: UIImage, completion: ((Bool) -> ())?){
-        print("enter vision")
-        let visionImage = VisionImage(image: image)
-        print("exit vision")
-        var retval = false
-        visionImage.orientation = image.imageOrientation
-        var fd1 : FaceDetector?
-        if(fd == nil){
-            fd1 = FaceDetector.faceDetector()
-        }
-        else {
-            fd1 = fd
-        }
-
-        // [START detect_faces]
-        fd1?.process(visionImage) {faces, error in
-            guard error == nil, let faces = faces, !faces.isEmpty else {
-              print("faces empty")
-                completion?(false)
-                return
-            }
-            if(faces.count > 0){
-                print("face count: \(faces.count)")
-                retval = true
-            }
-            completion?(retval)
-        }
-
-    }
+//    public static func faceDetect(fd: FaceDetector?,image: UIImage, completion: ((Bool) -> ())?){
+//        print("enter vision")
+//        let visionImage = VisionImage(image: image)
+//        print("exit vision")
+//        var retval = false
+//        visionImage.orientation = image.imageOrientation
+//        var fd1 : FaceDetector?
+//        if(fd == nil){
+//            fd1 = FaceDetector.faceDetector()
+//        }
+//        else {
+//            fd1 = fd
+//        }
+//
+//        // [START detect_faces]
+//        fd1?.process(visionImage) {faces, error in
+//            guard error == nil, let faces = faces, !faces.isEmpty else {
+//              print("faces empty")
+//                completion?(false)
+//                return
+//            }
+//            if(faces.count > 0){
+//                print("face count: \(faces.count)")
+//                retval = true
+//            }
+//            completion?(retval)
+//        }
+//
+//    }
 }
 
 extension Nexilis: GroupDelegate {

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/TMessage.swift

@@ -33,7 +33,7 @@ public class TMessage {
     public static let TYPE_ALL         =  "2"
     public static let TYPE_NEED_ACK    =  "3"
     
-    init() {
+    public init() {
         mBodies[CoreMessage_TMessageKey.IMEI] = Nexilis.getCLMUserId()
 //        mBodies[CoreMessage_TMessageKey.VERCOD] = UIApplication.appVersion
         mBodies[CoreMessage_TMessageKey.VERCOD] = "1.8.5.10"

+ 0 - 870
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController-backup.swift

@@ -1,870 +0,0 @@
-//
-//  ContactChatViewController.swift
-//  Qmera
-//
-//  Created by Yayan Dwi on 22/09/21.
-//
-
-import UIKit
-import FMDB
-import NotificationBannerSwift
-
-class ContactChatViewController: UITableViewController {
-    
-    deinit {
-        print(#function, ">>>> TADAA")
-        NotificationCenter.default.removeObserver(self)
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshView"), object: nil, userInfo: nil)
-    }
-    
-    var isChooser: ((String, String) -> ())?
-    
-    var isAdmin: Bool = false
-    
-    var chats: [Chat] = []
-    
-    var contacts: [User] = []
-    
-    var groups: [Group] = []
-    
-    var groupMap: [String:Int] = [:]
-    
-    var searchController: UISearchController!
-    
-    var segment: UISegmentedControl!
-    
-    var fillteredData: [Any] = []
-    
-    var isSearchBarEmpty: Bool {
-        return searchController.searchBar.text?.isEmpty ?? true
-    }
-    
-    var isFilltering: Bool {
-        return searchController.isActive && !isSearchBarEmpty
-    }
-    
-    func filterContentForSearchText(_ searchText: String) {
-        switch segment.selectedSegmentIndex {
-        case 1:
-            fillteredData = self.contacts.filter { $0.fullName.lowercased().contains(searchText.lowercased()) }
-        case 2:
-            fillteredData = self.groups.filter { $0.name.lowercased().contains(searchText.lowercased()) }
-        default:
-            fillteredData = self.chats.filter { $0.name.lowercased().contains(searchText.lowercased()) || $0.messageText.lowercased().contains(searchText.lowercased()) }
-        }
-        tableView.reloadData()
-    }
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        let me = UserDefaults.standard.string(forKey: "me")!
-        Database.shared.database?.inTransaction({ fmdb, rollback in
-            if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select FIRST_NAME, LAST_NAME, IMAGE_ID, USER_TYPE from BUDDY where F_PIN = '\(me)'"), cursor.next() {
-                isAdmin = cursor.string(forColumnIndex: 3) == "23" || cursor.string(forColumnIndex: 3) == "24"
-                cursor.close()
-            }
-        })
-        
-        title = "Start Conversation"
-        
-        //        navigationController?.navigationBar.prefersLargeTitles = true
-        
-        navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel(sender:)))
-        
-        var childrenMenu : [UIAction] = [
-            UIAction(title: "Create Group", image: UIImage(systemName: "person.and.person"), handler: {[weak self](_) in
-                let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "createGroupNav") as! UINavigationController
-                let vc = controller.topViewController as! GroupCreateViewController
-                vc.isDismiss = { id in
-                    let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "groupDetailView") as! GroupDetailViewController
-                    controller.data = id
-                    self?.navigationController?.show(controller, sender: nil)
-                }
-                self?.navigationController?.present(controller, animated: true, completion: nil)
-            }),
-            UIAction(title: "Add Friends", image: UIImage(systemName: "person.badge.plus"), handler: {[weak self](_) in
-                let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "addFriendNav") as! UINavigationController
-                if let vc = controller.viewControllers.first as? AddFriendTableViewController {
-                    vc.isDismiss = {
-                        self?.getContacts {
-                            DispatchQueue.main.async {
-                                self?.tableView.reloadData()
-                            }
-                        }
-                    }
-                }
-                self?.navigationController?.present(controller, animated: true, completion: nil)
-            }),
-//            UIAction(title: "Configure Email", image: UIImage(systemName: "mail"), handler: {[weak self](_) in
-//
-//            }),
-            UIAction(title: "Favorite Messages", image: UIImage(systemName: "star"), handler: {[weak self](_) in
-                let editorStaredVC = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "staredVC") as! EditorStarMessages
-                self?.navigationController?.show(editorStaredVC, sender: nil)
-            }),
-        ]
-        //debug only
-//        isAdmin = true
-        if(isAdmin){
-            childrenMenu.append(UIAction(title: "Broadcast Message", image: UIImage(systemName: "envelope.open"), handler: {[weak self](_) in
-                let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "broadcastNav")
-                self?.navigationController?.present(controller, animated: true, completion: nil)
-            }))
-        }
-        
-        let menu = UIMenu(title: "", children: childrenMenu)
-        navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .add, primaryAction: .none, menu: menu)
-        
-        searchController = UISearchController(searchResultsController: nil)
-        searchController.delegate = self
-        searchController.searchResultsUpdater = self
-        searchController.searchBar.autocapitalizationType = .none
-        searchController.searchBar.delegate = self
-        searchController.searchBar.barTintColor = .secondaryColor
-        searchController.searchBar.searchTextField.backgroundColor = .secondaryColor
-        searchController.obscuresBackgroundDuringPresentation = false
-        
-        navigationItem.searchController = searchController
-        navigationItem.hidesSearchBarWhenScrolling = true
-        
-        definesPresentationContext = true
-        
-        segment = UISegmentedControl(items: ["Chat", "Contact", "Group"])
-        segment.sizeToFit()
-        segment.selectedSegmentIndex = 0
-        segment.addTarget(self, action: #selector(segmentChanged(sender:)), for: .valueChanged)
-        
-        NotificationCenter.default.addObserver(self, selector: #selector(onReceiveMessage(notification:)), name: NSNotification.Name(rawValue: "onReceiveChat"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(onReload(notification:)), name: NSNotification.Name(rawValue: "onMember"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(onReload(notification:)), name: NSNotification.Name(rawValue: "onUpdatePersonInfo"), object: nil)
-        
-        tableView.tableHeaderView = segment
-        tableView.tableFooterView = UIView()
-        
-        pullBuddy()
-        
-    }
-    
-    override func viewWillAppear(_ animated: Bool) {
-        getData()
-    }
-    
-    @objc func onReload(notification: NSNotification) {
-        let data:[AnyHashable : Any] = notification.userInfo!
-        if data["member"] as? String == UserDefaults.standard.string(forKey: "me") {
-            DispatchQueue.main.async {
-                self.getData()
-            }
-        } else if data["state"] as? Int == 99 {
-            DispatchQueue.main.async {
-                self.getData()
-            }
-        }
-    }
-    
-    @objc func onReceiveMessage(notification: NSNotification) {
-        let data:[AnyHashable : Any] = notification.userInfo!
-        guard let dataMessage = data["message"] as? TMessage else {
-            return
-        }
-        let isUser = User.getData(pin: dataMessage.getBody(key: CoreMessage_TMessageKey.L_PIN)) != nil
-        let chatId = dataMessage.getBody(key: CoreMessage_TMessageKey.CHAT_ID, default_value: "").isEmpty ? dataMessage.getBody(key: CoreMessage_TMessageKey.L_PIN) : dataMessage.getBody(key: CoreMessage_TMessageKey.CHAT_ID, default_value: "")
-        let pin = isUser ? dataMessage.getBody(key: CoreMessage_TMessageKey.F_PIN) : chatId
-        let messageId = dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)
-        if let index = chats.firstIndex(of: Chat(pin: pin)) {
-            guard let chat = Chat.getData(messageId: messageId).first else {
-                return
-            }
-            DispatchQueue.main.async {
-                if self.segment.selectedSegmentIndex == 0 {
-                    self.tableView.beginUpdates()
-                    self.chats.remove(at: index)
-                    self.tableView.deleteRows(at: [IndexPath(row: index, section: 0)], with: .none)
-                }
-                self.chats.insert(chat, at: 0)
-                if self.segment.selectedSegmentIndex == 0 {
-                    self.tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
-                    self.tableView.endUpdates()
-                }
-            }
-        } else {
-            guard let chat = Chat.getData(messageId: messageId).first else {
-                return
-            }
-            DispatchQueue.main.async {
-                if self.segment.selectedSegmentIndex == 0 {
-                    self.tableView.beginUpdates()
-                }
-                self.chats.insert(chat, at: 0)
-                if self.segment.selectedSegmentIndex == 0 {
-                    self.tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
-                    self.tableView.endUpdates()
-                }
-            }
-        }
-    }
-    
-    @objc func add(sender: Any) {
-        
-    }
-    
-    @objc func cancel(sender: Any) {
-        navigationController?.dismiss(animated: true, completion: nil)
-    }
-    
-    @objc func segmentChanged(sender: Any) {
-        filterContentForSearchText(searchController.searchBar.text!)
-        if segment.selectedSegmentIndex == 2 {
-            self.getGroups { g1 in
-                self.getOpenGroups(listGroups: g1, completion: { g in
-                    self.groups.removeAll()
-                    self.groups.append(contentsOf: g1)
-                    for og in g {
-                        if self.groups.first(where: { $0.id == og.id }) == nil {
-                            self.groups.append(og)
-                        }
-                    }
-                    DispatchQueue.main.async {
-                        self.tableView.reloadData()
-                    }
-                })
-            }
-        }
-    }
-    
-    // MARK: - Data source
-    
-    func getData() {
-        getChats {
-            self.getContacts {
-                self.getGroups { g1 in
-                    self.getOpenGroups(listGroups: g1, completion: { g in
-                        self.groups.removeAll()
-                        self.groups.append(contentsOf: g1)
-                        for og in g {
-                            if self.groups.first(where: { $0.id == og.id }) == nil {
-                                self.groups.append(og)
-                            }
-                        }
-                        DispatchQueue.main.async {
-                            self.tableView.reloadData()
-                        }
-                    })
-                }
-            }
-        }
-    }
-    
-    func getChats(completion: @escaping ()->()) {
-        self.chats.removeAll()
-        DispatchQueue.global().async {
-            self.chats.append(contentsOf: Chat.getData())
-            completion()
-        }
-    }
-    
-    private func getContacts(completion: @escaping ()->()) {
-        self.contacts.removeAll()
-        DispatchQueue.global().async {
-            Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT f_pin, first_name, last_name, image_id, official_account, user_type FROM BUDDY where f_pin <> '\(UserDefaults.standard.string(forKey: "me")!)' order by 5 desc, 2 collate nocase asc") {
-                    while cursorData.next() {
-                        let user = User(pin: cursorData.string(forColumnIndex: 0) ?? "",
-                                        firstName: cursorData.string(forColumnIndex: 1) ?? "",
-                                        lastName: cursorData.string(forColumnIndex: 2) ?? "",
-                                        thumb: cursorData.string(forColumnIndex: 3) ?? "",
-                                        userType: cursorData.string(forColumnIndex: 5) ?? "")
-                        if (user.firstName + " " + user.lastName).trimmingCharacters(in: .whitespaces) == "USR\(user.pin)" {
-                            continue
-                        }
-                        user.official = cursorData.string(forColumnIndex: 4) ?? ""
-                        self.contacts.append(user)
-                    }
-                    cursorData.close()
-                }
-                completion()
-            })
-        }
-    }
-    
-    private func getGroupRecursive(fmdb: FMDatabase, id: String = "", parent: String = "") -> [Group] {
-        var data: [Group] = []
-        var query = "select g.group_id, g.f_name, g.image_id, g.quote, g.created_by, g.created_date, g.parent, g.group_type, g.is_open, g.official, g.is_education from GROUPZ g where "
-        if id.isEmpty {
-            query += "g.parent = '\(parent)'"
-        } else {
-            query += "g.group_id = '\(id)'"
-        }
-        if let cursor = Database.shared.getRecords(fmdb: fmdb, query: query) {
-            while cursor.next() {
-                let group = Group(
-                    id: cursor.string(forColumnIndex: 0) ?? "",
-                    name: cursor.string(forColumnIndex: 1) ?? "",
-                    profile: cursor.string(forColumnIndex: 2) ?? "",
-                    quote: cursor.string(forColumnIndex: 3) ?? "",
-                    by: cursor.string(forColumnIndex: 4) ?? "",
-                    date: cursor.string(forColumnIndex: 5) ?? "",
-                    parent: cursor.string(forColumnIndex: 6) ?? "",
-                    chatId: "",
-                    groupType: cursor.string(forColumnIndex: 7) ?? "",
-                    isOpen: cursor.string(forColumnIndex: 8) ?? "",
-                    official: cursor.string(forColumnIndex: 9) ?? "",
-                    isEducation: cursor.string(forColumnIndex: 10) ?? "")
-                
-                if group.chatId.isEmpty {
-                    let lounge = Group(id: group.id, name: "Lounge".localized(), profile: "", quote: group.quote, by: group.by, date: group.date, parent: group.id, chatId: group.chatId, groupType: group.groupType, isOpen: group.isOpen, official: group.official, isEducation: group.isEducation, isLounge: true)
-                    group.childs.append(lounge)
-                }
-                
-                if let topicCursor = Database.shared.getRecords(fmdb: fmdb, query: "select chat_id, title, thumb from DISCUSSION_FORUM where group_id = '\(group.id)'") {
-                    while topicCursor.next() {
-                        let topic = Group(id: group.id,
-                                          name: topicCursor.string(forColumnIndex: 1) ?? "",
-                                          profile: topicCursor.string(forColumnIndex: 2) ?? "",
-                                          quote: group.quote,
-                                          by: group.by,
-                                          date: group.date,
-                                          parent: group.id,
-                                          chatId: topicCursor.string(forColumnIndex: 0) ?? "",
-                                          groupType: group.groupType,
-                                          isOpen: group.isOpen,
-                                          official: group.official,
-                                          isEducation: group.isEducation)
-                        group.childs.append(topic)
-                    }
-                    topicCursor.close()
-                }
-                
-                if !group.id.isEmpty {
-                    if group.official == "1" {
-                        let idMe = UserDefaults.standard.string(forKey: "me") as String?
-                        if let cursorUser = Database.shared.getRecords(fmdb: fmdb, query: "SELECT user_type FROM BUDDY where f_pin='\(idMe!)'"), cursorUser.next() {
-//                            if cursorUser.string(forColumnIndex: 0) == "23" || cursorUser.string(forColumnIndex: 0) == "24" {
-//                                group.childs.append(contentsOf: getGroupRecursive(fmdb: fmdb, parent: group.id))
-//                            }
-                            group.childs.append(contentsOf: getGroupRecursive(fmdb: fmdb, parent: group.id))
-                            cursorUser.close()
-                        }
-                    } else if group.official != "1"{
-                        group.childs.append(contentsOf: getGroupRecursive(fmdb: fmdb, parent: group.id))
-                    }
-                    group.childs = group.childs.sorted(by: { $0.name < $1.name })
-                    let dataLounge = group.childs.filter({$0.name == "Lounge".localized()})
-                    group.childs = group.childs.filter({ $0.name != "Lounge".localized() })
-                    group.childs.insert(contentsOf: dataLounge, at: 0)
-                }
-                data.append(group)
-            }
-            cursor.close()
-        }
-        return data
-    }
-    
-    private func getOpenGroups(listGroups: [Group], completion: @escaping ([Group]) -> ()) {
-        if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getOpenGroups(p_account: "1,2,3,5,6,7", offset: "0", search: "")) {
-            var dataGroups: [Group] = []
-            if (response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "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?]] {
-                    for dataJson in json {
-                        let group = Group(
-                            id: dataJson[CoreMessage_TMessageKey.GROUP_ID] as? String ?? "",
-                            name: dataJson[CoreMessage_TMessageKey.GROUP_NAME] as? String ?? "",
-                            profile: dataJson[CoreMessage_TMessageKey.THUMB_ID] as? String ?? "",
-                            quote: dataJson[CoreMessage_TMessageKey.QUOTE] as? String ?? "",
-                            by: dataJson[CoreMessage_TMessageKey.BLOCK] as? String ?? "",
-                            date: "",
-                            parent: "",
-                            chatId: "",
-                            groupType: "NOTJOINED",
-                            isOpen: dataJson[CoreMessage_TMessageKey.IS_OPEN] as? String ?? "",
-                            official: "0",
-                            isEducation: "")
-                        dataGroups.append(group)
-                    }
-                }
-            } else {
-                DispatchQueue.main.async {
-                    self.groups.removeAll()
-                    self.groups.append(contentsOf: listGroups)
-                    self.tableView.reloadData()
-                }
-            }
-            completion(dataGroups)
-        }
-    }
-    
-    private func getGroups(id: String = "", parent: String = "", completion: @escaping ([Group]) -> ()) {
-        DispatchQueue.global().async {
-            Database.shared.database?.inTransaction({ fmdb, rollback in
-                completion(self.getGroupRecursive(fmdb: fmdb, id: id, parent: parent))
-            })
-        }
-    }
-    
-    private func pullBuddy() {
-        if let me = UserDefaults.standard.string(forKey: "me") {
-            DispatchQueue.global().async {
-                let _ = Nexilis.write(message: CoreMessage_TMessageBank.getBatchBuddiesInfos(p_f_pin: me, last_update: 0))
-            }
-        }
-    }
-    
-    private func joinOpenGroup(groupId: String, flagMember: String = "0", completion: @escaping (Bool) -> ()) {
-        DispatchQueue.global().async {
-            var result: Bool = false
-            let idMe = UserDefaults.standard.string(forKey: "me") as String?
-            if let response = Nexilis.writeAndWait(message: CoreMessage_TMessageBank.getAddGroupMember(p_group_id: groupId, p_member_pin: idMe!, p_position: "0")), response.isOk() {
-                result = true
-            }
-            completion(result)
-        }
-    }
-    
-}
-
-// MARK: - Table view data source
-
-extension ContactChatViewController {
-    
-    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        switch segment.selectedSegmentIndex {
-        case 0:
-            let data: Chat
-            if isFilltering {
-                data = fillteredData[indexPath.row] as! Chat
-            } else {
-                data = chats[indexPath.row]
-            }
-            if let chooser = isChooser {
-                if data.pin == "-999"{
-                    return
-                }
-                chooser(data.messageScope, data.pin)
-                dismiss(animated: true, completion: nil)
-                return
-            }
-            let user = User.getData(pin: data.pin)
-            if user != nil || data.pin == "-999" {
-                let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
-                editorPersonalVC.hidesBottomBarWhenPushed = true
-                editorPersonalVC.unique_l_pin = data.pin
-                navigationController?.show(editorPersonalVC, sender: nil)
-            } else {
-                let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
-                editorGroupVC.hidesBottomBarWhenPushed = true
-                editorGroupVC.unique_l_pin = data.pin
-                navigationController?.show(editorGroupVC, sender: nil)
-            }
-        case 1:
-            let data: User
-            if isFilltering {
-                data = fillteredData[indexPath.row] as! User
-            } else {
-                data = contacts[indexPath.row]
-            }
-            if let chooser = isChooser {
-                chooser("3", data.pin)
-                dismiss(animated: true, completion: nil)
-                return
-            }
-            let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
-            editorPersonalVC.hidesBottomBarWhenPushed = true
-            editorPersonalVC.unique_l_pin = data.pin
-            navigationController?.show(editorPersonalVC, sender: nil)
-        case 2:
-            let group: Group
-            if isFilltering {
-                if indexPath.row == 0 {
-                    group = fillteredData[indexPath.section] as! Group
-                } else {
-                    group = (fillteredData[indexPath.section] as! Group).childs[indexPath.row - 1]
-                }
-            } else {
-                if indexPath.row == 0 {
-                    group = groups[indexPath.section]
-                } else {
-                    group = groups[indexPath.section].childs[indexPath.row - 1]
-                }
-            }
-            group.isSelected = !group.isSelected
-            if !group.isSelected{
-                var sects = 0
-                var sect = indexPath.section
-                var id = group.id
-                if let e = groupMap[id] {
-                    var loooop = true
-                    repeat {
-                        let c = sect + 1
-                        if isFilltering {
-                            if let o = self.fillteredData[c] as? Group {
-                                if o.parent == id {
-                                    sects = sects + 1
-                                    sect = c
-                                    id = o.id
-                                }
-                                else {
-                                    loooop = false
-                                }
-                            }
-                        }
-                        else {
-                            if self.groups[c].parent == id {
-                                sects = sects + 1
-                                sect = c
-                                id = self.groups[c].id
-                            }
-                            else {
-                                loooop = false
-                            }
-                        }
-                    } while(loooop)
-                }
-                for i in stride(from: sects, to: 0, by: -1){
-                    if isFilltering {
-                        self.fillteredData.remove(at: indexPath.section + i)
-                    }
-                    else {
-                        self.groups.remove(at: indexPath.section + i)
-                    }
-                }
-                groupMap.removeValue(forKey: group.id)
-            }
-            if group.groupType == "NOTJOINED" {
-                let alert = UIAlertController(title: "Do you want to join this group?".localized(), message: "Groups : \(group.name)\nMembers: \(group.by)".localized(), preferredStyle: .alert)
-                alert.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel, handler: nil))
-                alert.addAction(UIAlertAction(title: "Join".localized(), style: .default, handler: {(_) in
-                    self.joinOpenGroup(groupId: group.id, completion: { result in
-                        if result {
-                            DispatchQueue.main.async {
-                                let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
-                                editorGroupVC.hidesBottomBarWhenPushed = true
-                                editorGroupVC.unique_l_pin = group.id
-                                self.navigationController?.show(editorGroupVC, sender: nil)
-                            }
-                        }
-                    })
-                }))
-                self.present(alert, animated: true, completion: nil)
-                return
-            }
-            if group.childs.count == 0 {
-                let groupId = group.chatId.isEmpty ? group.id : group.chatId
-                if let chooser = isChooser {
-                    chooser("4", groupId)
-                    dismiss(animated: true, completion: nil)
-                    return
-                }
-                let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
-                editorGroupVC.hidesBottomBarWhenPushed = true
-                editorGroupVC.unique_l_pin = groupId
-                navigationController?.show(editorGroupVC, sender: nil)
-            } else {
-                if indexPath.row == 0 {
-                    tableView.reloadData()
-                } else {
-                    getGroups(id: group.id) { g in
-                        DispatchQueue.main.async {
-                            print("index path section: \(indexPath.section)")
-                            print("index path row: \(indexPath.row)")
-//                            print("index path item: \(indexPath.item)")
-                            if self.isFilltering {
-//                                self.fillteredData.remove(at: indexPath.section)
-                                if self.fillteredData[indexPath.section] is Group {
-                                    self.groupMap[(self.fillteredData[indexPath.section] as! Group).id] = 1
-                                    self.fillteredData.insert(contentsOf: g, at: indexPath.section + 1)
-                                }
-                            } else {
-//                                self.groups.remove(at: indexPath.section)
-                                self.groupMap[self.groups[indexPath.section].id] = 1
-                                self.groups.insert(contentsOf: g, at: indexPath.section + 1)
-                            }
-                            print("groupMap: \(self.groupMap)")
-                            tableView.reloadData()
-                        }
-                    }
-                }
-            }
-        default:
-            let data = contacts[indexPath.row]
-            let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
-            editorPersonalVC.hidesBottomBarWhenPushed = true
-            editorPersonalVC.unique_l_pin = data.pin
-            navigationController?.show(editorPersonalVC, sender: nil)
-        }
-    }
-    
-}
-
-extension ContactChatViewController {
-    
-    override func numberOfSections(in tableView: UITableView) -> Int {
-        if isFilltering {
-            if segment.selectedSegmentIndex == 2 {
-                return fillteredData.count
-            }
-            return 1
-        } else {
-            if segment.selectedSegmentIndex == 2 {
-                return groups.count
-            }
-            return 1
-        }
-    }
-    
-    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        var value = 0
-        if isFilltering {
-            if segment.selectedSegmentIndex == 2, let groups = fillteredData as? [Group] {
-                let group = groups[section]
-                if group.isSelected {
-                    if let g = groupMap[group.id] {
-                        value = 1
-                    }
-                    else {
-                        value = group.childs.count + 1
-                    }
-                } else {
-                    value = 1
-                }
-            }
-            return fillteredData.count
-        }
-        switch segment.selectedSegmentIndex {
-        case 0:
-            value = chats.count
-        case 1:
-            value = contacts.count
-        case 2:
-            let group = groups[section]
-            if group.isSelected {
-                if let g = groupMap[group.id] {
-                    value = 1
-                }
-                else {
-                    value = group.childs.count + 1
-                }
-            } else {
-                value = 1
-            }
-        default:
-            value = chats.count
-        }
-        return value
-    }
-    
-    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        var cell: UITableViewCell!
-        switch segment.selectedSegmentIndex {
-        case 0:
-            cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierChat", for: indexPath)
-            cell.separatorInset.left = 60.0
-            let content = cell.contentView
-            if content.subviews.count > 0 {
-                content.subviews.forEach { $0.removeFromSuperview() }
-            }
-            let data: Chat
-            if isFilltering {
-                data = fillteredData[indexPath.row] as! Chat
-            } else {
-                data = chats[indexPath.row]
-            }
-            let imageView = UIImageView()
-            content.addSubview(imageView)
-            imageView.translatesAutoresizingMaskIntoConstraints = false
-            NSLayoutConstraint.activate([
-                imageView.leadingAnchor.constraint(equalTo: content.leadingAnchor, constant: 10.0),
-                imageView.topAnchor.constraint(equalTo: content.topAnchor, constant: 10.0),
-                imageView.bottomAnchor.constraint(equalTo: content.bottomAnchor, constant: -20.0),
-                imageView.widthAnchor.constraint(equalToConstant: 40.0),
-                imageView.heightAnchor.constraint(equalToConstant: 40.0)
-            ])
-            if data.profile.isEmpty && data.pin != "-999" {
-                let user = User.getData(pin: data.pin)
-                if user != nil {
-                    imageView.image = UIImage(named: "Profile---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
-                } else {
-                    imageView.image = UIImage(named: "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
-                }
-            } else {
-                getImage(name: data.profile, placeholderImage: UIImage(named: data.pin == "-999" ? "gaspol_icon" : "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in
-                    imageView.image = image
-                })
-            }
-            let titleView = UILabel()
-            content.addSubview(titleView)
-            titleView.translatesAutoresizingMaskIntoConstraints = false
-            NSLayoutConstraint.activate([
-                titleView.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: 10.0),
-                titleView.topAnchor.constraint(equalTo: content.topAnchor, constant: 10.0),
-                titleView.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -40.0),
-            ])
-            titleView.text = data.name
-            titleView.font = UIFont.systemFont(ofSize: 14, weight: .medium)
-            
-            let messageView = UILabel()
-            content.addSubview(messageView)
-            messageView.translatesAutoresizingMaskIntoConstraints = false
-            NSLayoutConstraint.activate([
-                messageView.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: 10.0),
-                messageView.topAnchor.constraint(equalTo: titleView.bottomAnchor, constant: 5.0),
-                messageView.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -40.0),
-            ])
-            messageView.textColor = .gray
-            let text = Utils.previewMessageText(chat: data)
-            if let attributeText = text as? NSAttributedString {
-                messageView.attributedText = attributeText
-            } else if let stringText = text as? String {
-                messageView.text = stringText
-            }
-            messageView.font = UIFont.systemFont(ofSize: 12)
-            messageView.numberOfLines = 2
-            
-            if data.counter != "0" {
-                let viewCounter = UIView()
-                content.addSubview(viewCounter)
-                viewCounter.translatesAutoresizingMaskIntoConstraints = false
-                NSLayoutConstraint.activate([
-                    viewCounter.centerYAnchor.constraint(equalTo: content.centerYAnchor),
-                    viewCounter.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -20),
-                    viewCounter.widthAnchor.constraint(greaterThanOrEqualToConstant: 20),
-                    viewCounter.heightAnchor.constraint(equalToConstant: 20)
-                ])
-                viewCounter.backgroundColor = .systemRed
-                viewCounter.layer.cornerRadius = 10
-                viewCounter.clipsToBounds = true
-                viewCounter.layer.borderWidth = 0.5
-                viewCounter.layer.borderColor = UIColor.secondaryColor.cgColor
-
-                let labelCounter = UILabel()
-                viewCounter.addSubview(labelCounter)
-                labelCounter.translatesAutoresizingMaskIntoConstraints = false
-                NSLayoutConstraint.activate([
-                    labelCounter.centerYAnchor.constraint(equalTo: viewCounter.centerYAnchor),
-                    labelCounter.leadingAnchor.constraint(equalTo: viewCounter.leadingAnchor, constant: 2),
-                    labelCounter.trailingAnchor.constraint(equalTo: viewCounter.trailingAnchor, constant: -2),
-                ])
-                labelCounter.font = UIFont.systemFont(ofSize: 11)
-                if Int(data.counter)! > 99 {
-                    labelCounter.text = "99+"
-                } else {
-                    labelCounter.text = data.counter
-                }
-                labelCounter.textColor = .secondaryColor
-                labelCounter.textAlignment = .center
-            }
-        case 1:
-            cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierContact", for: indexPath)
-            var content = cell.defaultContentConfiguration()
-            let data: User
-            if isFilltering {
-                data = fillteredData[indexPath.row] as! User
-            } else {
-                data = contacts[indexPath.row]
-            }
-            content.imageProperties.maximumSize = CGSize(width: 40, height: 40)
-            getImage(name: data.thumb, placeholderImage: UIImage(named: "Profile---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in
-                content.image = image
-            })
-            if (data.official == "1") {
-                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(data.fullName)", size: 15, y: -4)
-            }
-            else if data.userType == "23" {
-                content.attributedText = self.set(image: UIImage(named: "ic_internal", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(data.fullName)", size: 15, y: -4)
-            } else if data.userType == "24" {
-                content.attributedText = self.set(image: UIImage(named: "pb_call_center", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(data.fullName)", size: 15, y: -4)
-            }
-            else {
-                content.text = data.fullName
-            }
-            content.textProperties.font = UIFont.systemFont(ofSize: 14)
-            cell.contentConfiguration = content
-        case 2:
-            cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierGroup", for: indexPath)
-            var content = cell.defaultContentConfiguration()
-            content.textProperties.font = UIFont.systemFont(ofSize: 14)
-            let group: Group
-            if isFilltering {
-                if indexPath.row == 0 {
-                    group = fillteredData[indexPath.section] as! Group
-                } else {
-                    group = (fillteredData[indexPath.section] as! Group).childs[indexPath.row - 1]
-                }
-            } else {
-                if indexPath.row == 0 {
-                    group = groups[indexPath.section]
-                } else {
-                    group = groups[indexPath.section].childs[indexPath.row - 1]
-                }
-            }
-            if group.official == "1" && group.parent == "" {
-                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4)
-            }
-            else if group.isOpen == "1" && group.parent == "" {
-                if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
-                } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4)
-                }
-            } else if group.parent == "" {
-                if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
-                } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4)
-                }
-            } else {
-                content.text = group.name
-            }
-            if group.childs.count > 0 {
-                let iconName = (group.isSelected) ? "chevron.up.circle" : "chevron.down.circle"
-                let imageView = UIImageView(image: UIImage(systemName: iconName))
-                imageView.tintColor = .black
-                cell.accessoryView = imageView
-            }
-            else {
-                cell.accessoryView = nil
-                cell.accessoryType = .none
-            }
-            content.imageProperties.maximumSize = CGSize(width: 40, height: 40)
-            getImage(name: group.profile, placeholderImage: UIImage(named: "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath) { result, isDownloaded, image in
-                content.image = image
-            }
-            cell.contentConfiguration = content
-        default:
-            cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierContact", for: indexPath)
-            var content = cell.defaultContentConfiguration()
-            content.text = ""
-            cell.contentConfiguration = content
-        }
-        return cell
-    }
-    
-    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return 70
-    }
-    
-}
-
-
-extension ContactChatViewController: UISearchControllerDelegate, UISearchBarDelegate, UISearchResultsUpdating {
-    
-    func updateSearchResults(for searchController: UISearchController) {
-        filterContentForSearchText(searchController.searchBar.text!)
-    }
-    
-    func set(image: UIImage, with text: String, size: CGFloat, y: CGFloat) -> NSAttributedString {
-        let attachment = NSTextAttachment()
-        attachment.image = image
-        attachment.bounds = CGRect(x: 0, y: y, width: size, height: size)
-        let attachmentStr = NSAttributedString(attachment: attachment)
-        
-        let mutableAttributedString = NSMutableAttributedString()
-        mutableAttributedString.append(attachmentStr)
-        
-        let textString = NSAttributedString(string: text)
-        mutableAttributedString.append(textString)
-        
-        return mutableAttributedString
-    }
-    
-}

+ 117 - 53
src/mainIOS.py

@@ -15,12 +15,17 @@ app.base_project = "/Users/maronakins/Documents/AppBuilder/appbuilder-ios/AppBui
 app.nexilis_lite = "/Users/maronakins/Documents/AppBuilder/appbuilder-ios/NexilisLite"
 app.temp_folder = "/Users/maronakins/BuildIos"
 app.app_folder = "/Users/maronakins/"
+app.asset_folder = "/Users/maronakins/BuildIosAssets"
 app.verbose = True
 app.ssl = None
 app.keytool = '/usr/bin/keytool'
 app.username = "maronakins"
 # app.ios_platform_ids = ["bb8f256703e8fbe84da414cee20cb4d0eca3388d"]
 app.ios_platform_ids = []
+app.app_name = "AppBuilder"
+app.package_id = "io.newuniverse.AppBuilder420"
+app.version_code = "1"
+app.version_name = "1.0.0"
 
 app.base_project_name = os.path.basename(app.base_project)
 
@@ -154,29 +159,54 @@ def change_font(c_code_path, font):
     pass
 
 
-def change_logo(c_code_path, logo, logo_float=None):
+def change_logo(c_code_path, lib_dest, logo, logo_float=None):
     app_icon_set = [29,40,57,58,60,80,87,114,120,180,1024]
     app_icon_dir = os.path.join(c_code_path, 'Assets.xcassets/AppIcon.appiconset')
-    app_float_dir = os.path.join(c_code_path, 'Assets.xcassets/pb_icon.imageset')
+    app_float_dir = os.path.join(lib_dest, 'NexilisLite/Resource/Assets.xcassets/pb_ball.imageset')
     if isinstance(logo, str):
-        logo = requests.get('https://id.palio.io/dashboardv2/uploads/logo/{}'.format(logo))
-        for size in app_icon_set:
-            img_path = os.path.join(app_icon_dir, "{}.png".format(size))
-            with open(img_path, "wb") as f:
-                f.write(logo.content)
-            with open(img_path, "rb") as f:
-                l = Image.open(f)
-                l = l.resize((size, size))
-            l.save(img_path, "PNG")
+        # try:
+        #     logo_url = requests.get('https://newuniverse.io/dashboardv2/uploads/logo/{}'.format(logo))
+        #     for size in app_icon_set:
+        #         img_path = os.path.join(app_icon_dir, "{}.png".format(size))
+        #         with open(img_path, "wb") as f:
+        #             f.write(logo_url.content)
+        #         with open(img_path, "rb") as f:
+        #             l = Image.open(f)
+        #             l = l.resize((size, size))
+        #         l.save(img_path, "PNG")
+        # except:
+        try:
+            logo_path = os.path.join(app.asset_folder, "logo", "{}".format(logo))
+            for size in app_icon_set:
+                img_path = os.path.join(app_icon_dir, "{}.png".format(size))
+                with open(logo_path, "rb") as f:
+                    l = Image.open(f)
+                    l = l.resize((size, size))
+                l.save(img_path, "PNG")
+        except:
+            print("error logo: {}".format(logo))
+            return
         if logo_float:
-            logo_float = requests.get('https://id.palio.io/dashboardv2/uploads/logofloat/{}'.format(logo_float))
-            img_path = os.path.join(app_float_dir, "nexilis_icon.png")
-            with open(img_path, "wb") as f:
-                f.write(logo_float.content)
-            with open(img_path, "rb") as f:
-                l = Image.open(f)
-                l = l.resize((512, 512))
-            l.save(img_path, "PNG")
+            # try:
+            #     logo_float_url = requests.get('https://newuniverse.io/dashboardv2/uploads/logofloat/{}'.format(logo_float))
+            #     img_path = os.path.join(app_float_dir, "pb_ball.png")
+            #     with open(img_path, "wb") as f:
+            #         f.write(logo_float_url.content)
+            #     with open(img_path, "rb") as f:
+            #         l = Image.open(f)
+            #         l = l.resize((512, 512))
+            #     l.save(img_path, "PNG")
+            # except:
+            try:
+                logo_float_path = os.path.join(app.asset_folder, "logofloat", "{}".format(logo_float))
+                img_path = os.path.join(app_float_dir, "pb_ball.png".format(size))
+                with open(logo_float_path, "rb") as f:
+                    l = Image.open(f)
+                    l = l.resize((size, size))
+                l.save(img_path, "PNG")
+            except:
+                print("error logofloat: {}".format(logo_float))
+                return
     else:
         logo = Image.open(logo)
         for size in app_icon_set:
@@ -194,27 +224,40 @@ def change_background(c_code_path, background):
     assets_dir = os.path.join(c_code_path, "Assets.xcassets")
     img_src_path_1 = os.path.join(assets_dir, "pb_lbackground_1.imageset")
     if isinstance(background, str):
-        background = []
         background = background.split(",")
         for i, b in enumerate(background):
             n = i + 1
+            print(b)
             img_src_path = os.path.join(assets_dir, "pb_lbackground_{}.imageset".format(n))
+            print(img_src_path)
             if n != 1:
-                shutil.copy(img_src_path_1,img_src_path)
-                contents_json = os.path.join(img_src_path, "Contents.json")
-                with open(contents_json, "r") as f:
-                    file_source = f.read()
-                replaced = file_source.replace("lbackground_1", "= lbackground_{}".format(n))
-                with open(contents_json, "w") as f:
-                    f.write(replaced)
+                shutil.copytree(img_src_path_1,img_src_path)
+            os.remove(os.path.join(img_src_path,"pb_lbackground_1.png"))
+            contents_json = os.path.join(img_src_path, "Contents.json")
+            with open(contents_json, "r") as f:
+                file_source = f.read()
+            replaced = file_source.replace("lbackground_1", "lbackground_{}".format(n))
+            with open(contents_json, "w") as f:
+                f.write(replaced)
             img_path = os.path.join(img_src_path, "pb_lbackground_{}.png".format(n))
-            logo = requests.get('https://id.palio.io/dashboardv2/uploads/background/{}'.format(b))
-            with open(img_path, "wb") as f:
-                f.write(logo.content)
-            with open(img_path, "rb") as f:
-                logo = Image.open(f)
-                logo = logo.resize((600, 1250))
-            logo.save(img_path, "PNG")
+            # try:
+            #     background_url = requests.get('https://newuniverse.io/dashboardv2/uploads/background/{}'.format(b))
+            #     with open(img_path, "wb") as f:
+            #         f.write(background_url.content)
+            #     with open(img_path, "rb") as f:
+            #         l = Image.open(f)
+            #         l = l.resize((600, 1250))
+            #     l.save(img_path, "PNG")
+            # except:
+            try:
+                background_path = os.path.join(app.asset_folder, "background", "{}".format(b))
+                with open(background_path, "rb") as f:
+                    l = Image.open(f)
+                    l = l.resize((600, 1250))
+                l.save(img_path, "PNG")
+            except:
+                print("error background: {}".format(b))
+                return
         second_tab = os.path.join(c_code_path, "SecondTabViewController.swift")
         fourth_tab = os.path.join(c_code_path, "FourthTabViewController.swift")
         with open(second_tab, "r") as f:
@@ -242,13 +285,23 @@ def change_fb(lib_dest, fb_icon):
         img_path = "NexilisLite/Resource/Assets.xcassets"
         img_path = os.path.join(lib_dest, img_path, "{}.imageset".format(default_fb_icon[i]), "{}.png".format(default_fb_icon[i]))
         if isinstance(fb_icon[i], str):
-            logo = requests.get('https://id.palio.io/dashboardv2/uploads/fb_icon/{}'.format(fb_icon[i]))
-            with open(img_path, "wb") as f:
-                f.write(logo.content)
-            with open(img_path, "rb") as f:
-                logo = Image.open(f)
-                logo = logo.resize((150, 150))
-                logo.save(img_path, "PNG")
+            # try:
+            #     fb_icon_url = requests.get('https://newuniverse.io/dashboardv2/uploads/fb_icon/{}'.format(fb_icon[i]))
+            #     with open(img_path, "wb") as f:
+            #         f.write(fb_icon_url.content)
+            #     with open(img_path, "rb") as f:
+            #         l = Image.open(f)
+            #         l = l.resize((150, 150))
+            #     l.save(img_path, "PNG")
+            # except:
+                try:
+                    fb_icon_path = os.path.join(app.asset_folder, "fb_icon", "{}".format(fb_icon[i]))
+                    with open(fb_icon_path, "rb") as f:
+                        l = Image.open(f)
+                        l = l.resize((150, 150))
+                    l.save(img_path, "PNG")
+                except:
+                    print("error tab icon {}: {}".format(i,fb_icon[i]))
         else:
             logo = Image.open(fb_icon[i])
             logo = logo.resize((150, 150))
@@ -277,13 +330,24 @@ def change_tab(c_code_path, tabs, tab_icon, tab3_mode):
                                 "{}_icon.imageset".format(default_tab_icon[i]),
                                 "{}_nexilis.png".format(default_tab_icon[i]))
         if isinstance(tab_icon[i], str):
-            logo = requests.get('https://id.palio.io/dashboardv2/uploads/tab_icon/{}'.format(tab_icon[i]))
-            with open(img_path, "wb") as f:
-                f.write(logo.content)
-            with open(img_path, "rb") as f:
-                logo = Image.open(f)
-                logo = logo.resize((150, 150))
-                logo.save(img_path, "PNG")
+            # try:
+            #     tab_icon_url = requests.get('https://newuniverse.io/dashboardv2/uploads/tab_icon/{}'.format(tab_icon[i]))
+            #     with open(img_path, "wb") as f:
+            #         f.write(tab_icon_url.content)
+            #     with open(img_path, "rb") as f:
+            #         l = Image.open(f)
+            #         l = l.resize((150, 150))
+            #     l.save(img_path, "PNG")
+            # except:
+            try:
+                tab_icon_path = os.path.join(app.asset_folder, "tab_icon", "{}".format(tab_icon[i]))
+                with open(tab_icon_path, "rb") as f:
+                    l = Image.open(f)
+                    l = l.resize((150, 150))
+                l.save(img_path, "PNG")
+            except:
+                print("error tab_icon {}: {}".format(i,tab_icon[i]))
+                return
         else:
             logo = Image.open(tab_icon[i])
             logo = logo.resize((150, 150))
@@ -353,8 +417,8 @@ def build_apk():
     if request.method == 'POST':
         logo = None
         logo_float = None
-        app_name = "AppBuilder"
-        package_id = "io.newuniverse.AppBuilder420"
+        app_name = app.app_name
+        package_id = app.package_id
         acc = None
         url = None
         keystore = None
@@ -365,8 +429,8 @@ def build_apk():
         tab_icon = [None, None, None, None]
         fb_icon = [None, None, None, None, None]
         background = None
-        version_code = "1"
-        version_name = "1.0.0"
+        version_code = app.version_code
+        version_name = app.version_name
         font = 0
         key = {"alias": "nexilislite", "store_password": "allyourbase", "key_password": "arebelongto", "common_name": "all", "organization_unit": "your",
                "organization_name": "base", "locality_name": "are", "state_name": "belong", "country": "to"}
@@ -524,7 +588,7 @@ def build_apk():
         change_version(path_dest, app_name, version_code, version_name)
         change_font(c_code_path, font)
         if logo:
-            change_logo(c_code_path, logo, logo_float)
+            change_logo(c_code_path, lib_dest, logo, logo_float)
         if background:
             change_background(c_code_path, background)
         change_fb(lib_dest, fb_icon)