Ver código fonte

improve hierarchy group

alqindiirsyam 2 anos atrás
pai
commit
4237267571

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

@@ -210,7 +210,7 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             }
             if ViewController.checkIsChangePerson() {
                 if param2 == "like" {
-                    self.webView.evaluateJavaScript("likeProduct('\(param1)',true);")
+                    self.webView.evaluateJavaScript("likeProduct('\(param1)',1,true);")
                 } else if param2 == "comment" {
                     self.webView.evaluateJavaScript("openComment('\(param1.split(separator: "|")[0])',\(param1.split(separator: "|")[1]),true);")
                 } else if param2 == "report_user" {

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

@@ -35,6 +35,10 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
 //        tableView.separatorColor = .gray
         tableView.separatorStyle = .none
         
+        if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_DOCKED {
+            tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 80, right: 0)
+        }
+        
         switchVibrateMode.tintColor = .gray
         switchSaveToGallery.tintColor = .gray
         switchAutoDownload.tintColor = .gray

+ 150 - 128
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -119,6 +119,10 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         tableView.tableHeaderView = segment
         tableView.tableFooterView = UIView()
         
+        if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_DOCKED {
+            tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 80, right: 0)
+        }
+        
         pullBuddy()
         let cpaasMode = PrefsUtil.getCpaasMode()
         let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
@@ -440,7 +444,7 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
     
     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 "
+        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, g.level from GROUPZ g where "
         if id.isEmpty {
             query += "g.parent = '\(parent)'"
         } else {
@@ -460,10 +464,11 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
                     groupType: cursor.string(forColumnIndex: 7) ?? "",
                     isOpen: cursor.string(forColumnIndex: 8) ?? "",
                     official: cursor.string(forColumnIndex: 9) ?? "",
-                    isEducation: cursor.string(forColumnIndex: 10) ?? "")
+                    isEducation: cursor.string(forColumnIndex: 10) ?? "",
+                    level: cursor.string(forColumnIndex: 11) ?? "")
                 
                 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)
+                    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, level: group.level != "-1" ? group.level : "2")
                     group.childs.append(lounge)
                 }
                 
@@ -480,22 +485,28 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
                                           groupType: group.groupType,
                                           isOpen: group.isOpen,
                                           official: group.official,
-                                          isEducation: group.isEducation)
+                                          isEducation: group.isEducation,
+                                          level: group.level != "-1" ? group.level : "2")
                         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() {
-                            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))
-                    }
+//                    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() {
+//                            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.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)
             }
@@ -613,148 +624,154 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                 navigationController?.show(editorGroupVC, sender: nil)
             }
         case 1:
-            let group: Group
-            if isFilltering {
-                if indexPath.row == 0 {
-                    group = fillteredData[indexPath.section] as! Group
-                } else {
-                    if (fillteredData[indexPath.section] as! Group).childs.count > 0 {
-                        group = (fillteredData[indexPath.section] as! Group).childs[indexPath.row - 1]
-                    } else {
-                        return
-                    }
-                }
+            expandCollapseGroup(tableView: tableView, indexPath: indexPath)
+        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)
+        }
+    }
+    
+    func expandCollapseGroup(tableView: UITableView, indexPath: IndexPath) {
+        let group: Group
+        if isFilltering {
+            if indexPath.row == 0 {
+                group = fillteredData[indexPath.section] as! Group
             } else {
-                if indexPath.row == 0 {
-                    group = groups[indexPath.section]
+                if (fillteredData[indexPath.section] as! Group).childs.count > 0 {
+                    group = (fillteredData[indexPath.section] as! Group).childs[indexPath.row - 1]
                 } else {
-                    group = groups[indexPath.section].childs[indexPath.row - 1]
+                    return
                 }
             }
-            group.isSelected = !group.isSelected
-            if !group.isSelected{
-                var sects = 0
-                var sect = indexPath.section
-                var id = group.id
-                if let _ = 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
-                                    (self.fillteredData[c] as! Group).isSelected = false
-                                    self.groupMap.removeValue(forKey: (self.fillteredData[c] as! Group).id)
-                                }
-                                else {
-                                    loooop = false
-                                }
-                            }
-                        }
-                        else {
-                            if c < self.groups.count && self.groups[c].parent == id {
+        } 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 _ = 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 = self.groups[c].id
-                                self.groups[c].isSelected = false
-                                self.groupMap.removeValue(forKey: self.groups[c].id)
+                                id = o.id
+                                (self.fillteredData[c] as! Group).isSelected = false
+                                self.groupMap.removeValue(forKey: (self.fillteredData[c] as! Group).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)
+                        if c < self.groups.count && self.groups[c].parent == id {
+                            sects = sects + 1
+                            sect = c
+                            id = self.groups[c].id
+                            self.groups[c].isSelected = false
+                            self.groupMap.removeValue(forKey: self.groups[c].id)
+                        }
+                        else {
+                            loooop = false
+                        }
                     }
-                }
-                groupMap.removeValue(forKey: group.id)
+                } while(loooop)
             }
