alqindiirsyam 1 жил өмнө
parent
commit
571464ab59
38 өөрчлөгдсөн 442 нэмэгдсэн , 326 устгасан
  1. 20 20
      appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift
  2. 2 4
      appbuilder-ios/AppBuilder/AppBuilder/Base.lproj/Main.storyboard
  3. 26 8
      appbuilder-ios/AppBuilder/AppBuilder/FirstTabViewController.swift
  4. 17 13
      appbuilder-ios/AppBuilder/AppBuilder/FourthTabViewController.swift
  5. 2 2
      appbuilder-ios/AppBuilder/AppBuilder/Info.plist
  6. 11 2
      appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift
  7. 28 0
      appbuilder-ios/AppBuilder/AppBuilder/SceneDelegate.swift
  8. 30 20
      appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift
  9. 23 7
      appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift
  10. 18 14
      appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift
  11. 7 13
      appbuilder-ios/NexilisLite/NexilisLite/Resource/Palio.storyboard
  12. 4 4
      appbuilder-ios/NexilisLite/NexilisLite/Source/APIS.swift
  13. 7 3
      appbuilder-ios/NexilisLite/NexilisLite/Source/Extension.swift
  14. 2 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift
  15. 6 0
      appbuilder-ios/NexilisLite/NexilisLite/Source/IncomingThread.swift
  16. 141 141
      appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift
  17. 17 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/Utils.swift
  18. 2 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift
  19. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraCallContactViewController.swift
  20. 4 4
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift
  21. 2 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/ChatGPTBotView.swift
  22. 6 6
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift
  23. 17 16
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift
  24. 3 3
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorStarMessages.swift
  25. 2 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/ListGroupImages.swift
  26. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/AddFriendTableViewController.swift
  27. 1 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/BackupRestoreView.swift
  28. 3 3
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/BroadcastViewController.swift
  29. 17 17
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift
  30. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupCreateViewController.swift
  31. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupDescViewController.swift
  32. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupMemberViewController.swift
  33. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupNameViewController.swift
  34. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/GroupTopicViewController.swift
  35. 9 2
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ProfileViewController.swift
  36. 4 4
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/SettingTableViewController.swift
  37. 3 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/SignUpSignIn.swift
  38. 1 1
      appbuilder-ios/NexilisLite/NexilisLite/Source/View/Streaming/SeminarListViewController.swift

+ 20 - 20
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -17,22 +17,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             showButton = true
         }
         Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: showButton, fromMAB: true) //51D0C44F35AD837B27B2970885F9AE731EB1F867F542DDA173AF31497E01037A(CBN Palio Mall) //1C4FA430BC9F44484AFBE99C8974D70B68CE7891DBE83505CBF01205DE51FC18(CBN)
-        let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
-        tabBarAppearance.configureWithTransparentBackground()
-        if Bundle.main.displayName == "DigiNetS" {
-            tabBarAppearance.backgroundColor = .black.withAlphaComponent(0.7)
-        } else {
-            tabBarAppearance.backgroundColor = .white.withAlphaComponent(0.9)
-        }
-        if #available(iOS 13.0, *) {
-            UITabBar.appearance().standardAppearance = tabBarAppearance
-        }
-        if #available(iOS 15.0, *) {
-            UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
-        }
-        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
-        let cancelButtonAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
-        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes , for: .normal)
+//        let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
+//        tabBarAppearance.configureWithTransparentBackground()
+//        if Bundle.main.displayName == "DigiNetS" {
+//            tabBarAppearance.backgroundColor = .black.withAlphaComponent(0.7)
+//        } else {
+//            tabBarAppearance.backgroundColor = .white.withAlphaComponent(0.9)
+//        }
+//        if #available(iOS 13.0, *) {
+//            UITabBar.appearance().standardAppearance = tabBarAppearance
+//        }
+//        if #available(iOS 15.0, *) {
+//            UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
+//        }
+//        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
+//        let cancelButtonAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+//        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes , for: .normal)
         registerForPushNotifications()
         return true
     }
