فهرست منبع

update Super App

alqindiirsyam 1 سال پیش
والد
کامیت
379b0a9ae8

+ 132 - 24
appbuilder-ios/AppBuilder/AppBuilder/FourthTabViewController.swift

@@ -21,11 +21,16 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     var switchSaveToGallery = UISwitch()
     var switchAutoDownload = UISwitch()
     
-    let separatorLogout = UIView()
+    let separatorBackupRestore = UIView()
     let separatorNotifPersonal = UIView()
     let separatorAutoDownload = UIView()
     let separatorVersion = UIView()
     let separatorLogin = UIView()
+    let separatorCFBTop = UIView()
+    let separatorCFBBot = UIView()
+    let separatorCYATop = UIView()
+    let separatorCYABot = UIView()
+    let separatorBCABot = UIView()
     
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var backgroundImage: UIImageView!
@@ -85,11 +90,16 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     }
 
     public override func viewWillDisappear(_ animated: Bool) {
-        separatorLogout.removeFromSuperview()
+        separatorBackupRestore.removeFromSuperview()
         separatorNotifPersonal.removeFromSuperview()
         separatorAutoDownload.removeFromSuperview()
         separatorVersion.removeFromSuperview()
         separatorLogin.removeFromSuperview()
+        separatorCFBTop.removeFromSuperview()
+        separatorCFBBot.removeFromSuperview()
+        separatorCYATop.removeFromSuperview()
+        separatorCYABot.removeFromSuperview()
+        separatorBCABot.removeFromSuperview()
         if ViewController.isExpandButton {
             ViewController.expandButton()
         }
@@ -176,18 +186,11 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
                         Item(icon: UIImage(systemName: "person.badge.key"), title: "Access Admin / Internal Features".localized()),
                     ]
                 }
-                if Nexilis.showButtonFB {
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized()))
-                }
                 if !isChangeProfile {
                     Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
                 } else if isChangeProfile {
                     Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.clockwise.icloud"), title: "Backup & Restore".localized()))
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()))
-                    if Utils.getEnableMobileBuilder() == "1" {
-                        Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "iphone"), title: "Create Your Own App".localized()))
-                    }
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"), title: "Sign-Out".localized()))
+                    Item.menus["Personal"]?.insert(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()), at: 1)
                 }
                 let image = cursorUser.string(forColumnIndex: 1)
                 if image != nil {
@@ -265,6 +268,28 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             }
         })
         
+        Item.menus["Config"] = [
+            Item(icon: UIImage(systemName: "iphone"), title: "Create Your Own App".localized()),
+            Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized())
+        ]
+        if !isChangeProfile || Utils.getEnableMobileBuilder() != "1" {
+            if Item.menus["Config"]!.count > 1 {
+                Item.menus["Config"]!.remove(at: 0)
+            } else {
+                Item.menus["Config"]!.removeAll()
+            }
+        }
+        if !Nexilis.showButtonFB {
+            if Item.menus["Config"]!.count > 1 {
+                Item.menus["Config"]!.remove(at: 1)
+            } else {
+                Item.menus["Config"]!.removeAll()
+            }
+        }
+        if Utils.getIsLoadThemeFromOther() {
+            Item.menus["Config"]?.insert(Item(icon: UIImage(systemName: "iphone"), title: "Back to Company App".localized()), at: 1)
+        }
+        
         Item.menus["Call"] = [
             Item(icon: UIImage(systemName: "message"), title: "Notification Message(s)".localized()),
             Item(icon: UIImage(systemName: "message"), title: "Notification Message(s) Group".localized()),
@@ -276,6 +301,9 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             Item(icon: UIImage(systemName: "gear"), title: "Version".localized()),
             Item(icon: UIImage(named: "pb_powered_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), title: "Powered by Nexilis".localized()),
         ]
+        if isChangeProfile {
+            Item.menus["Version"]?.insert(Item(icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"), title: "Sign-Out".localized()), at: 0)
+        }
     }
     
     override public func viewWillAppear(_ animated: Bool) {
@@ -352,11 +380,6 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
         let isChangeProfile = Utils.getSetProfile()
-        if !isChangeProfile {
-            separatorLogout.removeFromSuperview()
-        } else {
-            separatorLogin.removeFromSuperview()
-        }
         cell.accessoryType = .none
         cell.indentationLevel = 0
         var content = cell.defaultContentConfiguration()
@@ -385,16 +408,35 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
                 cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorLogin)
             case "Configure Floating Button".localized():
                 cell.accessoryType = .disclosureIndicator
+                if !isChangeProfile || Utils.getEnableMobileBuilder() != "1" {
+                    separatorCFBTop.removeFromSuperview()
+                    cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCFBTop)
+                }
+                separatorCFBBot.removeFromSuperview()
+                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCFBBot)
             case "Notification Message(s)".localized():
                 cell.accessoryType = .disclosureIndicator
                 separatorNotifPersonal.removeFromSuperview()
                 cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorNotifPersonal)
             case "Backup & Restore".localized():
                 cell.accessoryType = .disclosureIndicator