-            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 {
-                                self.groupMap.removeAll()
-                                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
+            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)
+                }
             }
-            if group.childs.count == 0 {
-                Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                    let idMe = UserDefaults.standard.string(forKey: "me") as String?
-                    if let cursorMember = Database.shared.getRecords(fmdb: fmdb, query: "select f_pin from GROUPZ_MEMBER where group_id = '\(group.id)' and f_pin = '\(idMe!)'"), cursorMember.next() {
-                        let groupId = group.chatId.isEmpty ? group.id : group.chatId
-                        if let chooser = isChooser {
-                            chooser("4", groupId)
-                            dismiss(animated: true, completion: nil)
-                            return
-                        }
-                        self.groupMap.removeAll()
-                        let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
-                        editorGroupVC.hidesBottomBarWhenPushed = true
-                        editorGroupVC.unique_l_pin = groupId
-                        navigationController?.show(editorGroupVC, sender: nil)
-                        cursorMember.close()
-                    } else {
-                        var viewController = UIApplication.shared.windows.first!.rootViewController
-                        if !(viewController is ViewController) {
-                            viewController = self.parent
-                        }
-                        if let viewController = viewController as? ViewController {
-                            viewController.view.makeToast("You are not a member of this group".localized(), duration: 0.5)
+            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 {
+                            self.groupMap.removeAll()
+                            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)
                         }
                     }
                 })
-            } else {
-                if indexPath.row == 0 {
-                    tableView.reloadData()
+            }))
+            self.present(alert, animated: true, completion: nil)
+            return
+        }
+        if group.childs.count == 0 {
+            Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                let idMe = UserDefaults.standard.string(forKey: "me") as String?
+                if let cursorMember = Database.shared.getRecords(fmdb: fmdb, query: "select f_pin from GROUPZ_MEMBER where group_id = '\(group.id)' and f_pin = '\(idMe!)'"), cursorMember.next() {
+                    let groupId = group.chatId.isEmpty ? group.id : group.chatId
+                    if let chooser = isChooser {
+                        chooser("4", groupId)
+                        dismiss(animated: true, completion: nil)
+                        return
+                    }
+                    self.groupMap.removeAll()
+                    let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
+                    editorGroupVC.hidesBottomBarWhenPushed = true
+                    editorGroupVC.unique_l_pin = groupId
+                    navigationController?.show(editorGroupVC, sender: nil)
+                    cursorMember.close()
                 } else {
-                    getGroups(id: group.id) { g in
-                        DispatchQueue.main.async {
-                            print("index path section: \(indexPath.section)")
-                            print("index path row: \(indexPath.row)")
+                    var viewController = UIApplication.shared.windows.first!.rootViewController
+                    if !(viewController is ViewController) {
+                        viewController = self.parent
+                    }
+                    if let viewController = viewController as? ViewController {
+                        viewController.view.makeToast("You are not a member of this group".localized(), duration: 0.5)
+                    }
+                }
+            })
+        } 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 {
+                        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)
+                            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)
                             }
-                            print("groupMap: \(self.groupMap)")
-                            tableView.reloadData()
+                        } 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()
+                        
+                        self.expandCollapseGroup(tableView: tableView, indexPath: IndexPath(row: 0, section: indexPath.section + 1))
                     }
                 }
             }
