Sfoglia il codice sorgente

update burger mode

alqindiirsyam 1 anno fa
parent
commit
7d9bcea559

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

@@ -161,13 +161,7 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             dateRefresh = Date()
             FirstTabViewController.forceRefresh = false
         }
-        let cpaasMode = PrefsUtil.getCpaasMode()
-        let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
-        navigationController?.setNavigationBarHidden(!isBurger, animated: false)
-        if isBurger {
-            self.navigationController?.navigationBar.topItem?.title = Bundle.main.displayName
-            self.navigationController?.navigationBar.setNeedsLayout()
-        }
+        navigationController?.setNavigationBarHidden(true, animated: false)
     }
     
     func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

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

@@ -327,7 +327,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         navigationController?.navigationBar.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
         tabBarController?.navigationItem.leftBarButtonItem = nil
         tabBarController?.navigationItem.searchController = nil
-        tabBarController?.navigationItem.rightBarButtonItem = nil
+        checkBurgerMode()
         backgroundImage.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
         backgroundImage.image = nil
         DispatchQueue.global().async {
@@ -365,6 +365,100 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     
     // MARK: - Table view data source
     
+    func checkBurgerMode() {
+        let cpaasMode = PrefsUtil.getCpaasMode()
+        let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
+        if isBurger {
+            var childrenMenu: [UIAction] = []
+            if !Utils.getCustomButtons().isEmpty {
+                let customButtons = Utils.getCustomButtons().components(separatedBy: ",")
+                for i in 0..<customButtons.count {
+                    let package_id = customButtons[i]
+                    var app_id = ""
+                    var indexTap = 0
+                    if package_id.contains("_fb"){
+                        let listSplit = package_id.split(separator: "_", maxSplits: 1)
+                        let numIdx = listSplit[listSplit.firstIndex(where: { $0.contains("fb") }) ?? 0]
+                        indexTap = Int(String(numIdx).substring(from: 2, to: numIdx.count))!
+                        if listSplit.count == 2 {
+                            app_id = String(listSplit[1])
+                        }
+                    }
+                    var nameButton = ""
+                    switch (indexTap) {
+                    case Nexilis.IDX_ADDFRIEND :
+                        nameButton = "Add Friend".localized()
+                    case Nexilis.IDX_BROADCAST_FORM :
+                        nameButton = "Broadcast Form".localized()
+                    case Nexilis.IDX_CALL :
+                        nameButton = "Call".localized()
+                    case Nexilis.IDX_CALL_AUDIO :
+                        nameButton = "Call Audio".localized()
+                    case Nexilis.IDX_CALL_VIDEO :
+                        nameButton = "Call Video".localized()
+                    case Nexilis.IDX_CC :
+                        nameButton = "Contact Center".localized()
+                    case Nexilis.IDX_CC_STREAM :
+                        nameButton = "Contact Center Streaming".localized()
+                    case Nexilis.IDX_CHAT :
+                        nameButton = "Chat".localized()
+                    case Nexilis.IDX_CONFERENCE_ROOM_FORM :
+                        nameButton = "Video Conference Room".localized()
+                    case Nexilis.IDX_CREATE_GROUP :
+                        nameButton = "Create Group".localized()
+                    case Nexilis.IDX_CONVERSATION :
+                        nameButton = "Conversation".localized()
+                    case Nexilis.IDX_EMAIL_CONFIGURATION :
+                        nameButton = "Email Configuration".localized()
+                    case Nexilis.IDX_FAVORITEMESSAGE :
+                        nameButton = "Favorite Message".localized()
+                    case Nexilis.IDX_POST :
+                        nameButton = "New post".localized()
+                    case Nexilis.IDX_QUEUE_SYSTEM :
+                        nameButton = "Custom URL".localized()
+                    case Nexilis.IDX_NOTIF_CENTER :
+                        nameButton = "Notification Center".localized()
+                    case Nexilis.IDX_SCREENSHARING :
+                        nameButton = "Screen Sharing".localized()
+                    case Nexilis.IDX_STREAM :
+                        nameButton = "Live Streaming".localized()
+                    case Nexilis.IDX_WHITEBOARD :
+                        nameButton = "Whiteboard".localized()
+                    case Nexilis.IDX_SELF_ACT :
+                        nameButton = "Custom Action".localized()
+                    case Nexilis.IDX_SOCIAL_COMMERCE :
+                        nameButton = "Social Commerce".localized()
+                    case Nexilis.IDX_NEWS :
+                        nameButton = "News".localized()
+                    default :
+                        nameButton = ""
+                    }
+                    childrenMenu.append(UIAction(title: nameButton, handler: {(_) in
+                        Nexilis.buttonClicked(index: indexTap, id: app_id)
+                    }))
+                }
+            } else {
+                childrenMenu.append(UIAction(title: "Contact Center".localized(), handler: {(_) in
+                    Nexilis.buttonClicked(index: Nexilis.IDX_CC)
+                }))
+                childrenMenu.append(UIAction(title: "Chat".localized(), handler: {(_) in
+                    Nexilis.buttonClicked(index: Nexilis.IDX_CHAT)
+                }))
+                childrenMenu.append(UIAction(title: "Call".localized(), handler: {(_) in
+                    Nexilis.buttonClicked(index: Nexilis.IDX_CALL)
+                }))
+                childrenMenu.append(UIAction(title: "Live Streaming".localized(), handler: {(_) in
+                    Nexilis.buttonClicked(index: Nexilis.IDX_STREAM)
+                }))
+            }
+            let menu = UIMenu(title: "", children: childrenMenu)
+            let menuButton = UIBarButtonItem(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(systemName: "ellipsis")?.withTintColor(.white) : UIImage(systemName: "ellipsis"), menu: menu)
+            tabBarController?.navigationItem.rightBarButtonItem = menuButton
+        } else {
+            tabBarController?.navigationItem.rightBarButtonItem = nil
+        }
+    }
+    
     public func numberOfSections(in tableView: UITableView) -> Int {
         return Item.sections.count
     }

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

@@ -150,9 +150,7 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         }
         
         pullBuddy()
-        let cpaasMode = PrefsUtil.getCpaasMode()
-        let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
-        navigationController?.setNavigationBarHidden(!isBurger, animated: false)
+        navigationController?.setNavigationBarHidden(true, animated: false)
         
         let tapGesture = UITapGestureRecognizer(target: self, action: #selector(collapseDocked))
         tapGesture.cancelsTouchesInView = false

+ 2 - 8
appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift

@@ -144,7 +144,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
                     myURL = URL(string: address)
                 }
                 else {
-                    if ViewController.sURL.contains("nexilis/pages"){
+                    if ViewController.tab3.contains("nexilis/pages"){
                         address = "\(PrefsUtil.getURLBase())\(ViewController.tab3)?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
                     } else {
                         address = "https://\(ViewController.tab3)"
@@ -166,13 +166,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             dateRefresh = Date()
             ThirdTabViewController.forceRefresh = false
         }
-        let cpaasMode = PrefsUtil.getCpaasMode()
-        let isBurger = cpaasMode == PrefsUtil.CPAAS_MODE_BURGER
-        navigationController?.setNavigationBarHidden(!isBurger, animated: false)
-        if isBurger {
-            self.navigationController?.navigationBar.topItem?.title = Bundle.main.displayName
-            self.navigationController?.navigationBar.setNeedsLayout()
-        }
+        navigationController?.setNavigationBarHidden(true, animated: false)
     }
     
     func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

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

@@ -164,44 +164,6 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 }
             }
         }
-        if(cpaasMode == PrefsUtil.CPAAS_MODE_BURGER){
-            navigationController?.setNavigationBarHidden(false, animated: false)
-            //print("cpaas mode burger")
-            let childrenMenu : [UIAction] = [
-                UIAction(title: "Contact Center", handler: {[weak self](_) in
-                    self?.ccTap()
-                }),
-                UIAction(title: "Chat", handler: {[weak self](_) in
-                    self?.chatTap()
-                }),
-                UIAction(title: "Call", handler: {[weak self](_) in
-                    self?.callTap()
-                }),
-                UIAction(title: "New Post", handler: {[weak self](_) in
-                    self?.postTap()
-                }),
-                UIAction(title: "Live Streaming", handler: {[weak self](_) in
-                    self?.streamTap()
-                }),
-//                UIAction(title: "Settings", handler: {[weak self](_) in
-//                    self?.settingTap()
-//                }),
-            ]
-            let menu = UIMenu(title: "", children: childrenMenu)
-            if !PrefsUtil.getIconDock().isEmpty {
-                DispatchQueue.global().async {
-                    ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
-                        guard let data = data, error == nil else { return }
-                        // always update the UI from the main thread
-                        DispatchQueue.main.async() { [self] in
-                            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
-                        }
-                    }
-                }
-            } else {
-                navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
-            }
-        }
         if((cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)){
             createMidFloatingButton()
             navigationController?.setNavigationBarHidden(true, animated: false)
@@ -585,48 +547,6 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 }
             }
         }
-        let cpaasMode = PrefsUtil.getCpaasMode()
-        var childrenMenu = [UIAction]()
-        if(cpaasMode == PrefsUtil.CPAAS_MODE_BURGER){
-            //print("cpaas mode burger")
-            childrenMenu.append(contentsOf: [
-                UIAction(title: "Contact Center", handler: {[weak self](_) in
-                    self?.ccTap()
-                }),
-                UIAction(title: "Chat", handler: {[weak self](_) in
-                    self?.chatTap()
-                }),
-                UIAction(title: "Call", handler: {[weak self](_) in
-                    self?.callTap()
-                }),
-                UIAction(title: "New Post", handler: {[weak self](_) in
-                    self?.postTap()
-                }),
-                UIAction(title: "Live Streaming", handler: {[weak self](_) in
-                    self?.streamTap()
-                }),
-//                UIAction(title: "Settings", handler: {[weak self](_) in
-//                    self?.settingTap()
-//                }),
-            ])
-            if let vc = viewController as? SecondTabViewController {
-                childrenMenu.append(contentsOf: vc.childrenMenu)
-            }
-            let menu = UIMenu(title: "", children: childrenMenu)
-            if !PrefsUtil.getIconDock().isEmpty {
-                DispatchQueue.global().async {
-                    ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
-                        guard let data = data, error == nil else { return }
-                        // always update the UI from the main thread
-                        DispatchQueue.main.async() { [self] in
-                            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
-                        }
-                    }
-                }
-            } else {
-                navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
-            }
-        }
     }
     
     override func viewWillAppear(_ animated: Bool) {

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

@@ -125,7 +125,7 @@ public final class Utils {
         UserDefaults.standard.set(value, forKey: "app_builder_custom_buttons")
     }
     
-    static func getCustomButtons() -> String {
+    public static func getCustomButtons() -> String {
         UserDefaults.standard.string(forKey: "app_builder_custom_buttons") ?? ""
     }