+                separatorBackupRestore.removeFromSuperview()
+                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorBackupRestore)
             case "Validation Transaction Limit".localized():
                 cell.accessoryType = .disclosureIndicator
             case "Create Your Own App".localized():
                 cell.accessoryType = .disclosureIndicator
+                separatorCYATop.removeFromSuperview()
+                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCYATop)
+                if !Nexilis.showButtonFB && !Utils.getIsLoadThemeFromOther() {
+                    separatorCYABot.removeFromSuperview()
+                    cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCYABot)
+                }
+            case "Back to Company App".localized():
+                if !Nexilis.showButtonFB {
+                    separatorBCABot.removeFromSuperview()
+                    cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorBCABot)
+                }
             case "Notification Message(s) Group".localized():
                 cell.accessoryType = .disclosureIndicator
 //            case "Logout".localized():
@@ -415,8 +457,10 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
                 accessoryButton.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
                 accessoryButton.contentMode = .scaleAspectFit
                 cell.accessoryView = accessoryButton as UIView
-                separatorVersion.removeFromSuperview()
-                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
+                if !isChangeProfile {
+                    separatorVersion.removeFromSuperview()
+                    cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
+                }
             case "Vibrate Mode".localized():
                 cell.accessoryView = switchVibrateMode
             case "Save to Gallery".localized():
@@ -426,8 +470,8 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
                 separatorAutoDownload.removeFromSuperview()
                 cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorAutoDownload)
             case "Sign-Out".localized():
-                separatorLogout.removeFromSuperview()
-                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorLogout)
+                separatorVersion.removeFromSuperview()
+                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
             default:
                 content.secondaryText = nil
             }
@@ -581,11 +625,13 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
                                     imageView.tintColor = .white
                                     let banner = FloatingNotificationBanner(title: "Successfully Sign-Out".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
                                     banner.show()
-                                    if Nexilis.showFB {
+                                    if viewController is UINavigationController {
+                                        viewController = (viewController as! UINavigationController).viewControllers[0]
+                                    }
+                                    if Nexilis.showFB && viewController is ViewController{
                                         Nexilis.floatingButton.removeFromSuperview()
                                         Nexilis.floatingButton = FloatingButton()
-                                        let viewController = (UIApplication.shared.windows.first?.rootViewController)!
-                                        Nexilis.addFB(viewController: viewController, fromMAB: true)
+                                        Nexilis.addFB(viewController: viewController!, fromMAB: true)
                                     }
                                     var dataImage: [AnyHashable : Any] = [:]
                                     dataImage["name"] = ""
@@ -707,10 +753,72 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         } else if item.title == "Validation Transaction Limit".localized() {
             let controller = ValidationTransactionLimit()
             navigationController?.show(controller, sender: nil)
-        }  else if item.title == "Create Your Own App".localized() {
+        } else if item.title == "Create Your Own App".localized() {
             let controller = BNIBookingWebView()
             controller.customUrl = PrefsUtil.getURLBase() + "mobile_MAB?f_pin="
             self.present(controller, animated: true)
+        } else if item.title == "Back to Company App".localized() {
+            let alert = LibAlertController(title: "", message: "Are you sure want to back to company app?".localized(), preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: "Cancel".localized(), style: UIAlertAction.Style.default, handler: nil))
+            alert.addAction(UIAlertAction(title: "Yes".localized(), style: .destructive, handler: {(_) in
+                if !CheckConnection.isConnectedToNetwork()  || API.nGetCLXConnState() == 0 {
+                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                    imageView.tintColor = .white
+                    let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                    banner.show()
+                    return
+                }
+                Nexilis.showLoader()
+                DispatchQueue.global().async {
+                    if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.backToSuperApp(), timeout: 30 * 1000) {
+                        DispatchQueue.main.async {
+                            if response.isOk() {
+                                Utils.setMyTheme(value: "")
+                                Utils.setIsLoadThemeFromOther(value: false)
+                                Utils.resetValueSuperApp()
+                                Utils.setValueInitialApp(data: Utils.getPrefTheme())
+                                Database.shared.database?.inTransaction({ fmdb, rollback in
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "GROUPZ", _where: "")
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "GROUPZ_MEMBER", _where: "")
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "DISCUSSION_FORUM", _where: "")
+                                    _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: User.getMyPin() ?? ""))
+                                })
+                                Nexilis.hideLoader {
+                                    let alert = LibAlertController(title: "Successfully changed".localized(), message: "Please open the app again to see the changes".localized(), preferredStyle: .alert)
+                                    alert.addAction(UIAlertAction(title: "OK".localized(), style: .default, handler: {(_) in
+                                        exit(0)
+                                    }))
+                                    self.present(alert, animated: true, completion: nil)
+                                }
+                            } else if response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "10" {
+                                Nexilis.hideLoader(completion: {
+                                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                    imageView.tintColor = .white
+                                    let banner = FloatingNotificationBanner(title: "Failed to back to Company App".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                    banner.show()
+                                })
+                            } else {
+                                Nexilis.hideLoader(completion: {
+                                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                    imageView.tintColor = .white
+                                    let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                    banner.show()
+                                })
+                            }
+                        }
+                    } else {
+                        DispatchQueue.main.async {
+                            Nexilis.hideLoader(completion: {
+                                let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                imageView.tintColor = .white
+                                let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                banner.show()
+                            })
+                        }
+                    }
+                }
+            }))
+            self.present(alert, animated: true, completion: nil)
         }
     }
     
@@ -1052,7 +1160,7 @@ struct Item: Hashable {
     var title = ""
     
     static var sections: [String] {
-        return ["Personal", "Call", "Version"]
+        return ["Personal", "Config", "Call", "Version"]
     }
     
     static var menus: [String: [Item]] = [:]

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

@@ -496,6 +496,7 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         tabBarController?.navigationItem.searchController = nil
         tabBarController?.navigationItem.rightBarButtonItem = nil
         tabBarController?.navigationItem.rightBarButtonItems = nil
+        tabBarController?.navigationItem.titleView = nil
         Utils.inTabChats = false
         if ViewController.isExpandButton {
             ViewController.expandButton()

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

@@ -118,6 +118,52 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             }
             i += 1
         }
+        DispatchQueue.global().async {
+            if !Utils.getTab1Icon().isEmpty {
+                ViewController.getDataImageFromUrl(from: URL(string: "\(PrefsUtil.getURLBase())get_file_from_path?img=\(Utils.getTab1Icon())")!) { 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
+                        tabs[0].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                    }
+                }
+            }
+            if !Utils.getTab2Icon().isEmpty {
+                ViewController.getDataImageFromUrl(from: URL(string: "\(PrefsUtil.getURLBase())get_file_from_path?img=\(Utils.getTab2Icon())")!) { 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
+                        tabs[1].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                    }
+                }
+            }
+            if !Utils.getTab3Icon().isEmpty {
+                ViewController.getDataImageFromUrl(from: URL(string: "\(PrefsUtil.getURLBase())get_file_from_path?img=\(Utils.getTab3Icon())")!) { 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
+                        if cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX {
+                            tabs[3].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                        } else {
+                            tabs[2].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                        }
+                    }
+                }
+            }
+            if !Utils.getTab4Icon().isEmpty {
+                ViewController.getDataImageFromUrl(from: URL(string: "\(PrefsUtil.getURLBase())get_file_from_path?img=\(Utils.getTab4Icon())")!) { 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
+                        if cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX {
+                            tabs[4].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                        } else {
+                            tabs[3].tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal))
+                        }
+                    }
+                }
+            }
+        }
         if(cpaasMode == PrefsUtil.CPAAS_MODE_BURGER){
             navigationController?.setNavigationBarHidden(false, animated: false)
             //print("cpaas mode burger")

+ 3 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/id.lproj/Localizable.strings

@@ -357,3 +357,6 @@
 "Expired Code" = "Kode telah kadaluarsa";
 "You have been blocked" = "Anda telah di blokir";
 "Please open the app again to see the changes" = "Tolong buka aplikasi kembali untuk melihat perubahan";
+"Back to Company App" = "Kembali ke Aplikasi Awal";
+"Are you sure want to back to company app?" = "Apakah kamu yakin ingin kembali ke aplikasi awal?";
+"Failed to back to Company App" = "Gagal kembali ke Aplikasi Awal";

+ 8 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/CoreMessage_TMessageBank.swift

@@ -2486,4 +2486,12 @@ public class CoreMessage_TMessageBank {
         return tmessage
     }
     
+    public static func backToSuperApp() -> TMessage {
+        let tmessage = TMessage()
+        tmessage.mCode = CoreMessage_TMessageCode.RESET_SUPER_APP
+        tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tmessage.mPIN = User.getMyPin() ?? ""
+        return tmessage
+    }
+    
 }

+ 2 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/CoreMessage_TMessageCode.swift

@@ -778,4 +778,6 @@ public class CoreMessage_TMessageCode {
 
     public static let SHIELD_SECURITY_VALIDATE_TOKEN = "SSVT";
     public static let BLOCK_ACCESS = "BLK";
+    
+    public static let RESET_SUPER_APP = "RSA";
 }

+ 0 - 7
appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -415,13 +415,7 @@ public class FloatingButton: UIView {
                                 }
                             }
                         }
-                    } else {
-                        groupView.subviews.forEach({ $0.removeFromSuperview() })
-                        getDefaultButton()
                     }
-                } else {
-                    groupView.subviews.forEach({ $0.removeFromSuperview() })
-                    getDefaultButton()
                 }
             }
         }
@@ -594,7 +588,6 @@ public class FloatingButton: UIView {
     }
     
     @objc func fbTap(_ sender: UIButton) {
-        print("LOHE")
         let package_id = sender.restorationIdentifier!
         var app_id = sender.accessibilityIdentifier!
         var indexTap = 0

+ 2 - 85
appbuilder-ios/NexilisLite/NexilisLite/Source/IncomingThread.swift

@@ -320,92 +320,9 @@ class IncomingThread {
         let data = message.getBody(key: CoreMessage_TMessageKey.DATA)
         if !data.isEmpty && !Utils.getIsLoadThemeFromOther() {
             Utils.setPrefTheme(value: data)
-            if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
-                for json in jsonArray {
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_first_tab" {
-                        Utils.setURLFirstTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_third_tab" {
-                        Utils.setURLThirdTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_tab" {
-                        Utils.setCustomTab(cust: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_base" {
-                        Utils.setURLBase(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_qms" {
-                        Utils.setURLQMS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_dock" {
-                        Utils.setIconDock(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_ss" {
-                        Utils.setIconSS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background" {
-                        Utils.setBackground(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_privacy_policy" {
-                        Utils.setURLPrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_privacy_policy" {
-                        Utils.setEnablePrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String == "1" ? true : false)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "pb_fb_icon_center_self_mode2" {
-                        Utils.setIconCenterAnim2(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "pb_fb_icon_center_self_mode4" {
-                        Utils.setIconCenterAnim4(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_ac_theme" {
-                        Utils.setACTheme(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_url" {
-                        Utils.setButtonURL(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_buttons" {
-                        Utils.setCustomButtons(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
-                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
-                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_config_mode" {
-                        Utils.setConfigModeFB(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_icon" {
-                        Utils.setCustomFBIcon(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_floating_anim" {
-                        Utils.setFloatingAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_with_bg" {
-                        Utils.setFBIconBg(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_item_with_bg" {
-                        Utils.setFBItemBg(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "user_agent" {
-                        Utils.setUserAgent(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background_light" {
-                        Utils.setBackgroundLight(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background_dark" {
-                        Utils.setBackgroundDark(value: json[CoreMessage_TMessageKey.VALUE] as! String)
-                    }
-                    //print("PrefsInit : \(json)")
-                }
-                Utils.setFinishInitPrefs(value: true)
-            } else {
-                Utils.setFinishInitPrefs(value: true)
-            }
-        } else {
-            Utils.setFinishInitPrefs(value: true)
+            Utils.setValueInitialApp(data: data)
         }
+        Utils.setFinishInitPrefs(value: true)
         ack(message: message)
     }
     

+ 117 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Utils.swift

@@ -390,6 +390,123 @@ public final class Utils {
         task.resume()
     }
     
+    public static func resetValueSuperApp() {
+        Utils.setURLFirstTab(value: "")
+        Utils.setURLThirdTab(value: "")
+        Utils.setURLWv3(value: "")
+        Utils.setURLWv4(value: "")
+        Utils.setURLWv5(value: "")
+        Utils.setURLWv6(value: "")
+        Utils.setCustomTab(cust: "")
+        Utils.setIconDock(value: "")
+        Utils.setBackground(value: "")
+        Utils.setBackgroundLight(value: "")
+        Utils.setBackgroundDark(value: "")
+        Utils.setBackgroundTab1(value: "")
+        Utils.setBackgroundTab2(value: "")
+        Utils.setBackgroundTab3(value: "")
+        Utils.setBackgroundTab4(value: "")
+        Utils.setBackgroundTab5(value: "")
+        Utils.setBackgroundTab6(value: "")
+        Utils.setCpaasMode(mode: 0)
+        Utils.setCustomButtons(value: "")
+        Utils.setIconDock(value: "")
+        Utils.setTab1Icon(value: "")
+        Utils.setTab2Icon(value: "")
+        Utils.setTab3Icon(value: "")
+        Utils.setTab4Icon(value: "")
+        Utils.setTab5Icon(value: "")
+        Utils.setTab6Icon(value: "")
+        Utils.setButtonIcon(value: "")
+        Utils.setReverseTab(value: "")
+        Utils.setIconDockSize(value: "")
+    }
+    
+    public static func setValueInitialApp(data: String) {
+        if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
+            do {
+                for json in jsonArray {
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_first_tab" {
+                        Utils.setURLFirstTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_third_tab" {
+                        Utils.setURLThirdTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_tab" {
+                        Utils.setCustomTab(cust: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_base" {
+                        Utils.setURLBase(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_qms" {
+                        Utils.setURLQMS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_dock" {
+                        Utils.setIconDock(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_ss" {
+                        Utils.setIconSS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background" {
+                        Utils.setBackground(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_privacy_policy" {
+                        Utils.setURLPrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_privacy_policy" {
+                        Utils.setEnablePrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String == "1" ? true : false)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "pb_fb_icon_center_self_mode2" {
+                        Utils.setIconCenterAnim2(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "pb_fb_icon_center_self_mode4" {
+                        Utils.setIconCenterAnim4(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_ac_theme" {
+                        Utils.setACTheme(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_url" {
+                        Utils.setButtonURL(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_buttons" {
+                        Utils.setCustomButtons(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_config_mode" {
+                        Utils.setConfigModeFB(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_icon" {
+                        Utils.setCustomFBIcon(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_floating_anim" {
+                        Utils.setFloatingAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_with_bg" {
+                        Utils.setFBIconBg(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_item_with_bg" {
+                        Utils.setFBItemBg(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "user_agent" {
+                        Utils.setUserAgent(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background_light" {
+                        Utils.setBackgroundLight(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background_dark" {
+                        Utils.setBackgroundDark(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                }
+            } catch {
+            }
+        }
+    }
+    
     public static var inTabChats = false
     
     public static var longitude = ""

+ 1 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/BNIView/BNIBookingWebView.swift

@@ -271,6 +271,7 @@ public class BNIBookingWebView: UIViewController, WKNavigationDelegate, UIScroll
             }
             Utils.setMyTheme(value: param1)
             Utils.setIsLoadThemeFromOther(value: true)
+            Utils.resetValueSuperApp()
             if let jsonArray = try! JSONSerialization.jsonObject(with: param1.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
                 do {
                     for json in jsonArray {

+ 176 - 78
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/SettingTableViewController.swift

@@ -20,17 +20,25 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
     var switchSaveToGallery = UISwitch()
     var switchAutoDownload = UISwitch()
     
-    let separatorLogout = UIView()
+    let separatorBackupRestore = UIView()
     let separatorNotifPersonal = UIView()
     let separatorAutoDownload = UIView()
     let separatorVersion = UIView()
     let separatorLogin = UIView()
+    let separatorCFBTop = UIView()
+    let separatorCFBBot = UIView()
+    let separatorCYATop = UIView()
+    let separatorCYABot = UIView()
+    let separatorBCABot = UIView()
     
     var notInTab = false
     
     public override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
+        self.navigationController?.navigationBar.topItem?.backButtonTitle = ""
+        
         tableView.delegate = self
         tableView.dataSource = self
         tableView.layoutMargins = .init(top: 0, left: 0, bottom: 0, right: 0)
@@ -58,8 +66,19 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
         switchVibrateMode.addTarget(self, action: #selector(vibrateModeSwitch), for: .valueChanged)
         switchSaveToGallery.addTarget(self, action: #selector(saveToGallerySwitch), for: .valueChanged)
         switchAutoDownload.addTarget(self, action: #selector(autoDownloadSwitch), for: .valueChanged)
-        
-//        navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(didTapCancel))
+    }
+
+    public override func viewWillDisappear(_ animated: Bool) {
+        separatorBackupRestore.removeFromSuperview()
+        separatorNotifPersonal.removeFromSuperview()
+        separatorAutoDownload.removeFromSuperview()
+        separatorVersion.removeFromSuperview()
+        separatorLogin.removeFromSuperview()
+        separatorCFBTop.removeFromSuperview()
+        separatorCFBBot.removeFromSuperview()
+        separatorCYATop.removeFromSuperview()
+        separatorCYABot.removeFromSuperview()
+        separatorBCABot.removeFromSuperview()
     }
     
     public override func viewDidAppear(_ animated: Bool) {
@@ -96,17 +115,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
         Database.shared.database?.inTransaction({ fmdb, rollback in
             let idMe = UserDefaults.standard.string(forKey: "me") as String?
             if let cursorUser = Database.shared.getRecords(fmdb: fmdb, query: "SELECT user_type, image_id, official_account FROM BUDDY where f_pin='\(idMe!)'"), cursorUser.next() {
-                var groupId = ""
-                if let cursorGroup = Database.shared.getRecords(fmdb: fmdb, query: "SELECT group_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorGroup.next() {
-                    groupId = cursorGroup.string(forColumnIndex: 0) ?? ""
-                    cursorGroup.close()
-                }
-                var position = ""
-                if let cursorIsAdmin = Database.shared.getRecords(fmdb: fmdb, query: "SELECT position FROM GROUPZ_MEMBER where group_id = '\(groupId)' AND f_pin = '\(idMe!)'"), cursorIsAdmin.next() {
-                    position = cursorIsAdmin.string(forColumnIndex: 0) ?? ""
-                    cursorIsAdmin.close()
-                }
-                if ( User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") && position == "1") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") {
+                if (User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") && User.isAdmin(fmdb: fmdb)) || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") {
                     Item.menus["Personal"] = [
                         Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
                         Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
@@ -128,18 +137,11 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                         Item(icon: UIImage(systemName: "person.badge.key"), title: "Access Admin / Internal Features".localized()),
                     ]
                 }
-                if Nexilis.showButtonFB {
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized()))
-                }
                 if !isChangeProfile {
                     Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
                 } else if isChangeProfile {
                     Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.clockwise.icloud"), title: "Backup & Restore".localized()))
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()))
-                    if Utils.getEnableMobileBuilder() == "1" {
-                        Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "iphone"), title: "Create Your Own App".localized()))
-                    }
-                    Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"), title: "Sign-Out".localized()))
+                    Item.menus["Personal"]?.insert(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()), at: 1)
                 }
                 let image = cursorUser.string(forColumnIndex: 1)
                 if image != nil {
@@ -156,7 +158,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
                                 }
                             } else {
-                                Download().startHTTP(forKey: image!) { (name, progress) in
+                                Download().start(forKey: image!) { (name, progress) in
                                     guard progress == 100 else {
                                         return
                                     }
@@ -198,7 +200,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                             dataImage["name"] = imageSignIn
                             NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
                         } else {
-                            Download().startHTTP(forKey: imageSignIn) { (name, progress) in
+                            Download().start(forKey: imageSignIn) { (name, progress) in
                                 guard progress == 100 else {
                                     return
                                 }
@@ -217,6 +219,28 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             }
         })
         
+        Item.menus["Config"] = [
+            Item(icon: UIImage(systemName: "iphone"), title: "Create Your Own App".localized()),
+            Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized())
+        ]
+        if !isChangeProfile || Utils.getEnableMobileBuilder() != "1" {
+            if Item.menus["Config"]!.count > 1 {
+                Item.menus["Config"]!.remove(at: 0)
+            } else {
+                Item.menus["Config"]!.removeAll()
+            }
+        }
+        if !Nexilis.showButtonFB {
+            if Item.menus["Config"]!.count > 1 {
+                Item.menus["Config"]!.remove(at: 1)
+            } else {
+                Item.menus["Config"]!.removeAll()
+            }
+        }
+        if Utils.getIsLoadThemeFromOther() {
+            Item.menus["Config"]?.insert(Item(icon: UIImage(systemName: "iphone"), title: "Back to Company App".localized()), at: 1)
+        }
+        
         Item.menus["Call"] = [
             Item(icon: UIImage(systemName: "message"), title: "Notification Message(s)".localized()),
             Item(icon: UIImage(systemName: "message"), title: "Notification Message(s) Group".localized()),
@@ -228,44 +252,37 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             Item(icon: UIImage(systemName: "gear"), title: "Version".localized()),
             Item(icon: UIImage(named: "pb_powered_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), title: "Powered by Nexilis".localized()),
         ]
+        if isChangeProfile {
+            Item.menus["Version"]?.insert(Item(icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"), title: "Sign-Out".localized()), at: 0)
+        }
     }
     
     override public func viewWillAppear(_ animated: Bool) {
 //        self.navigationController?.navigationBar.topItem?.title = ""
-//        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
-//        let navBarAppearance = UINavigationBarAppearance()
-//        navBarAppearance.configureWithTransparentBackground()
-//        navigationController?.navigationBar.standardAppearance = navBarAppearance
-//        navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
-//        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.black]
-//        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
-//        navigationController?.navigationBar.backgroundColor = .clear
-//        navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
-//        navigationController?.navigationBar.shadowImage = UIImage()
-//        navigationController?.navigationBar.isTranslucent = true
-//        navigationController?.setNavigationBarHidden(false, animated: false)
-//        navigationController?.navigationBar.overrideUserInterfaceStyle = .light
-//        navigationController?.navigationBar.barStyle = .default
-//        navigationController?.navigationBar.tintColor = .black
-//        tabBarController?.navigationItem.leftBarButtonItem = nil
-//        tabBarController?.navigationItem.searchController = nil
-//        tabBarController?.navigationItem.rightBarButtonItem = nil
-        let imageButton = UIImageView(frame: CGRect(x: -16, y: 0, width: 20, height: 44))
-        imageButton.image = UIImage(systemName: "chevron.backward", withConfiguration: UIImage.SymbolConfiguration(pointSize: 20, weight: .regular, scale: .default))?.withTintColor(.white)
-        imageButton.contentMode = .left
-        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapExit))
-        imageButton.isUserInteractionEnabled = true
-        imageButton.addGestureRecognizer(tapGestureRecognizer)
-        let leftItem = UIBarButtonItem(customView: imageButton)
-        self.navigationItem.leftBarButtonItem = leftItem
+        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black]
+        let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black, NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 16)]
+        let navBarAppearance = UINavigationBarAppearance()
+        navBarAppearance.configureWithTransparentBackground()
+        navBarAppearance.titleTextAttributes = attributes
+        navigationController?.navigationBar.standardAppearance = navBarAppearance
+        navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
+        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
+        navigationController?.navigationBar.backgroundColor = .clear
+        navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
+        navigationController?.navigationBar.shadowImage = UIImage()
+        navigationController?.navigationBar.isTranslucent = true
+        navigationController?.setNavigationBarHidden(false, animated: false)
+        navigationController?.navigationBar.overrideUserInterfaceStyle = self.traitCollection.userInterfaceStyle == .dark ? .dark : .light
+        navigationController?.navigationBar.barStyle = .default
+        navigationController?.navigationBar.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
+        tabBarController?.navigationItem.leftBarButtonItem = nil
+        tabBarController?.navigationItem.searchController = nil
+        tabBarController?.navigationItem.rightBarButtonItem = nil
         makeMenu()
         tableView.reloadData()
     }
     
-    @objc func didTapExit() {
-        self.dismiss(animated: true, completion: nil)
-    }
-    
     // MARK: - Table view data source
     
     public override func numberOfSections(in tableView: UITableView) -> Int {
@@ -283,11 +300,6 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
     public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
         let isChangeProfile = Utils.getSetProfile()
-        if !isChangeProfile {
-            separatorLogout.removeFromSuperview()
-        } else {
-            separatorLogin.removeFromSuperview()
-        }
         cell.accessoryType = .none
         cell.indentationLevel = 0
         var content = cell.defaultContentConfiguration()
@@ -299,7 +311,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
         if let arr = Item.menus[section] {
             let menu = arr[indexPath.row]
             content.image = menu.icon
-            content.imageProperties.tintColor = .black
+            content.imageProperties.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
             content.imageProperties.maximumSize = CGSize(width: 24, height: 24)
             content.text = menu.title
             cell.accessoryView = nil
@@ -316,21 +328,40 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                 cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorLogin)
             case "Configure Floating Button".localized():
                 cell.accessoryType = .disclosureIndicator
+                if !isChangeProfile || Utils.getEnableMobileBuilder() != "1" {
+                    separatorCFBTop.removeFromSuperview()
+                    cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCFBTop)
+                }
+                separatorCFBBot.removeFromSuperview()
+                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCFBBot)
             case "Notification Message(s)".localized():
                 cell.accessoryType = .disclosureIndicator
                 separatorNotifPersonal.removeFromSuperview()
                 cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorNotifPersonal)
             case "Backup & Restore".localized():
                 cell.accessoryType = .disclosureIndicator
+                separatorBackupRestore.removeFromSuperview()
+                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorBackupRestore)
+            case "Validation Transaction Limit".localized():
+                cell.accessoryType = .disclosureIndicator
+            case "Create Your Own App".localized():
+                cell.accessoryType = .disclosureIndicator
+                separatorCYATop.removeFromSuperview()
+                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCYATop)
+                if !Nexilis.showButtonFB {
+                    separatorCYABot.removeFromSuperview()
+                    cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorCYABot)
+                }
+            case "Back to Company App".localized():
+                if !Nexilis.showButtonFB {
+                    separatorBCABot.removeFromSuperview()
+                    cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorBCABot)
+                }
             case "Notification Message(s) Group".localized():
                 cell.accessoryType = .disclosureIndicator
 //            case "Logout".localized():
             case "Change Admin / Internal Password".localized():
                 cell.accessoryType = .disclosureIndicator
-            case "Validation Transaction Limit".localized():
-                cell.accessoryType = .disclosureIndicator
-            case "Create Your Own App".localized():
-                cell.accessoryType = .disclosureIndicator
             case "Change Language".localized():
                 cell.accessoryType = .disclosureIndicator
             case "Set Internal Account".localized():
@@ -340,13 +371,16 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             case "Version".localized():
                 let accessoryButton = UIButton(type: .custom)
                 accessoryButton.setTitle(UIApplication.appVersion, for: .normal)
-                accessoryButton.setTitleColor(.black, for: .normal)
-                accessoryButton.contentHorizontalAlignment = .right;
+                accessoryButton.setTitleColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .black, for: .normal)
+                accessoryButton.titleLabel?.font = .systemFont(ofSize: 18)
+                accessoryButton.contentHorizontalAlignment = .right
                 accessoryButton.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
                 accessoryButton.contentMode = .scaleAspectFit
                 cell.accessoryView = accessoryButton as UIView
-                separatorVersion.removeFromSuperview()
-                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
+                if !isChangeProfile {
+                    separatorVersion.removeFromSuperview()
+                    cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
+                }
             case "Vibrate Mode".localized():
                 cell.accessoryView = switchVibrateMode
             case "Save to Gallery".localized():
@@ -356,8 +390,8 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                 separatorAutoDownload.removeFromSuperview()
                 cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorAutoDownload)
             case "Sign-Out".localized():
-                separatorLogout.removeFromSuperview()
-                cell.addBottomBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorLogout)
+                separatorVersion.removeFromSuperview()
+                cell.addTopBorder(with: .lightGray.withAlphaComponent(0.5), andWidth: 1, view: separatorVersion)
             default:
                 content.secondaryText = nil
             }
@@ -513,12 +547,14 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
                                 })
                             }
                         } else {
-                            Nexilis.hideLoader(completion: {
-                                let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
-                                imageView.tintColor = .white
-                                let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
-                                banner.show()
-                            })
+                            DispatchQueue.main.async {
+                                Nexilis.hideLoader(completion: {
+                                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                    imageView.tintColor = .white
+                                    let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                    banner.show()
+                                })
+                            }
                         }
                     } else {
                         DispatchQueue.main.async {
@@ -614,10 +650,72 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
         } else if item.title == "Validation Transaction Limit".localized() {
             let controller = ValidationTransactionLimit()
             navigationController?.show(controller, sender: nil)
-        }  else if item.title == "Create Your Own App".localized() {
+        } else if item.title == "Create Your Own App".localized() {
             let controller = BNIBookingWebView()
             controller.customUrl = Utils.getURLBase() + "mobile_MAB?f_pin="
             self.present(controller, animated: true)
+        } else if item.title == "Back to Company App".localized() {
+            let alert = LibAlertController(title: "", message: "Are you sure want to back to company app?".localized(), preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: "Cancel".localized(), style: UIAlertAction.Style.default, handler: nil))
+            alert.addAction(UIAlertAction(title: "Yes".localized(), style: .destructive, handler: {(_) in
+                if !CheckConnection.isConnectedToNetwork()  || API.nGetCLXConnState() == 0 {
+                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                    imageView.tintColor = .white
+                    let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                    banner.show()
+                    return
+                }
+                Nexilis.showLoader()
+                DispatchQueue.global().async {
+                    if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.backToSuperApp(), timeout: 30 * 1000) {
+                        DispatchQueue.main.async {
+                            if response.isOk() {
+                                Utils.setMyTheme(value: "")
+                                Utils.setIsLoadThemeFromOther(value: false)
+                                Utils.resetValueSuperApp()
+                                Utils.setValueInitialApp(data: Utils.getPrefTheme())
+                                Database.shared.database?.inTransaction({ fmdb, rollback in
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "GROUPZ", _where: "")
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "GROUPZ_MEMBER", _where: "")
+                                    _ = Database.shared.deleteRecord(fmdb: fmdb, table: "DISCUSSION_FORUM", _where: "")
+                                    _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: User.getMyPin() ?? ""))
+                                })
+                                Nexilis.hideLoader {
+                                    let alert = LibAlertController(title: "Successfully changed".localized(), message: "Please open the app again to see the changes".localized(), preferredStyle: .alert)
+                                    alert.addAction(UIAlertAction(title: "OK".localized(), style: .default, handler: {(_) in
+                                        exit(0)
+                                    }))
+                                    self.present(alert, animated: true, completion: nil)
+                                }
+                            } else if response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "10" {
+                                Nexilis.hideLoader(completion: {
+                                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                    imageView.tintColor = .white
+                                    let banner = FloatingNotificationBanner(title: "Failed to back to Company App".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                    banner.show()
+                                })
+                            } else {
+                                Nexilis.hideLoader(completion: {
+                                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                    imageView.tintColor = .white
+                                    let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                    banner.show()
+                                })
+                            }
+                        }
+                    } else {
+                        DispatchQueue.main.async {
+                            Nexilis.hideLoader(completion: {
+                                let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                                imageView.tintColor = .white
+                                let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                                banner.show()
+                            })
+                        }
+                    }
+                }
+            }))
+            self.present(alert, animated: true, completion: nil)
         }
     }
     
@@ -959,7 +1057,7 @@ struct Item: Hashable {
     var title = ""
     
     static var sections: [String] {
-        return ["Personal", "Call", "Version"]
+        return ["Personal", "Config", "Call", "Version"]
     }
     
     static var menus: [String: [Item]] = [:]