@@ -129,7 +129,7 @@ extension AppDelegate: ConnectDelegate, UNUserNotificationCenterDelegate {
         let navigationController = UINavigationController(rootViewController: editorPersonalVC)
         navigationController.modalPresentationStyle = .fullScreen
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
@@ -137,7 +137,7 @@ extension AppDelegate: ConnectDelegate, UNUserNotificationCenterDelegate {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         if UIApplication.shared.visibleViewController?.navigationController != nil {
             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
         } else {
@@ -153,7 +153,7 @@ extension AppDelegate: ConnectDelegate, UNUserNotificationCenterDelegate {
         let navigationController = UINavigationController(rootViewController: editorGroupVC)
         navigationController.modalPresentationStyle = .fullScreen
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
@@ -161,7 +161,7 @@ extension AppDelegate: ConnectDelegate, UNUserNotificationCenterDelegate {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         if UIApplication.shared.visibleViewController?.navigationController != nil {
             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
         } else {

+ 2 - 4
appbuilder-ios/AppBuilder/AppBuilder/Base.lproj/Main.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nD6-T3-59p">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nD6-T3-59p">
     <device id="retina6_7" orientation="portrait" appearance="dark"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -33,7 +33,6 @@
                         <rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <viewLayoutGuide key="safeArea" id="f2x-TV-t0G"/>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="1UN-B6-dct" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -234,7 +233,6 @@
                         <rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <viewLayoutGuide key="safeArea" id="gQh-2u-SN6"/>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="crD-Us-xmX" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

+ 26 - 8
appbuilder-ios/AppBuilder/AppBuilder/FirstTabViewController.swift

@@ -32,6 +32,9 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
     
     override func viewDidLoad() {
         super.viewDidLoad()
+        
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
+        
         let tapGesture = UITapGestureRecognizer(target: self, action: #selector(collapseDocked))
         tapGesture.cancelsTouchesInView = false
         tapGesture.delegate = self
@@ -79,6 +82,21 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         NotificationCenter.default.addObserver(self, selector: #selector(onRefreshWebView(notification:)), name: NSNotification.Name(rawValue: "onRefreshWebView"), object: nil)
     }
     
+    func loadURLWithCookie(url: URL) {
+        var urlRequest = URLRequest(url: url)
+        let cookieHeader = Utils.getCookiesMobile()
+        urlRequest.addValue(cookieHeader, forHTTPHeaderField: "Cookie")
+        let customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1 \(Utils.getUserAgent())"
+        urlRequest.setValue(customUserAgent, forHTTPHeaderField: "User-Agent")
+        webView.load(urlRequest)
+        
+        if let cookies = HTTPCookieStorage.shared.cookies {
+            for cookie in cookies {
+                webView.configuration.websiteDataStore.httpCookieStore.setCookie(cookie)
+            }
+        }
+    }
+    
     override func viewWillAppear(_ animated: Bool) {
         let me = UserDefaults.standard.string(forKey: "me")
         
@@ -93,19 +111,19 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         }
         switch(ViewController.sURL){
         case "0":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "1":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-main-only?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-main-only?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "2":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "3":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-commerce?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-commerce?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "4":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-video?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-video?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         default:
             if(!ViewController.sURL.isEmpty){
@@ -115,7 +133,7 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
                 }
                 else {
                     if ViewController.sURL.contains("nexilis/pages"){
-                        address = "\(PrefsUtil.getURLBase())\(ViewController.sURL)?f_pin=\(me ?? "")&lang=\(intLang)"
+                        address = "\(PrefsUtil.getURLBase())\(ViewController.sURL)?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
                     } else {
                         address = "https://\(ViewController.sURL)"
                     }
@@ -126,8 +144,8 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         if let u = myURL {
             self.webView.evaluateJavaScript("{window.localStorage.setItem('currentTab','\(ViewController.sURL)')}")
             if ((dateRefresh == nil || Int(Date().timeIntervalSince(dateRefresh!)) >= 60) && FirstTabViewController.atFirstPage) || FirstTabViewController.forceRefresh {
-                let myRequest = URLRequest(url: u)
-                webView.load(myRequest)
+//                let myRequest = URLRequest(url: u)
+                loadURLWithCookie(url: u)
             } else {
                 self.webView.evaluateJavaScript("if(resumeAll){resumeAll();}")
             }

+ 17 - 13
appbuilder-ios/AppBuilder/AppBuilder/FourthTabViewController.swift

@@ -35,6 +35,8 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     public override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
+        
         tableView.delegate = self
         tableView.dataSource = self
         tableView.layoutMargins = .init(top: 0, left: 0, bottom: 0, right: 0)
@@ -273,30 +275,32 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
     
     override public func viewWillAppear(_ animated: Bool) {
         self.navigationController?.navigationBar.topItem?.title = ""
-        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
-        let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 16)]
+        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: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+        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 = .light
+        navigationController?.navigationBar.overrideUserInterfaceStyle = self.traitCollection.userInterfaceStyle == .dark ? .dark : .light
         navigationController?.navigationBar.barStyle = .default
-        navigationController?.navigationBar.tintColor = .black
+        navigationController?.navigationBar.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
         tabBarController?.navigationItem.leftBarButtonItem = nil
         tabBarController?.navigationItem.searchController = nil
         tabBarController?.navigationItem.rightBarButtonItem = nil
-        backgroundImage.backgroundColor = .white
+        backgroundImage.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
         backgroundImage.image = nil
         DispatchQueue.global().async {
-            if let listBg = PrefsUtil.getBackground() {
+            DispatchQueue.main.async {
+                let listBg = PrefsUtil.getBackgroundLight().isEmpty && PrefsUtil.getBackgroundDark().isEmpty ? PrefsUtil.getBackground() :
+                                    self.traitCollection.userInterfaceStyle == .dark ? PrefsUtil.getBackgroundDark() : PrefsUtil.getBackgroundLight()
                 if listBg.isEmpty {
                    return
                 }
@@ -351,7 +355,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         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
@@ -388,7 +392,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             case "Version".localized():
                 let accessoryButton = UIButton(type: .custom)
                 accessoryButton.setTitle(UIApplication.appVersion, for: .normal)
-                accessoryButton.setTitleColor(.black, for: .normal)
+                accessoryButton.setTitleColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .black, for: .normal)
                 accessoryButton.contentHorizontalAlignment = .right;
                 accessoryButton.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
                 accessoryButton.contentMode = .scaleAspectFit
@@ -646,13 +650,13 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             let controller = ScannerViewController()
             let navigationController = UINavigationController(rootViewController: controller)
             navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
+            navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.isTranslucent = false
             let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
+            navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
             navigationController.navigationBar.barStyle = .black
             navigationController.modalPresentationStyle = .custom
@@ -664,7 +668,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             }
             let navigationController = UINavigationController(rootViewController: controller)
             navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
+            navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.isTranslucent = false
             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
             navigationController.navigationBar.barStyle = .black
@@ -672,7 +676,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
+            navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             self.present(navigationController, animated: true)
         } else if item.title == "Backup & Restore".localized() {
             let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "backupRestore") as! BackupRestoreView

+ 2 - 2
appbuilder-ios/AppBuilder/AppBuilder/Info.plist

@@ -115,8 +115,8 @@
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
-	<key>UIUserInterfaceStyle</key>
-	<string>Light</string>
+<!--	<key>UIUserInterfaceStyle</key>-->
+<!--	<string>Light</string>-->
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<true/>
 </dict>

+ 11 - 2
appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift

@@ -57,9 +57,18 @@ class PrefsUtil {
     static func getIconSS() -> String? {
         return UserDefaults.standard.string(forKey: "app_builder_icon_ss")
     }
-    static func getBackground() -> String? {
-        return UserDefaults.standard.string(forKey: "app_builder_background")
+    static func getBackground() -> String {
+        return UserDefaults.standard.string(forKey: "app_builder_background") ?? ""
     }
+    
+    static func getBackgroundLight() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_background_light") ?? ""
+    }
+
+    static func getBackgroundDark() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_background_dark") ?? ""
+    }
+    
     static func getUrlSS() -> String? {
         return PrefsUtil.getURLBase() + "get_file_from_path?img=" + PrefsUtil.getIconSS()!
     }

+ 28 - 0
appbuilder-ios/AppBuilder/AppBuilder/SceneDelegate.swift

@@ -46,6 +46,34 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
                         }
                     )
                 }
+                
+                let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
+                tabBarAppearance.configureWithTransparentBackground()
+                if let rootViewController = window.rootViewController {
+                    // Check if dark mode is enabled
+                    let isDarkMode = rootViewController.traitCollection.userInterfaceStyle == .dark
+                    if isDarkMode {
+                        tabBarAppearance.backgroundColor = .black.withAlphaComponent(0.7)
+                        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
+                        let cancelButtonAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+                        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes , for: .normal)
+                    } else {
+                        tabBarAppearance.backgroundColor = .white.withAlphaComponent(0.9)
+                        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
+                        let cancelButtonAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+                        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes , for: .normal)
+                    }
+                    
+                    if Bundle.main.displayName == "DigiNetS" {
+                        tabBarAppearance.backgroundColor = .black.withAlphaComponent(0.7)
+                    }
+                }
+                if #available(iOS 13.0, *) {
+                    UITabBar.appearance().standardAppearance = tabBarAppearance
+                }
+                if #available(iOS 15.0, *) {
+                    UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
+                }
 
                 return window
             }()

+ 30 - 20
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -33,6 +33,10 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
     var alertController = LibAlertController()
     
     var noData = false
+    
+    override var preferredStatusBarStyle: UIStatusBarStyle {
+        return self.traitCollection.userInterfaceStyle == .dark ? .default : .lightContent // Change this to .default for black text color
+    }
 
     lazy var searchController: UISearchController = {
         var searchController = UISearchController(searchResultsController: nil)
@@ -40,8 +44,12 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         searchController.searchResultsUpdater = self
         searchController.searchBar.autocapitalizationType = .none
         searchController.searchBar.delegate = self
-        searchController.searchBar.barTintColor = .secondaryColor
-        searchController.searchBar.searchTextField.backgroundColor = .secondaryColor
+        let searchBarHeight: CGFloat = 20 // Set your desired height
+        let searchBarFrame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: searchBarHeight)
+        searchController.searchBar.frame = searchBarFrame
+        searchController.searchBar.setMagnifyingGlassColorTo(color: self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor)
+        searchController.searchBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .secondaryColor
+        searchController.searchBar.searchTextField.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .secondaryColor
         searchController.obscuresBackgroundDuringPresentation = false
         searchController.searchBar.searchTextField.attributedPlaceholder = NSAttributedString(string: "Search chats & messages".localized(), attributes: [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)])
         return searchController
@@ -104,11 +112,11 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
             }))
         }
         
-        let startConvIcon = resizeImage(image: UIImage(systemName: "square.and.pencil")!, targetSize: CGSize(width: 25, height: 25))
+        let startConvIcon = resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ?  UIImage(systemName: "square.and.pencil")!.withTintColor(.white) : UIImage(systemName: "square.and.pencil")!, targetSize: CGSize(width: 25, height: 25))
         let viewStartConv = UIButton(frame: CGRect(x: 0, y: 0, width: startConvIcon.size.width, height: startConvIcon.size.height))
         viewStartConv.setImage(startConvIcon, for: .normal)
         viewStartConv.addTarget(self, action: #selector(startConversation), for: .touchUpInside)
-        let brodcastIcon = resizeImage(image: UIImage(named: "ic_broadcast")!, targetSize: CGSize(width: 25, height: 25))
+        let brodcastIcon = resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "ic_broadcast")!.withTintColor(.white) : UIImage(named: "ic_broadcast")!, targetSize: CGSize(width: 25, height: 25))
         let viewbrodcast = UIButton(frame: CGRect(x: 0, y: 0, width: brodcastIcon.size.width, height: brodcastIcon.size.height))
         viewbrodcast.setImage(brodcastIcon, for: .normal)
         viewbrodcast.addTarget(self, action: #selector(openBroadcast), for: .touchUpInside)
@@ -165,13 +173,13 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
         navigationController.modalPresentationStyle = .fullScreen
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
         self.navigationController?.present(navigationController, animated: true, completion: nil)
@@ -345,9 +353,9 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
     
     override func viewWillAppear(_ animated: Bool) {
 //        tabBarController?.navigationItem.leftBarButtonItem = cancelSearchButton
-        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+        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)
-        let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 16)]
+        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
@@ -358,8 +366,8 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         navigationController?.navigationBar.shadowImage = UIImage()
         navigationController?.navigationBar.isTranslucent = true
         navigationController?.setNavigationBarHidden(false, animated: false)
-        navigationController?.navigationBar.tintColor = .black
-        navigationController?.navigationBar.overrideUserInterfaceStyle = .light
+        navigationController?.navigationBar.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
+        navigationController?.navigationBar.overrideUserInterfaceStyle = self.traitCollection.userInterfaceStyle == .dark ? .dark : .light
         navigationController?.navigationBar.barStyle = .default
         tabBarController?.navigationItem.leftBarButtonItem = voiceItem
         let myData = User.getData(pin: User.getMyPin())
@@ -373,9 +381,11 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         tabBarController?.navigationItem.searchController = searchController
         let lang = UserDefaults.standard.string(forKey: "i18n_language")
         speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: lang ?? "en"))