-        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)
         }
     }
     
@@ -1023,6 +1040,11 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                 content.image = image
             }
             cell.contentConfiguration = content
+            if group.level != "-1" && Int(group.level)! < 7 {
+                cell.contentView.layoutMargins = .init(top: 0.0, left: CGFloat(25 * Int(group.level)!), bottom: 0.0, right: 0)
+            } else if Int(group.level)! > 6 {
+                cell.contentView.layoutMargins = .init(top: 0.0, left: CGFloat(25 * (Int(group.level)! - 6)), bottom: 0.0, right: 0)
+            }
         default:
             cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierContact", for: indexPath)
             var content = cell.defaultContentConfiguration()

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

@@ -223,7 +223,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             }
             if ViewController.checkIsChangePerson() {
                 if param2 == "like" {
-                    self.webView.evaluateJavaScript("likeProduct('\(param1)',true);")
+                    self.webView.evaluateJavaScript("likeProduct('\(param1)',1,true);")
                 } else if param2 == "comment" {
                     self.webView.evaluateJavaScript("openComment('\(param1.split(separator: "|")[0])',\(param1.split(separator: "|")[1]),true);")
                 } else if param2 == "report_user" {

+ 137 - 123
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -294,7 +294,7 @@ class ContactChatViewController: UITableViewController {
     
     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 "
+        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, g.level from GROUPZ g where "
         if id.isEmpty {
             query += "g.parent = '\(parent)'"
         } else {
@@ -314,10 +314,11 @@ class ContactChatViewController: UITableViewController {
                     groupType: cursor.string(forColumnIndex: 7) ?? "",
                     isOpen: cursor.string(forColumnIndex: 8) ?? "",
                     official: cursor.string(forColumnIndex: 9) ?? "",
-                    isEducation: cursor.string(forColumnIndex: 10) ?? "")
+                    isEducation: cursor.string(forColumnIndex: 10) ?? "",
+                    level: cursor.string(forColumnIndex: 11) ?? "")
                 
                 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)
+                    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, level: group.level != "-1" ? group.level : "2")
                     group.childs.append(lounge)
                 }
                 
@@ -334,25 +335,27 @@ class ContactChatViewController: UITableViewController {
                                           groupType: group.groupType,
                                           isOpen: group.isOpen,
                                           official: group.official,
-                                          isEducation: group.isEducation)
+                                          isEducation: group.isEducation,
+                                          level: group.level != "-1" ? group.level : "2")
                         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))
-                    }
+//                    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.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() })
@@ -498,138 +501,144 @@ extension ContactChatViewController {
             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]
-                }
+            expandCollapseGroup(tableView: tableView, indexPath: indexPath)
+        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)
+        }
+    }
+    
+    func expandCollapseGroup(tableView: UITableView, indexPath: IndexPath) {
+        let group: Group
+        if isFilltering {
+            if indexPath.row == 0 {
+                group = fillteredData[indexPath.section] as! Group
             } else {
-                if indexPath.row == 0 {
-                    group = groups[indexPath.section]
-                } else {
-                    group = groups[indexPath.section].childs[indexPath.row - 1]
-                }
+                group = (fillteredData[indexPath.section] as! Group).childs[indexPath.row - 1]
             }
-            group.isSelected = !group.isSelected
-            if !group.isSelected{
-                var sects = 0
-                var sect = indexPath.section
-                var id = group.id
-                if let _ = 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
-                                    (self.fillteredData[c] as! Group).isSelected = false
-                                    self.groupMap.removeValue(forKey: (self.fillteredData[c] as! Group).id)
-                                }
-                                else {
-                                    loooop = false
-                                }
-                            }
-                        }
-                        else {
-                            if c < self.groups.count && self.groups[c].parent == id {
+        } 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 _ = 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 = self.groups[c].id
-                                self.groups[c].isSelected = false
-                                self.groupMap.removeValue(forKey: self.groups[c].id)
+                                id = o.id
+                                (self.fillteredData[c] as! Group).isSelected = false
+                                self.groupMap.removeValue(forKey: (self.fillteredData[c] as! Group).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)
+                        if c < self.groups.count && self.groups[c].parent == id {
+                            sects = sects + 1
+                            sect = c
+                            id = self.groups[c].id
+                            self.groups[c].isSelected = false
+                            self.groupMap.removeValue(forKey: 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 {
-                                self.groupMap.removeAll()
-                                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 {
-                Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                    let idMe = UserDefaults.standard.string(forKey: "me") as String?
-                    if let cursorMember = Database.shared.getRecords(fmdb: fmdb, query: "select f_pin from GROUPZ_MEMBER where group_id = '\(group.id)' and f_pin = '\(idMe!)'"), cursorMember.next() {
-                        let groupId = group.chatId.isEmpty ? group.id : group.chatId
-                        if let chooser = isChooser {
-                            chooser("4", groupId)
-                            dismiss(animated: true, completion: nil)
-                            return
+            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 {
+                            self.groupMap.removeAll()
+                            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.groupMap.removeAll()
-                        let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
-                        editorGroupVC.hidesBottomBarWhenPushed = true
-                        editorGroupVC.unique_l_pin = groupId
-                        navigationController?.show(editorGroupVC, sender: nil)
-                        cursorMember.close()
-                    } else {
-                        self.view.makeToast("You are not a member of this group".localized(), duration: 0.5)
                     }
                 })
-            } else {
-                if indexPath.row == 0 {
-                    tableView.reloadData()
+            }))
+            self.present(alert, animated: true, completion: nil)
+            return
+        }
+        if group.childs.count == 0 {
+            Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                let idMe = UserDefaults.standard.string(forKey: "me") as String?
+                if let cursorMember = Database.shared.getRecords(fmdb: fmdb, query: "select f_pin from GROUPZ_MEMBER where group_id = '\(group.id)' and f_pin = '\(idMe!)'"), cursorMember.next() {
+                    let groupId = group.chatId.isEmpty ? group.id : group.chatId
+                    if let chooser = isChooser {
+                        chooser("4", groupId)
+                        dismiss(animated: true, completion: nil)
+                        return
+                    }
+                    self.groupMap.removeAll()
+                    let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
+                    editorGroupVC.hidesBottomBarWhenPushed = true
+                    editorGroupVC.unique_l_pin = groupId
+                    navigationController?.show(editorGroupVC, sender: nil)
+                    cursorMember.close()
                 } else {
-                    getGroups(id: group.id) { g in
-                        DispatchQueue.main.async {
-                            print("index path section: \(indexPath.section)")
-                            print("index path row: \(indexPath.row)")
+                    self.view.makeToast("You are not a member of this group".localized(), duration: 0.5)
+                }
+            })
+        } 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 {
+                        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)
+                            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)
                             }
-                            print("groupMap: \(self.groupMap)")
-                            tableView.reloadData()
+                        } 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()
+                        
+                        self.expandCollapseGroup(tableView: tableView, indexPath: IndexPath(row: 0, section: indexPath.section + 1))
                     }
                 }
             }
-        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)
         }
     }
     
@@ -928,6 +937,11 @@ extension ContactChatViewController {
                 content.image = image
             }
             cell.contentConfiguration = content
+            if group.level != "-1" && Int(group.level)! < 7 {
+                cell.contentView.layoutMargins = .init(top: 0.0, left: CGFloat(25 * Int(group.level)!), bottom: 0.0, right: 0)
+            } else if Int(group.level)! > 6 {
+                cell.contentView.layoutMargins = .init(top: 0.0, left: CGFloat(25 * (Int(group.level)! - 6)), bottom: 0.0, right: 0)
+            }
         default:
             cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifierContact", for: indexPath)
             var content = cell.defaultContentConfiguration()

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupDetailViewController.swift

@@ -20,7 +20,7 @@ class GroupDetailViewController: UITableViewController {
     
     var data: String = ""
     
-    static let SUBGROUP_LEVEL_LIMIT = 5
+    static let SUBGROUP_LEVEL_LIMIT = 10
     
     private var group: Group?