-        backgroundImage.backgroundColor = .white
+        backgroundImage.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
         DispatchQueue.global().async {
-            if let listBg = PrefsUtil.getBackground() {
+            DispatchQueue.main.async {
+                let listBg = PrefsUtil.getBackgroundLight().isEmpty && PrefsUtil.getBackgroundDark().isEmpty ? PrefsUtil.getBackground() :
+                                    self.traitCollection.userInterfaceStyle == .dark ? PrefsUtil.getBackgroundDark() : PrefsUtil.getBackgroundLight()
                 if listBg.isEmpty {
                    return
                 }
@@ -936,7 +946,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                 let labelNochat = UILabel()
                 labelNochat.text = "There are no conversations".localized()
                 labelNochat.font = .systemFont(ofSize: 13)
-                labelNochat.textColor = .black
+                labelNochat.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                 content.addSubview(labelNochat)
                 labelNochat.anchor(centerX: content.centerXAnchor, centerY: content.centerYAnchor)
                 cell.backgroundColor = .clear
@@ -951,7 +961,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                     let labelNochat = UILabel()
                     labelNochat.text = "There are no conversations".localized()
                     labelNochat.font = .systemFont(ofSize: 13)
-                    labelNochat.textColor = .black
+                    labelNochat.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                     content.addSubview(labelNochat)
                     labelNochat.anchor(centerX: content.centerXAnchor, centerY: content.centerYAnchor)
                     cell.backgroundColor = .clear
@@ -1163,19 +1173,19 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                 }
             }
             if group.official == "1" && group.parent == "" {
-                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4)
+                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
             }
             else if group.isOpen == "1" && group.parent == "" {
                 if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 }
             } else if group.parent == "" {
                 if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 }
             } else {
                 content.text = group.name
@@ -1183,7 +1193,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
             if group.childs.count > 0 {
                 let iconName = (group.isSelected) ? "chevron.up.circle" : "chevron.down.circle"
                 let imageView = UIImageView(image: UIImage(systemName: iconName))
-                imageView.tintColor = .black
+                imageView.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                 cell.accessoryView = imageView
             }
             else {

+ 23 - 7
appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift

@@ -33,6 +33,9 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
     
     override func viewDidLoad() {
         super.viewDidLoad()
+        
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
+        
         let tapGesture = UITapGestureRecognizer(target: self, action: #selector(collapseDocked))
         tapGesture.cancelsTouchesInView = false
         tapGesture.delegate = self
@@ -80,6 +83,18 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         NotificationCenter.default.addObserver(self, selector: #selector(onRefreshWebView(notification:)), name: NSNotification.Name(rawValue: "onRefreshWebView"), object: nil)
     }
     
+    func loadURLWithCookie(url: URL) {
+        var urlRequest = URLRequest(url: url)
+        // Setting cookies
+        let cookieHeader = Utils.getCookiesMobile()
+        urlRequest.addValue(cookieHeader, forHTTPHeaderField: "Cookie")
+        
+        // Setting user agent
+        let customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1 \(Utils.getUserAgent())"
+        urlRequest.setValue(customUserAgent, forHTTPHeaderField: "User-Agent")
+        webView.load(urlRequest)
+    }
+    
     override func viewWillAppear(_ animated: Bool) {
         if ThirdTabViewController.inView {
            return
@@ -99,19 +114,19 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         }
         switch(ViewController.tab3){
         case "0":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "1":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-main-only?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-main-only?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "2":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "3":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-commerce?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab3-commerce?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         case "4":
-            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-video?f_pin=\(me ?? "")&lang=\(intLang)"
+            address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-video?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
             myURL = URL(string: address)
         default:
             if(!ViewController.tab3.isEmpty){
@@ -121,7 +136,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
                 }
                 else {
                     if ViewController.sURL.contains("nexilis/pages"){
-                        address = "\(PrefsUtil.getURLBase())\(ViewController.tab3)?f_pin=\(me ?? "")&lang=\(intLang)"
+                        address = "\(PrefsUtil.getURLBase())\(ViewController.tab3)?f_pin=\(me ?? "")&lang=\(intLang)&theme=\(self.traitCollection.userInterfaceStyle == .dark ? "0" : "1")"
                     } else {
                         address = "https://\(ViewController.tab3)"
                     }
@@ -134,7 +149,8 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             self.webView.evaluateJavaScript("{window.localStorage.setItem('currentTab','\(ViewController.tab3)')}")
             if ((dateRefresh == nil || Int(Date().timeIntervalSince(dateRefresh!)) >= 60) && ThirdTabViewController.atFirstPage) || ThirdTabViewController.forceRefresh {
                 let myRequest = URLRequest(url: u)
-                webView.load(myRequest)
+//                let myRequest = URLRequest(url: u)
+                loadURLWithCookie(url: u)
             } else {
                 self.webView.evaluateJavaScript("if(resumeAll){resumeAll();}")
             }

+ 18 - 14
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -59,7 +59,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     override func viewDidLoad() {
         super.viewDidLoad()
         DispatchQueue.main.async { [self] in
-            while !Utils.getFinishInitPrefsr() {
+            while !Utils.getFinishInitPrefsr() || HTTPCookieStorage.shared.cookies?.count == 0 {
                 //print("WAITING PREFS DONE")
             }
             startView()
@@ -84,10 +84,10 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         
         self.delegate = self
         
-        firstTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
-        secondTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
-        thirdTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
-        fourthTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        firstTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_1_icon")!.withTintColor(.white) : UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        secondTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_2_icon")!.withTintColor(.white) : UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        thirdTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_3_icon")!.withTintColor(.white) : UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        fourthTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_4_icon")!.withTintColor(.white) : UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
         var i = 0
         var j = 0
         while j < customTab.count {
@@ -305,7 +305,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -313,7 +313,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 ViewController.def?.show(b: false)
                 ViewController.def?.thirdTab?.webView?.evaluateJavaScript("{if(pauseAll){pauseAll();}}")
                 ViewController.def?.firstTab?.webView?.evaluateJavaScript("{if(pauseAll){pauseAll();}}")
@@ -582,7 +582,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 controller.forceLogin = true
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -590,7 +590,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.modalTransitionStyle = .crossDissolve
                 self.present(navigationController, animated: true)
@@ -607,7 +607,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             bgImage.anchor(top: privacyView.topAnchor, left: privacyView.leftAnchor, bottom: privacyView.bottomAnchor, right: privacyView.rightAnchor)
             bgImage.backgroundColor = .white
             DispatchQueue.global().async {
-                if let listBg = PrefsUtil.getBackground() {
+                DispatchQueue.main.async {
+                    let listBg = PrefsUtil.getBackgroundLight().isEmpty && PrefsUtil.getBackgroundDark().isEmpty ? PrefsUtil.getBackground() :
+                                        self.traitCollection.userInterfaceStyle == .dark ? PrefsUtil.getBackgroundDark() : PrefsUtil.getBackgroundLight()
                     if listBg.isEmpty {
                        return
                     }
@@ -681,7 +683,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             bgImage.anchor(top: viewWelcome.topAnchor, left: viewWelcome.leftAnchor, bottom: viewWelcome.bottomAnchor, right: viewWelcome.rightAnchor)
             bgImage.backgroundColor = .white
             DispatchQueue.global().async {
-                if let listBg = PrefsUtil.getBackground() {
+                DispatchQueue.main.async {
+                    let listBg = PrefsUtil.getBackgroundLight().isEmpty && PrefsUtil.getBackgroundDark().isEmpty ? PrefsUtil.getBackground() :
+                                        self.traitCollection.userInterfaceStyle == .dark ? PrefsUtil.getBackgroundDark() : PrefsUtil.getBackgroundLight()
                     if listBg.isEmpty {
                        return
                     }
@@ -722,17 +726,17 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             
             let imageAgree = UIImageView()
             imageAgree.image = UIImage(systemName: "arrow.forward.circle")
-            imageAgree.tintColor = .black
+            imageAgree.tintColor = self.traitCollection.userInterfaceStyle == .dark ? UIColor.white: UIColor.black
             containerButton.addSubview(imageAgree)
             imageAgree.anchor(left: containerButton.leftAnchor, centerY: containerButton.centerYAnchor, width: 40, height: 40)
             
             let titleAgree = UILabel()
             titleAgree.text = "Agree and Continue".localized()
-            titleAgree.textColor = .black
+            titleAgree.textColor = self.traitCollection.userInterfaceStyle == .dark ? UIColor.white: UIColor.black
             containerButton.addSubview(titleAgree)
             titleAgree.anchor(left: imageAgree.rightAnchor, right: containerButton.rightAnchor, paddingLeft: 5, centerY: containerButton.centerYAnchor)
             
-            let formattedText = String.format(strings: [term], inString: termText)
+            let formattedText = String.format(strings: [term], inString: termText, color: self.traitCollection.userInterfaceStyle == .dark ? UIColor.white: UIColor.black)
             welcomeDesc.isUserInteractionEnabled = true
             welcomeDesc.attributedText = formattedText
             welcomeDesc.numberOfLines = 0

+ 7 - 13
appbuilder-ios/NexilisLite/NexilisLite/Resource/Palio.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
         <capability name="Image references" minToolsVersion="12.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
@@ -772,10 +772,9 @@
                                                         </label>
                                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NYg-hJ-SNM">
                                                             <rect key="frame" x="8" y="124" width="358" height="34.5"/>
+                                                            <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                             <state key="normal" title="Button"/>
-                                                            <buttonConfiguration key="configuration" style="filled" title="Contact Center History">
-                                                                <color key="baseBackgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                                            </buttonConfiguration>
+                                                            <buttonConfiguration key="configuration" style="filled" title="Contact Center History"/>
                                                         </button>
                                                         <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="oaQ-vC-3bV">
                                                             <rect key="frame" x="315" y="4" width="51" height="31"/>
@@ -860,6 +859,7 @@
                     </tableView>
                     <connections>
                         <outlet property="buttonEditPass" destination="ndh-T2-T4k" id="cy2-EG-DG5"/>
+                        <outlet property="buttonEditpass" destination="ndh-T2-T4k" id="d12-ra-06C"/>
                         <outlet property="buttonGroup" destination="iZk-GF-RJR" id="mQl-wh-jCZ"/>
                         <outlet property="buttonHistoryCC" destination="NYg-hJ-SNM" id="1ah-Tv-T3l"/>
                         <outlet property="call" destination="8T1-2m-3h5" id="i1Z-n0-cmD"/>
@@ -2318,7 +2318,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <viewLayoutGuide key="safeArea" id="J5B-BM-rF4"/>
-                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="0Xk-4f-4yy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -2560,7 +2560,6 @@
                                                 </connections>
                                             </button>
                                         </subviews>
-                                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                                         <constraints>
                                             <constraint firstItem="Y6s-g6-F6l" firstAttribute="width" secondItem="UMZ-Cg-DEH" secondAttribute="width" multiplier="0.25" id="7m9-oZ-EYC"/>
                                             <constraint firstItem="A4V-Nn-duA" firstAttribute="height" secondItem="UMZ-Cg-DEH" secondAttribute="height" id="7uj-aT-7Z0"/>
@@ -2584,7 +2583,6 @@
                             </view>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="4DG-z5-IE7"/>
-                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                         <constraints>
                             <constraint firstItem="4DG-z5-IE7" firstAttribute="trailing" secondItem="yLm-Hp-3ZU" secondAttribute="trailing" id="5qq-yP-taB"/>
                             <constraint firstItem="yLm-Hp-3ZU" firstAttribute="top" secondItem="tSE-6b-2zD" secondAttribute="bottom" constant="10" id="6PR-yi-4lY"/>
@@ -2637,7 +2635,7 @@
                             </tableView>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="1vz-q2-vEl">
                                 <rect key="frame" x="0.0" y="836" width="414" height="150"/>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="150" id="h0o-Vx-cZy"/>
                                 </constraints>
@@ -2733,7 +2731,6 @@
                                                 </connections>
                                             </button>
                                         </subviews>
-                                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                                         <constraints>
                                             <constraint firstItem="4tF-ju-a54" firstAttribute="height" secondItem="ZXb-nM-tPm" secondAttribute="height" id="0Y6-mG-7p5"/>
                                             <constraint firstItem="acF-7N-m3T" firstAttribute="height" secondItem="ZXb-nM-tPm" secondAttribute="height" id="2tl-at-cqF"/>
@@ -2757,7 +2754,6 @@
                             </view>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="kcu-H8-MOl"/>
-                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                         <constraints>
                             <constraint firstAttribute="bottom" secondItem="rs3-vX-pDB" secondAttribute="bottom" id="7cj-we-UtI"/>
                             <constraint firstItem="pVj-YY-BAA" firstAttribute="leading" secondItem="kcu-H8-MOl" secondAttribute="leading" id="Boh-wY-vBg"/>
@@ -2858,7 +2854,6 @@
                             </tableView>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="9qz-fK-dJv"/>
-                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                         <constraints>
                             <constraint firstItem="R3H-lp-ykb" firstAttribute="leading" secondItem="9qz-fK-dJv" secondAttribute="leading" id="74e-tt-1zg"/>
                             <constraint firstAttribute="bottom" secondItem="R3H-lp-ykb" secondAttribute="bottom" constant="20" id="LmS-xC-8SD"/>
@@ -3196,7 +3191,6 @@
                             </view>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="5fk-BT-ZVX"/>
-                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
                         <constraints>
                             <constraint firstItem="PQ7-32-KB5" firstAttribute="trailing" secondItem="5fk-BT-ZVX" secondAttribute="trailing" id="5gH-12-yDu"/>
                             <constraint firstItem="iIp-8A-V60" firstAttribute="bottom" secondItem="5fk-BT-ZVX" secondAttribute="bottom" id="H6o-Rr-AFa"/>

+ 4 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/APIS.swift

@@ -193,7 +193,7 @@ public class APIS: NSObject {
         let navigationController = UINavigationController(rootViewController: editorPersonalVC)
         navigationController.modalPresentationStyle = .fullScreen
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
@@ -201,7 +201,7 @@ public class APIS: NSObject {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         if UIApplication.shared.visibleViewController?.navigationController != nil {
             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
         } else {
@@ -736,7 +736,7 @@ extension UINavigationController {
     func defaultStyle() {
         self.modalPresentationStyle = .fullScreen
         self.navigationBar.tintColor = .white
-        self.navigationBar.barTintColor = .mainColor
+        self.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         self.navigationBar.isTranslucent = false
         self.navigationBar.overrideUserInterfaceStyle = .dark
         self.navigationBar.barStyle = .black
@@ -744,6 +744,6 @@ extension UINavigationController {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         self.navigationBar.titleTextAttributes = textAttributes
-        self.view.backgroundColor = .mainColor
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
     }
 }

+ 7 - 3
appbuilder-ios/NexilisLite/NexilisLite/Source/Extension.swift

@@ -353,13 +353,17 @@ extension URL {
 
 extension UIColor {
     public static var mainColor: UIColor {
-        renderColor(hex: "#3669ad")
+        return renderColor(hex: "#3669ad")
     }
     
     public static var secondaryColor: UIColor {
         return renderColor(hex: "#FAFAFF")
     }
     
+    public static var blackDarkMode: UIColor {
+        return renderColor(hex: "#262626")
+    }
+    
     public static var orangeColor: UIColor {
         return renderColor(hex: "#FFA03E")
     }
@@ -476,7 +480,7 @@ extension UIViewController {
     public func showToast(message : String, font: UIFont = UIFont.systemFont(ofSize: 12, weight: .medium), controller: UIViewController) {
         
         let toastContainer = UIView(frame: CGRect())
-        toastContainer.backgroundColor = UIColor.mainColor.withAlphaComponent(0.6)
+        toastContainer.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode.withAlphaComponent(0.6) : UIColor.mainColor.withAlphaComponent(0.6)
         toastContainer.alpha = 0.0
         toastContainer.layer.cornerRadius = 25;
         toastContainer.clipsToBounds  =  true
@@ -1229,7 +1233,7 @@ public class LibAlertController: UIAlertController {
 extension UISearchBar
 {
 
-    func setMagnifyingGlassColorTo(color: UIColor)
+    public func setMagnifyingGlassColorTo(color: UIColor)
     {
         // Search Icon
         let textFieldInsideSearchBar = self.value(forKey: "searchField") as? UITextField

+ 2 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -574,7 +574,7 @@ public class FloatingButton: UIView {
                 let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -582,7 +582,7 @@ public class FloatingButton: UIView {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 UIApplication.shared.rootViewController?.present(navigationController, animated: true, completion: nil)
             }
             hideButton()

+ 6 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/IncomingThread.swift

@@ -259,6 +259,12 @@ class IncomingThread {
                     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)

+ 141 - 141
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -123,142 +123,142 @@ public class Nexilis: NSObject {
     }
     
     public static func connect(apiKey: String, delegate: ConnectDelegate, showButton: Bool = true, fromMAB: Bool = false) {
-        do {
-            showFB = showButton
-            
-            Nexilis.shared.createDelegate()
-            
-            Nexilis.sAPIKey = apiKey
-            
-            Nexilis.showButtonFB = showButton
-            
-            Database.shared.openDatabase()
-            
-            IncomingThread.default.run()
-            
-            imageCache.countLimit = 100
-            imageCache.totalCostLimit = 1024 * 1024 * 200
-            
-            let address = Nexilis.getAddressNew(apiKey:apiKey)
-//            print("ADDRESS \(address)")
-            if address.isEmpty {
-                return
-            }
-//            UserDefaults.standard.set(address, forKey: "address")
-//            UserDefaults.standard.set(address[0], forKey: "server")
-//            
-            Nexilis.dispatch = DispatchGroup()
-            Nexilis.dispatch?.enter()
-//            var server = UserDefaults.standard.string(forKey: "server")
-//            if let s = server, let a = UserDefaults.standard.stringArray(forKey: "address"), s != a[0] {
-//                server = a[0]
-//                UserDefaults.standard.set(server, forKey: "server")
-//            }
-//            var ip = ""
-//            var port = 0
-//            if let s = server {
-//                let data = s.split(separator: ":")
-//                ip = String(data[0])
-//                if let p = Int(data[1]) {
-//                    port = p
-//                }
-//            }
-            Nexilis.ADDRESS = address.components(separatedBy: ":")[0]
-            Nexilis.PORT = Int(address.components(separatedBy: ":")[1]) ?? 0
-//            print("IP PORT \(Nexilis.ADDRESS) <> \(Nexilis.PORT)")
-            var id = ""
-            if let device_id = UserDefaults.standard.string(forKey: "device_id") {
-                try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: device_id, sStartWH: "09:00")
-            } else if let me = UserDefaults.standard.string(forKey: "me") {
-                try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: me, sStartWH: "09:00")
-            } else {
-                let uuid = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
-                try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: uuid, sStartWH: "09:00")
-                id = uuid
-            }
-            
-            // wait until connection true
-            Nexilis.dispatch?.wait()
-            Nexilis.dispatch = nil
-            
-//            Nexilis.initiateAudio()
-            if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
-                if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
-                    id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
-                    let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
-                    Utils.setForceAnonymous(value: enable_signup)
-                    if(!id.isEmpty) {
-                        Nexilis.changeUser(f_pin: id)
-                        UserDefaults.standard.setValue(id, forKey: "me")
+        showFB = showButton
+        
+        Nexilis.shared.createDelegate()
+        
+        Nexilis.sAPIKey = apiKey
+        
+        Nexilis.showButtonFB = showButton
+        
+        Database.shared.openDatabase()
+        
+        IncomingThread.default.run()
+        
+        imageCache.countLimit = 100
+        imageCache.totalCostLimit = 1024 * 1024 * 200
+        
+        DispatchQueue.global().async {
+            do {
+                let address = Nexilis.getAddressNew(apiKey:apiKey)
+    //            print("ADDRESS \(address)")
+                if address.isEmpty {
+                    return
+                }
+    //            UserDefaults.standard.set(address, forKey: "address")
+    //            UserDefaults.standard.set(address[0], forKey: "server")
+    //
+                Nexilis.dispatch = DispatchGroup()
+                Nexilis.dispatch?.enter()
+    //            var server = UserDefaults.standard.string(forKey: "server")
+    //            if let s = server, let a = UserDefaults.standard.stringArray(forKey: "address"), s != a[0] {
+    //                server = a[0]
+    //                UserDefaults.standard.set(server, forKey: "server")
+    //            }
+    //            var ip = ""
+    //            var port = 0
+    //            if let s = server {
+    //                let data = s.split(separator: ":")
+    //                ip = String(data[0])
+    //                if let p = Int(data[1]) {
+    //                    port = p
+    //                }
+    //            }
+                Nexilis.ADDRESS = address.components(separatedBy: ":")[0]
+                Nexilis.PORT = Int(address.components(separatedBy: ":")[1]) ?? 0
+    //            print("IP PORT \(Nexilis.ADDRESS) <> \(Nexilis.PORT)")
+                var id = ""
+                if let device_id = UserDefaults.standard.string(forKey: "device_id") {
+                    try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: device_id, sStartWH: "09:00")
+                } else if let me = UserDefaults.standard.string(forKey: "me") {
+                    try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: me, sStartWH: "09:00")
+                } else {
+                    let uuid = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
+                    try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: uuid, sStartWH: "09:00")
+                    id = uuid
+                }
+                
+                // wait until connection true
+                Nexilis.dispatch?.wait()
+                Nexilis.dispatch = nil
+                
+    //            Nexilis.initiateAudio()
+                if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
+                    if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
+                        id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
+                        let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
+                        Utils.setForceAnonymous(value: enable_signup)
+                        if(!id.isEmpty) {
+                            Nexilis.changeUser(f_pin: id)
+                            UserDefaults.standard.setValue(id, forKey: "me")
+                        }
                     }
                 }
-            }
 
-            if UserDefaults.standard.string(forKey: "apiKey") == nil {
-                UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
-            }
-            
-            if let me = UserDefaults.standard.string(forKey: "me") {
-                if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
-                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
-                            if !cursorData.next() {
-                                _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
+                if UserDefaults.standard.string(forKey: "apiKey") == nil {
+                    UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
+                }
+                
+                if let me = UserDefaults.standard.string(forKey: "me") {
+                    if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
+                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
+                                if !cursorData.next() {
+                                    _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
+                                }
+                                cursorData.close()
                             }
-                            cursorData.close()
-                        }
-                    })
-                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
-                            do {
-                                let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
-                                let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
-                                if !FileManager().fileExists(atPath: file.path) {
-                                    Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
+                        })
+                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
+                                do {
+                                    let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+                                    let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
+                                    if !FileManager().fileExists(atPath: file.path) {
+                                        Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
+                                    }
+                                } catch {}
+                                cursorData.close()
+                            }
+                        })
+                    }
+                    getServiceBank()
+                    getPullWorkingArea()
+                    getPullGroupNoMember()
+                    delegate.onSuccess(userId: me)
+                    getPullDefaultCC()
+                    if showButton {
+                        DispatchQueue.main.async {
+                            var viewController = UIApplication.shared.windows.first?.rootViewController
+                            var notNull = false
+                            while !notNull {
+                                viewController = UIApplication.shared.windows.first?.rootViewController
+                                if viewController != nil && Utils.getFinishInitPrefsr() {
+                                    notNull = true
                                 }
-                            } catch {}
-                            cursorData.close()
-                        }
-                    })
-                }
-                getServiceBank()
-                getPullWorkingArea()
-                getPullGroupNoMember()
-                delegate.onSuccess(userId: me)
-                getPullDefaultCC()
-                if showButton {
-                    DispatchQueue.main.async {
-                        var viewController = UIApplication.shared.windows.first?.rootViewController
-                        var notNull = false
-                        while !notNull {
-                            viewController = UIApplication.shared.windows.first?.rootViewController
-                            if viewController != nil && Utils.getFinishInitPrefsr() {
-                                notNull = true
                             }
+                            addFB(viewController: viewController!, fromMAB: fromMAB)
                         }
-                        addFB(viewController: viewController!, fromMAB: fromMAB)
                     }
                 }
+                Nexilis.destroyAll()
+                OutgoingThread.default.run()
+                
+                InquiryThread.default.run()
+                
+                if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
+                    UIFont.libOverrideInitialize()
+                }
+                
+                if (Utils.getSetProfile() && !Utils.getFinishInitPrefsr()) || (!Utils.getForceAnonymous() && !Utils.getFinishInitPrefsr()) {
+                    Utils.setFinishInitPrefs(value: true)
+                }
+            } catch {
+                delegate.onFailed(error: "99:Something went wrong")
             }
-            Nexilis.destroyAll()
-            OutgoingThread.default.run()
-            
-            InquiryThread.default.run()
-            
-            if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
-                UIFont.libOverrideInitialize()
-            }
-            
-            if (Utils.getSetProfile() && !Utils.getFinishInitPrefsr()) || (!Utils.getForceAnonymous() && !Utils.getFinishInitPrefsr()) {
-                Utils.setFinishInitPrefs(value: true)
-            }
-            
-            //print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
-        }
-        catch {
-            //print(error)
-            delegate.onFailed(error: "99:Something went wrong")
         }
+        
+        //print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
     }
     
     public static func addFB(viewController: UIViewController, fromMAB: Bool) {
@@ -852,7 +852,7 @@ public class Nexilis: NSObject {
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -860,7 +860,7 @@ public class Nexilis: NSObject {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 if UIApplication.shared.visibleViewController?.navigationController != nil {
                     UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                 } else {
@@ -896,7 +896,7 @@ public class Nexilis: NSObject {
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -904,7 +904,7 @@ public class Nexilis: NSObject {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 if UIApplication.shared.visibleViewController?.navigationController != nil {
                     UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                 } else {
@@ -967,7 +967,7 @@ public class Nexilis: NSObject {
                 let navigationController = UINavigationController(rootViewController: controller)
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
-                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 navigationController.navigationBar.isTranslucent = false
                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                 navigationController.navigationBar.barStyle = .black
@@ -975,7 +975,7 @@ public class Nexilis: NSObject {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                navigationController.view.backgroundColor = .mainColor
+                navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 let rootVC = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
                 if rootVC?.presentedViewController == nil {
                     rootVC?.present(navigationController, animated: true, completion: nil)
@@ -2491,7 +2491,7 @@ extension Nexilis: MessageDelegate {
                                         let navigationController = UINavigationController(rootViewController: editorPersonalVC)
                                         navigationController.modalPresentationStyle = .fullScreen
                                         navigationController.navigationBar.tintColor = .white
-                                        navigationController.navigationBar.barTintColor = .mainColor
+                                        navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                         navigationController.navigationBar.isTranslucent = false
                                         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                                         navigationController.navigationBar.barStyle = .black
@@ -2499,7 +2499,7 @@ extension Nexilis: MessageDelegate {
                                         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                                         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                                         navigationController.navigationBar.titleTextAttributes = textAttributes
-                                        navigationController.view.backgroundColor = .mainColor
+                                        navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                         if UIApplication.shared.visibleViewController?.navigationController != nil {
                                             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                                         } else {
@@ -2888,7 +2888,7 @@ extension Nexilis: MessageDelegate {
                                             let navigationController = UINavigationController(rootViewController: editorPersonalVC)
                                             navigationController.modalPresentationStyle = .fullScreen
                                             navigationController.navigationBar.tintColor = .white
-                                            navigationController.navigationBar.barTintColor = .mainColor
+                                            navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                             navigationController.navigationBar.isTranslucent = false
                                             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                                             navigationController.navigationBar.barStyle = .black
@@ -2896,7 +2896,7 @@ extension Nexilis: MessageDelegate {
                                             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                                             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                                             navigationController.navigationBar.titleTextAttributes = textAttributes
-                                            navigationController.view.backgroundColor = .mainColor
+                                            navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                             if UIApplication.shared.visibleViewController?.navigationController != nil {
                                                 UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                                             } else {
@@ -3329,7 +3329,7 @@ extension Nexilis: MessageDelegate {
                                         let navigationController = UINavigationController(rootViewController: controller)
                                         navigationController.modalPresentationStyle = .fullScreen
                                         navigationController.navigationBar.tintColor = .white
-                                        navigationController.navigationBar.barTintColor = .mainColor
+                                        navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                         navigationController.navigationBar.isTranslucent = false
                                         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                                         navigationController.navigationBar.barStyle = .black
@@ -3337,7 +3337,7 @@ extension Nexilis: MessageDelegate {
                                         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                                         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                                         navigationController.navigationBar.titleTextAttributes = textAttributes
-                                        navigationController.view.backgroundColor = .mainColor
+                                        navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                         if UIApplication.shared.visibleViewController?.navigationController != nil {
                                             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                                         } else {
@@ -3372,7 +3372,7 @@ extension Nexilis: MessageDelegate {
                                 let navigationController = UINavigationController(rootViewController: editorPersonalVC)
                                 navigationController.modalPresentationStyle = .fullScreen
                                 navigationController.navigationBar.tintColor = .white
-                                navigationController.navigationBar.barTintColor = .mainColor
+                                navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                 navigationController.navigationBar.isTranslucent = false
                                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                                 navigationController.navigationBar.barStyle = .black
@@ -3380,7 +3380,7 @@ extension Nexilis: MessageDelegate {
                                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                                navigationController.view.backgroundColor = .mainColor
+                                navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                 if UIApplication.shared.visibleViewController?.navigationController != nil {
                                     UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                                 } else {
@@ -3465,7 +3465,7 @@ extension Nexilis: MessageDelegate {
                                 let navigationController = UINavigationController(rootViewController: editorGroupVC)
                                 navigationController.modalPresentationStyle = .fullScreen
                                 navigationController.navigationBar.tintColor = .white
-                                navigationController.navigationBar.barTintColor = .mainColor
+                                navigationController.navigationBar.barTintColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                 navigationController.navigationBar.isTranslucent = false
                                 navigationController.navigationBar.overrideUserInterfaceStyle = .dark
                                 navigationController.navigationBar.barStyle = .black
@@ -3473,7 +3473,7 @@ extension Nexilis: MessageDelegate {
                                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                                 navigationController.navigationBar.titleTextAttributes = textAttributes
-                                navigationController.view.backgroundColor = .mainColor
+                                navigationController.view.backgroundColor = UIApplication.shared.visibleViewController?.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                                 if UIApplication.shared.visibleViewController?.navigationController != nil {
                                     UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
                                 } else {

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

@@ -158,10 +158,26 @@ public final class Utils {
         UserDefaults.standard.set(value, forKey: "cookies_mobile")
     }
 
-    static func getCookiesMobile() -> String {
+    public static func getCookiesMobile() -> String {
         UserDefaults.standard.string(forKey: "cookies_mobile") ?? ""
     }
     
+    static func setBackgroundLight(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_background_light")
+    }
+
+    static func getBackgroundLight() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_background_light") ?? ""
+    }
+    
+    static func setBackgroundDark(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_background_dark")
+    }
+
+    static func getBackgroundDark() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_background_dark") ?? ""
+    }
+    
     
     public static func sGetCurrentDateTime(sFormat: String!) -> String! {
         let todaysDate = NSDate()

+ 2 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -444,7 +444,7 @@ class QmeraAudioViewController: UIViewController {
         let navigationController = UINavigationController(rootViewController: editorPersonalVC)
         navigationController.modalPresentationStyle = .overCurrentContext
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
@@ -452,7 +452,7 @@ class QmeraAudioViewController: UIViewController {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         if UIApplication.shared.visibleViewController?.navigationController != nil {
             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
         } else {

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraCallContactViewController.swift

@@ -49,7 +49,7 @@ class QmeraCallContactViewController: UITableViewController {
         } else {
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController?.navigationBar.titleTextAttributes = textAttributes
-            navigationController?.navigationBar.barTintColor = .mainColor
+            navigationController?.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         }
         
         tableView.register(UITableViewCell.self, forCellReuseIdentifier: "reuseIdentifier")

+ 4 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -114,7 +114,7 @@ class QmeraVideoViewController: UIViewController {
         navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
         navigationController?.navigationBar.shadowImage = nil
         navigationController?.navigationBar.isTranslucent = false
-        navigationController?.view.backgroundColor = .mainColor
+        navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController?.navigationBar.titleTextAttributes = textAttributes
         navigationController?.navigationBar.topItem?.backBarButtonItem = nil
@@ -127,7 +127,7 @@ class QmeraVideoViewController: UIViewController {
             navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
             navigationController?.navigationBar.shadowImage = nil
             navigationController?.navigationBar.isTranslucent = false
-            navigationController?.view.backgroundColor = .mainColor
+            navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController?.navigationBar.titleTextAttributes = textAttributes
             navigationController?.navigationBar.topItem?.backBarButtonItem = nil
@@ -598,7 +598,7 @@ class QmeraVideoViewController: UIViewController {
         let navigationController = UINavigationController(rootViewController: editorPersonalVC)
         navigationController.modalPresentationStyle = .overCurrentContext
         navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController.navigationBar.isTranslucent = false
         navigationController.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController.navigationBar.barStyle = .black
@@ -606,7 +606,7 @@ class QmeraVideoViewController: UIViewController {
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
         navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
+        navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         if UIApplication.shared.visibleViewController?.navigationController != nil {
             UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
         } else {

+ 2 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/ChatGPTBotView.swift

@@ -87,11 +87,11 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
     public override func viewDidAppear(_ animated: Bool) {
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
         navigationController?.navigationBar.isTranslucent = false
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.tintColor = .white
         navigationController?.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController?.navigationBar.barStyle = .black

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

@@ -114,11 +114,11 @@ public class EditorGroup: UIViewController {
     public override func viewDidAppear(_ animated: Bool) {
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
         navigationController?.navigationBar.isTranslucent = false
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.tintColor = .white
         navigationController?.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController?.navigationBar.barStyle = .black
@@ -2645,11 +2645,11 @@ extension EditorGroup: UIContextMenuInteractionDelegate {
             }
             contactChatNav.modalPresentationStyle = .custom
             contactChatNav.navigationBar.tintColor = .white
-            contactChatNav.navigationBar.barTintColor = .mainColor
+            contactChatNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             contactChatNav.navigationBar.isTranslucent = false
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             contactChatNav.navigationBar.titleTextAttributes = textAttributes
-            contactChatNav.view.backgroundColor = .mainColor
+            contactChatNav.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             if let controller = contactChatNav.viewControllers.first as? ContactChatViewController {
                 controller.isChooser = { [weak self] scope, pin in
                     if scope == "3" {
@@ -3114,7 +3114,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                 let streamingNav = UINavigationController(rootViewController: streamingController)
                 streamingNav.modalPresentationStyle = .custom
                 streamingNav.navigationBar.tintColor = .white
-                streamingNav.navigationBar.barTintColor = .mainColor
+                streamingNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 streamingNav.navigationBar.isTranslucent = false
                 streamingNav.navigationBar.overrideUserInterfaceStyle = .dark
                 streamingNav.navigationBar.barStyle = .black
@@ -3122,7 +3122,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 streamingNav.navigationBar.titleTextAttributes = textAttributes
-                streamingNav.view.backgroundColor = .mainColor
+                streamingNav.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 streamingNav.navigationBar.isTranslucent = false
                 navigationController?.present(streamingNav, animated: true, completion: nil)
             }

+ 17 - 16
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -130,11 +130,11 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     public override func viewDidAppear(_ animated: Bool) {
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
         navigationController?.navigationBar.isTranslucent = false
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.tintColor = .white
         navigationController?.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController?.navigationBar.barStyle = .black
@@ -159,29 +159,30 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
         super.viewDidLoad()
 //        navigationController?.navigationBar.topItem?.title = ""
         
-        viewButton.layer.shadowColor = UIColor.gray.cgColor
+        viewButton.layer.shadowColor = self.traitCollection.userInterfaceStyle == .dark ? UIColor.white.cgColor : UIColor.gray.cgColor
         viewButton.layer.shadowOpacity = 1
         viewButton.layer.shadowOffset = .zero
         viewButton.layer.shadowRadius = 3
         
 //        buttonVoice.setImage(resizeImage(image: UIImage(named: "Voice-Record", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)), for: .normal)
-        buttonSendImage.setImage(resizeImage(image: UIImage(named: "Send-Image", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(.mainColor), for: .normal)
-        buttonSendPhoto.setImage(resizeImage(image: UIImage(named: "Camera", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(.mainColor), for: .normal)
-        buttonSendSticker.setImage(resizeImage(image: UIImage(named: "Sticker---Emoji", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(.mainColor), for: .normal)
-        buttonSendFile.setImage(resizeImage(image: UIImage(named: "File---Documents", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(.mainColor), for: .normal)
+        buttonSendImage.setImage(resizeImage(image: UIImage(named: "Send-Image", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor), for: .normal)
+        buttonSendPhoto.setImage(resizeImage(image: UIImage(named: "Camera", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor), for: .normal)
+        buttonSendSticker.setImage(resizeImage(image: UIImage(named: "Sticker---Emoji", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor), for: .normal)
+        buttonSendFile.setImage(resizeImage(image: UIImage(named: "File---Documents", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor), for: .normal)
         
-        buttonSendChat.setImage(resizeImage(image: UIImage(named: "Send-(White)", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), for: .normal)
+        buttonSendChat.setImage(resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "Send-(White)", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(.blackDarkMode) : UIImage(named: "Send-(White)", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), for: .normal)
         
         buttonSendChat.circle()
         buttonSendChat.addTarget(self, action: #selector(sendTapped), for: .touchUpInside)
-        buttonSendChat.backgroundColor = .mainColor
+        buttonSendChat.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor
         if isContactCenter {
             buttonAckConfidential.isHidden = true
             constraintLeftTextField.constant = 20
         } else {
             buttonAckConfidential.circle()
             buttonAckConfidential.addTarget(self, action: #selector(showChooserACKConfidential), for: .touchUpInside)
-            buttonAckConfidential.backgroundColor = .mainColor
+            buttonAckConfidential.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .white
+            buttonAckConfidential.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor
         }
         textFieldSend.layer.cornerRadius = textFieldSend.maxCornerRadius()
         textFieldSend.layer.borderWidth = 1.0
@@ -529,7 +530,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     let last_r = dataSaved.components(separatedBy: ",")[1]
                     if !last_m.isEmpty {
                         textFieldSend.text = last_m
-                        textFieldSend.textColor = UIColor.black
+                        textFieldSend.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black
                     }
                     
                     if !last_r.isEmpty {
@@ -3341,7 +3342,7 @@ extension EditorPersonal: UITextViewDelegate {
     public func textViewDidBeginEditing(_ textView: UITextView) {
         if textView.textColor == UIColor.lightGray {
             textView.text = nil
-            textView.textColor = UIColor.black
+            textView.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black
         }
     }
     
@@ -3826,11 +3827,11 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             }
             contactChatNav.modalPresentationStyle = .custom
             contactChatNav.navigationBar.tintColor = .white
-            contactChatNav.navigationBar.barTintColor = .mainColor
+            contactChatNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             contactChatNav.navigationBar.isTranslucent = false
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             contactChatNav.navigationBar.titleTextAttributes = textAttributes
-            contactChatNav.view.backgroundColor = .mainColor
+            contactChatNav.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             if let controller = contactChatNav.viewControllers.first as? ContactChatViewController {
                 controller.isChooser = { [weak self] scope, pin in
                     if scope == "3" {
@@ -4236,7 +4237,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                 let streamingNav = UINavigationController(rootViewController: streamingController)
                 streamingNav.modalPresentationStyle = .custom
                 streamingNav.navigationBar.tintColor = .white
-                streamingNav.navigationBar.barTintColor = .mainColor
+                streamingNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 streamingNav.navigationBar.isTranslucent = false
                 streamingNav.navigationBar.overrideUserInterfaceStyle = .dark
                 streamingNav.navigationBar.barStyle = .black
@@ -4244,7 +4245,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                 UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 streamingNav.navigationBar.titleTextAttributes = textAttributes
-                streamingNav.view.backgroundColor = .mainColor
+                streamingNav.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 streamingNav.navigationBar.isTranslucent = false
                 navigationController?.present(streamingNav, animated: true, completion: nil)
             } else if  message["message_scope_id"] as? String == "18" {

+ 3 - 3
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorStarMessages.swift

@@ -1331,7 +1331,7 @@ public class EditorStarMessages: UIViewController, UITableViewDataSource, UITabl
             let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
             navigationController.modalPresentationStyle = .custom
             navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
+            navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.isTranslucent = false
             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
             navigationController.navigationBar.barStyle = .black
@@ -1339,7 +1339,7 @@ public class EditorStarMessages: UIViewController, UITableViewDataSource, UITabl
             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
+            navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             if let controller = navigationController.viewControllers.first as? ContactChatViewController {
                 controller.isChooser = { [weak self] scope, pin in
                     if scope == "3" {
@@ -1490,7 +1490,7 @@ public class EditorStarMessages: UIViewController, UITableViewDataSource, UITabl
                 }
                 let streamingNav = UINavigationController(rootViewController: streamingController)
                 streamingNav.modalPresentationStyle = .custom
-                streamingNav.navigationBar.barTintColor = .mainColor
+                streamingNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
                 streamingNav.navigationBar.tintColor = .white
                 let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
                 streamingNav.navigationBar.titleTextAttributes = textAttributes

+ 2 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/ListGroupImages.swift

@@ -532,11 +532,11 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
             let contactChatNav = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
             contactChatNav.modalPresentationStyle = .custom
             contactChatNav.navigationBar.tintColor = .white
-            contactChatNav.navigationBar.barTintColor = .mainColor
+            contactChatNav.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             contactChatNav.navigationBar.isTranslucent = false
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             contactChatNav.navigationBar.titleTextAttributes = textAttributes
-            contactChatNav.view.backgroundColor = .mainColor
+            contactChatNav.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             if let controller = contactChatNav.viewControllers.first as? ContactChatViewController {
                 controller.isChooser = { [weak self] scope, pin in
                     if scope == "3" {

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

@@ -51,7 +51,7 @@ class AddFriendTableViewController: UITableViewController {
         let attributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
         navBarAppearance.titleTextAttributes = attributes
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance

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

@@ -188,7 +188,6 @@ public class BackupRestoreView: UIViewController, UITableViewDataSource, UITable
     
     public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "cellBackupRestore", for: indexPath as IndexPath)
-        cell.backgroundColor = .secondaryColor
         makeViewBackup(cell: cell, indexPath: indexPath)
         return cell
     }
@@ -366,7 +365,7 @@ public class BackupRestoreView: UIViewController, UITableViewDataSource, UITable
             descBackup.anchor(top: containerLogo.bottomAnchor, left: container.leftAnchor, bottom: container.bottomAnchor, right: container.rightAnchor, paddingTop: 2, paddingLeft: 10, paddingBottom: 10, paddingRight: 10)
             descBackup.text = "Back up your chat history to server so if you lose your phone or switch to a new one or logout your account, your chat history is safe. You can restore your chat history when you relogin your account.".localized()
             descBackup.numberOfLines = 0
-            descBackup.textColor = .black
+            descBackup.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
             descBackup.font = .systemFont(ofSize: 12)
         } else if indexPath.section == 1 {
             if indexPath.row == 0 {

+ 3 - 3
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/BroadcastViewController.swift

@@ -106,13 +106,13 @@ class BroadcastViewController: UITableViewController, UITextFieldDelegate, UITex
             _ = Nexilis.write(message: CoreMessage_TMessageBank.getFormList(p_pin: me, p_last_id: "0"))
         }
         
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.tintColor = .white
-        navigationController?.navigationBar.barTintColor = .mainColor
+        navigationController?.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.isTranslucent = false
         navigationController?.navigationBar.overrideUserInterfaceStyle = .dark
         navigationController?.navigationBar.barStyle = .black
-        navigationController?.view.backgroundColor = .mainColor
+        navigationController?.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
         UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
         let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

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

@@ -156,10 +156,10 @@ class ContactChatViewController: UITableViewController {
         searchController.searchResultsUpdater = self
         searchController.searchBar.autocapitalizationType = .none
         searchController.searchBar.delegate = self
-        searchController.searchBar.barTintColor = .secondaryColor
-        searchController.searchBar.searchTextField.backgroundColor = .secondaryColor
+        searchController.searchBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .secondaryColor
+        searchController.searchBar.searchTextField.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .secondaryColor
         searchController.obscuresBackgroundDuringPresentation = false
-        searchController.searchBar.setMagnifyingGlassColorTo(color: .mainColor)
+        searchController.searchBar.setMagnifyingGlassColorTo(color: self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor)
         searchController.searchBar.tintColor = .mainColor
         searchController.searchBar.searchTextField.attributedPlaceholder = NSAttributedString(string: "Search".localized(), attributes: [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)])
         
@@ -196,7 +196,7 @@ class ContactChatViewController: UITableViewController {
         let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16.0), NSAttributedString.Key.foregroundColor: UIColor.white]
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
         navBarAppearance.titleTextAttributes = attributes
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
@@ -917,7 +917,7 @@ extension ContactChatViewController {
                     let labelNochat = UILabel()
                     labelNochat.text = "There are no conversations".localized()
                     labelNochat.font = .systemFont(ofSize: 13)
-                    labelNochat.textColor = .black
+                    labelNochat.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                     content.addSubview(labelNochat)
                     labelNochat.anchor(centerX: content.centerXAnchor, centerY: content.centerYAnchor)
                     cell.backgroundColor = .clear
@@ -932,7 +932,7 @@ extension ContactChatViewController {
                         let labelNochat = UILabel()
                         labelNochat.text = "There are no conversations".localized()
                         labelNochat.font = .systemFont(ofSize: 13)
-                        labelNochat.textColor = .black
+                        labelNochat.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                         content.addSubview(labelNochat)
                         labelNochat.anchor(centerX: content.centerXAnchor, centerY: content.centerYAnchor)
                         cell.backgroundColor = .clear
@@ -1147,19 +1147,19 @@ extension ContactChatViewController {
                     }
                 }
                 if group.official == "1" && group.parent == "" {
-                    content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 }
                 else if group.isOpen == "1" && group.parent == "" {
                     if self.traitCollection.userInterfaceStyle == .dark {
-                        content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                        content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                     } else {
                         content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4)
                     }
                 } else if group.parent == "" {
                     if self.traitCollection.userInterfaceStyle == .dark {
-                        content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                        content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                     } else {
-                        content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4)
+                        content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                     }
                 } else {
                     content.text = group.name
@@ -1167,7 +1167,7 @@ extension ContactChatViewController {
                 if group.childs.count > 0 {
                     let iconName = (group.isSelected) ? "chevron.up.circle" : "chevron.down.circle"
                     let imageView = UIImageView(image: UIImage(systemName: iconName))
-                    imageView.tintColor = .black
+                    imageView.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                     cell.accessoryView = imageView
                 }
                 else {
@@ -1249,19 +1249,19 @@ extension ContactChatViewController {
                 }
             }
             if group.official == "1" && group.parent == "" {
-                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4)
+                content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
             }
             else if group.isOpen == "1" && group.parent == "" {
                 if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "globe")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "globe")!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 }
             } else if group.parent == "" {
                 if self.traitCollection.userInterfaceStyle == .dark {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!.withTintColor(.white), with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 } else {
-                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4)
+                    content.attributedText = self.set(image: UIImage(systemName: "lock.fill")!, with: "  \(group.name)", size: 15, y: -4, colorText: self.traitCollection.userInterfaceStyle == .dark ? .white : .black)
                 }
             } else {
                 content.text = group.name
@@ -1269,7 +1269,7 @@ extension ContactChatViewController {
             if group.childs.count > 0 {
                 let iconName = (group.isSelected) ? "chevron.up.circle" : "chevron.down.circle"
                 let imageView = UIImageView(image: UIImage(systemName: iconName))
-                imageView.tintColor = .black
+                imageView.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
                 cell.accessoryView = imageView
             }
             else {

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

@@ -23,7 +23,7 @@ class GroupCreateViewController: UITableViewController {
         let attributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
         navBarAppearance.titleTextAttributes = attributes
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance

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

@@ -25,7 +25,7 @@ class GroupDescViewController: UITableViewController {
         navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Save".localized(), style: .plain, target: self, action: #selector(save(sender:)))
         navigationItem.rightBarButtonItem?.isEnabled = false
         descText.text = quote
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         
         descText.addTarget(self, action: #selector(didChanged(sender:)), for: .editingChanged)
         descText.placeholder = "Description".localized()

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

@@ -36,7 +36,7 @@ class GroupMemberViewController: UITableViewController {
 
         title = "Add New Member(s)".localized()
         
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationController?.navigationBar.prefersLargeTitles = true
         
         navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(add(sender:)))

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

@@ -22,7 +22,7 @@ class GroupNameViewController: UITableViewController {
 
         title = "Change Group Name".localized()
         
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Save".localized(), style: .plain, target: self, action: #selector(save(sender:)))
         navigationItem.rightBarButtonItem?.isEnabled = false
         

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

@@ -20,7 +20,7 @@ class GroupTopicViewController: UITableViewController {
         
         title = "Add Topic".localized()
 
-        navigationController?.navigationBar.backgroundColor = .mainColor
+        navigationController?.navigationBar.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
         navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Save".localized(), style: .plain, target: self, action: #selector(save(sender:)))
         navigationItem.rightBarButtonItem?.isEnabled = false
         

+ 9 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ProfileViewController.swift

@@ -29,6 +29,7 @@ public class ProfileViewController: UITableViewController {
     @IBOutlet weak var countFriend: UILabel!
     @IBOutlet weak var labelPrivateAccount: UILabel!
     @IBOutlet weak var labelChangePassword: UILabel!
+    @IBOutlet weak var buttonEditpass: UIButton!
     @IBOutlet weak var labelAcceptCall: UILabel!
     
     private var imageVideoPicker : ImageVideoPicker!
@@ -195,7 +196,7 @@ public class ProfileViewController: UITableViewController {
         profile.isUserInteractionEnabled = true
         profile.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(profileTapped)))
         
-        self.view.backgroundColor = .white
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
         
         if fromRootViewController {
             navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(didTapExit(sender:)))
@@ -204,8 +205,14 @@ public class ProfileViewController: UITableViewController {
         labelPrivateAccount.text = "Private Account Mode".localized()
         labelChangePassword.text = "Change Password".localized()
         labelAcceptCall.text = "Accept Call".localized()
-        buttonHistoryCC.setAttributedTitle(NSAttributedString(string: "Call Center History".localized(), attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]), for: .normal)
+        buttonHistoryCC.setAttributedTitle(NSAttributedString(string: "Call Center History".localized(), attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor : self.traitCollection.userInterfaceStyle == .dark ? UIColor.blackDarkMode : UIColor.white]), for: .normal)
         navigationController?.navigationBar.topItem?.backButtonTitle = "Back".localized()
+        
+        switchPrivateAccount.onTintColor = .mainColor
+        switchAcceptCall.onTintColor = .mainColor
+        buttonEditpass.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
+        buttonHistoryCC.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .secondaryColor : .black
+        
         if let me = UserDefaults.standard.string(forKey: "me"), me == data || flag == Flag.me {
             buttonGroup.removeFromSuperview()
             navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Edit".localized(), style: .plain, target: self, action: #selector(didTapEdit(sender:)))

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

@@ -558,13 +558,13 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             let controller = ScannerViewController()
             let navigationController = UINavigationController(rootViewController: controller)
             navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
+            navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.isTranslucent = false
             let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
+            navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
             navigationController.navigationBar.barStyle = .black
             navigationController.modalPresentationStyle = .custom
@@ -576,7 +576,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             }
             let navigationController = UINavigationController(rootViewController: controller)
             navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
+            navigationController.navigationBar.barTintColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             navigationController.navigationBar.isTranslucent = false
             navigationController.navigationBar.overrideUserInterfaceStyle = .dark
             navigationController.navigationBar.barStyle = .black
@@ -584,7 +584,7 @@ public class SettingTableViewController: UITableViewController, UIGestureRecogni
             UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
             let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
             navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
+            navigationController.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : .mainColor
             self.present(navigationController, animated: true)
         } else if item.title == "Backup & Restore".localized() {
             let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "backupRestore") as! BackupRestoreView

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

@@ -22,7 +22,7 @@ public class SignUpSignIn: UIViewController {
     public override func viewDidLoad() {
         super.viewDidLoad()
 
-        self.view.backgroundColor = .white
+        self.view.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .black : .white
 
         self.title = "Sign-Up/Sign-In".localized()
         descSignUpSignIn.text = "Please enter your nickname or email address and your password".localized()
@@ -37,6 +37,8 @@ public class SignUpSignIn: UIViewController {
         showPasswordButton.setImage(UIImage(systemName: "eye.slash.fill"), for: .normal)
         usernameField.placeholder = "Your Nickname".localized() + "/" + "Email".localized()
         passwordField.placeholder = "Password".localized()
+        usernameField.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor
+        passwordField.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor
         usernameField.addTarget(self, action: #selector(checkUsername(_:)), for: .editingChanged)
         
         showPasswordButton.addTarget(self, action: #selector(showPassword), for: .touchUpInside)

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Streaming/SeminarListViewController.swift

@@ -45,7 +45,7 @@ class SeminarListViewController: UIViewController {
         let attributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
         let navBarAppearance = UINavigationBarAppearance()
         navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = UIColor.mainColor
+        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
         navBarAppearance.titleTextAttributes = attributes
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance