Sfoglia il codice sorgente

update FB and Prefs

alqindiirsyam 1 anno fa
parent
commit
2665c34e6f

+ 16 - 39
appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift

@@ -38,10 +38,6 @@ class PrefsUtil {
         return PrefsUtil.CUSTOM_TAB
     }
     
-    static func setCustomTab(cust: String){
-        UserDefaults.standard.set(cust, forKey: "custom_tab")
-    }
-    
     static func getURLFirstTab() -> String? {
         return UserDefaults.standard.string(forKey: "app_builder_url_first_tab")
     }
@@ -71,27 +67,20 @@ class PrefsUtil {
         return PrefsUtil.getURLBase() + "dashboardv2/uploads/fb_icon/" + PrefsUtil.getIconDock()
     }
     
-    static func setURLFirstTab(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_url_first_tab")
+    static func getURLPrivacyPolicy() -> String {
+        return UserDefaults.standard.string(forKey: "app_builder_url_privacy_policy") ?? "https://newuniverse.io/privacypolicy"
     }
     
-    static func setURLThirdTab(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_url_third_tab")
-    }
-    static func setURLBase(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_url_base")
-    }
-    static func setURLQMS(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_url_qms")
-    }
-    static func setIconDock(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_icon_dock")
+    static func getEnablePrivacyPolicy() -> Bool {
+        return UserDefaults.standard.bool(forKey: "app_builder_enable_privacy_policy")
     }
-    static func setIconSS(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_icon_ss")
+    
+    static func getAgreePrivacyPolicy() -> Bool {
+        return UserDefaults.standard.bool(forKey: "agree_privacy_policy")
     }
-    static func setBackground(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_background")
+    
+    static func setAgreePrivacyPolicy(value: Bool){
+        UserDefaults.standard.set(value, forKey: "agree_privacy_policy")
     }
     static func getTerms() -> Bool {
         return UserDefaults.standard.bool(forKey: "terms_app")
@@ -101,28 +90,16 @@ class PrefsUtil {
         UserDefaults.standard.set(value, forKey: "terms_app")
     }
     
-    static func getURLPrivacyPolicy() -> String {
-        return UserDefaults.standard.string(forKey: "app_builder_url_privacy_policy") ?? "https://newuniverse.io/privacypolicy"
-    }
-    
-    static func setURLPrivacyPolicy(value: String){
-        UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
-    }
-    
-    static func getEnablePrivacyPolicy() -> Bool {
-        return UserDefaults.standard.bool(forKey: "app_builder_enable_privacy_policy")
+    static func getCustomButtons() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_custom_buttons") ?? ""
     }
     
-    static func setEnablePrivacyPolicy(value: Bool){
-        UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
+    static func getCustomFBIcon() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_button_icon") ?? ""
     }
     
-    static func getAgreePrivacyPolicy() -> Bool {
-        return UserDefaults.standard.bool(forKey: "agree_privacy_policy")
-    }
-    
-    static func setAgreePrivacyPolicy(value: Bool){
-        UserDefaults.standard.set(value, forKey: "agree_privacy_policy")
+    static func getIconCenterAnim() -> String? {
+        UserDefaults.standard.string(forKey: "fb_icon_center_anim")
     }
     
 }

+ 48 - 6
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -440,12 +440,22 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         //print("buttonCenterY \(buttonCenterY)")
         ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
         if !PrefsUtil.getIconDock().isEmpty {
-            DispatchQueue.global().async {
-                ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
-                    guard let data = data, error == nil else { return }
-                    // always update the UI from the main thread
-                    DispatchQueue.main.async() {
-                        ViewController.middleButton.setBackgroundImage(UIImage(data: data), for: .normal)
+            if PrefsUtil.getIconDock().contains(".gif") {
+                ViewController.middleButton.sd_setBackgroundImage(with: URL(string: PrefsUtil.getIconCenterAnim()!), for: .normal, completed: { (image, error, cacheType, imageURL) in
+                    if let error = error {
+                        print("Error loading image: \(error.localizedDescription)")
+                    } else {
+                        print("Image loaded successfully")
+                    }
+                })
+            } else {
+                DispatchQueue.global().async {
+                    ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
+                        guard let data = data, error == nil else { return }
+                        // always update the UI from the main thread
+                        DispatchQueue.main.async() {
+                            ViewController.middleButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                        }
                     }
                 }
             }
@@ -1025,6 +1035,38 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         if datePullFB == nil || Int(Date().timeIntervalSince(datePullFB!)) >= 60 {
             datePullFB = Date()
             DispatchQueue.global().async {
+                if !PrefsUtil.getCustomButtons().isEmpty {
+                    DispatchQueue.main.async { [self] in
+                        let customButtons = PrefsUtil.getCustomButtons().components(separatedBy: ",")
+                        let customIcons = PrefsUtil.getCustomFBIcon().components(separatedBy: ",")
+                        for i in 0..<customButtons.count {
+                            let package_id = customButtons[i]
+                            let app_id = ""
+                            let icon = customIcons[i]
+                            listPullFB.append("\(package_id)|\(app_id)")
+                            DispatchQueue.global().async {
+                                ViewController.getDataImageFromUrl(from: URL(string: "https://nexilis.io/dashboardv2/uploads/fb_icon/\(icon)")!) { data, response, error in
+                                    guard let data = data, error == nil else { return }
+                                    // always update the UI from the main thread
+                                    DispatchQueue.main.async() {
+                                        if i == 0 {
+                                            ViewController.chatButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                                        } else if i == 1 {
+                                            ViewController.callButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                                        }  else if i == 2 {
+                                            ViewController.ccButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                                        }  else if i == 3 {
+                                            ViewController.postButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                                        }  else if i == 4 {
+                                            ViewController.streamingButton.setBackgroundImage(UIImage(data: data), for: .normal)
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    return
+                }
                 if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.pullFloatingButton(), timeout: 30 * 1000) {
                     if response.isOk() {
                         let data = response.getBody(key: CoreMessage_TMessageKey.DATA, default_value: "")

+ 1 - 1
appbuilder-ios/DigiXLite/DigiXLite/Source/DigiX.swift

@@ -221,7 +221,7 @@ public class DigiX: NSObject {
                         var notNull = false
                         while !notNull {
                             viewController = UIApplication.shared.windows.first?.rootViewController
-                            if viewController != nil {
+                            if viewController != nil && Utils.getFinishInitPrefsr() {
                                 notNull = true
                             }
                         }

+ 1 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/Extension.swift

@@ -338,6 +338,7 @@ extension NSObject {
             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "TASK_PIC", _where: "")
             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "TASK_DETAIL", _where: "")
         })
+        Utils.setFinishInitPrefs(value: false)
     }
     
 }

+ 126 - 36
appbuilder-ios/DigiXLite/DigiXLite/Source/FloatingButton/FloatingButton.swift

@@ -35,6 +35,19 @@ public class FloatingButton: UIView {
     var datePull: Date?
     
     var panGesture: UIPanGestureRecognizer?
+    var defaultWidthFB = (UIScreen.main.bounds.height * 0.5) / 7.5
+    var defaultHeightFB = (UIScreen.main.bounds.height * 0.5) / 7.5
+    let defaultWidthHeightMenuFB = (UIScreen.main.bounds.height * 0.45) / 7.5
+    let widthFBAnim = (UIScreen.main.bounds.height * 1) / 7.5
+    let heightFBAnim = (UIScreen.main.bounds.height * 1) / 7.5
+    
+    var countMenuFB: CGFloat = 5 {
+        didSet {
+            if isShow {
+                show(isShow: isShow)
+            }
+        }
+    }
     
     public weak var mySettingDelegate: SettingMABDelegate?
     
@@ -51,24 +64,41 @@ public class FloatingButton: UIView {
     }
     
     private func commonInit() {
-        backgroundColor = .clear
-        frame = CGRect(x: UIScreen.main.bounds.width - 50, y: (UIScreen.main.bounds.height / 2) - 50, width: 50.0, height: 50.0)
-        
         panGesture = UIPanGestureRecognizer(target: self, action: #selector(draggedView(_:)))
         addGestureRecognizer(panGesture!)
         
         nexilis_button = UIImageView()
         nexilis_button.translatesAutoresizingMaskIntoConstraints = false
         nexilis_button.isUserInteractionEnabled = true
-        if Utils.getIconDock() != nil {
-            let dataImage = try? Data(contentsOf: URL(string: Utils.getUrlDock()!)!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
-            if dataImage != nil {
-                nexilis_button.image = UIImage(data: dataImage!)
+        if !Utils.getIconDock().isEmpty {
+            var dataImage: Data?
+            if Utils.getIconDock().contains(".gif") {
+                defaultWidthFB = widthFBAnim
+                defaultHeightFB = heightFBAnim
+                nexilis_button.sd_setImage(with: URL(string: Utils.getIconCenterAnim()!)) { [self] (image, error, cacheType, imageURL) in
+                    if let error = error {
+                        //print("Error loading GIF: \(error.localizedDescription)")
+                    } else {
+                        // Configure the animation
+                        nexilis_button.animationImages = image?.images
+                        nexilis_button.animationDuration = image?.duration ?? 0.0
+                        nexilis_button.animationRepeatCount = 0
+                        nexilis_button.startAnimating()
+                    }
+                }
+            } else {
+                dataImage = try? Data(contentsOf: URL(string: Utils.getUrlDock()!)!)
+                if dataImage != nil {
+                    nexilis_button.image = UIImage(data: dataImage!)
+                }
             }
         } else {
             nexilis_button.image = UIImage(named: "pb_button", in: Bundle.resourceBundle(for: DigiX.self), with: nil)
         }
         
+        backgroundColor = .clear
+        frame = CGRect(x: UIScreen.main.bounds.width - defaultWidthFB, y: (UIScreen.main.bounds.height / 2) - defaultHeightFB, width: defaultWidthFB, height: defaultHeightFB)
+        
         let qmeraTap = UITapGestureRecognizer(target: self, action: #selector(qmeraTap))
         qmeraTap.numberOfTouchesRequired = 1
         nexilis_button.addGestureRecognizer(qmeraTap)
@@ -78,24 +108,30 @@ public class FloatingButton: UIView {
         
         addSubview(nexilis_button)
         
-        nexilis_button.widthAnchor.constraint(equalToConstant: 50.0).isActive = true
-        nexilis_button.heightAnchor.constraint(equalToConstant: 50.0).isActive = true
-        nexilis_button.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
+        nexilis_button.widthAnchor.constraint(equalToConstant: defaultWidthFB).isActive = true
+        nexilis_button.heightAnchor.constraint(equalToConstant: defaultHeightFB).isActive = true
+        nexilis_button.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
         nexilis_button.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
         
         scrollView = UIScrollView()
         scrollView.translatesAutoresizingMaskIntoConstraints = false
-        scrollView.layer.borderWidth = 1.0
-        scrollView.layer.borderColor = UIColor.white.cgColor
-        scrollView.layer.cornerRadius = 8.0
-        scrollView.layer.masksToBounds = true
-        scrollView.backgroundColor = .black.withAlphaComponent(0.25)
+//        scrollView.layer.borderWidth = 1.0
+//        scrollView.layer.borderColor = UIColor.white.cgColor
+//        scrollView.layer.cornerRadius = 8.0
+//        scrollView.layer.masksToBounds = true
+//        scrollView.backgroundColor = .black.withAlphaComponent(0.25)
         addSubview(scrollView)
         
-        scrollView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
-        scrollView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
+        scrollView.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB + 10).isActive = true
         scrollView.topAnchor.constraint(equalTo: topAnchor).isActive = true
-        scrollView.bottomAnchor.constraint(equalTo: nexilis_button.topAnchor).isActive = true
+        if Utils.getIconDock().contains(".gif") {
+            scrollView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
+            scrollView.leftAnchor.constraint(equalTo: nexilis_button.rightAnchor, constant: -20).isActive = true
+            scrollView.isHidden = true
+        } else {
+            scrollView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
+            scrollView.bottomAnchor.constraint(equalTo: nexilis_button.topAnchor).isActive = true
+        }
         
         groupView = UIStackView()
         groupView.translatesAutoresizingMaskIntoConstraints = false
@@ -104,7 +140,7 @@ public class FloatingButton: UIView {
 
         scrollView.addSubview(groupView)
 
-        groupView.widthAnchor.constraint(equalToConstant: 40).isActive = true
+        groupView.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
         groupView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 5).isActive = true
         groupView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: -5).isActive = true
         groupView.leftAnchor.constraint(equalTo: scrollView.leftAnchor, constant: 6).isActive = true
@@ -134,6 +170,38 @@ public class FloatingButton: UIView {
             return
         }
         DispatchQueue.global().async { [self] in
+            if !Utils.getCustomButtons().isEmpty {
+                DispatchQueue.main.async { [self] in
+                    let customButtons = Utils.getCustomButtons().components(separatedBy: ",")
+                    let customIcons = Utils.getCustomFBIcon().components(separatedBy: ",")
+                    countMenuFB = CGFloat(customButtons.count > 5 ? 5 : customButtons.count)
+                    for i in 0..<customButtons.count {
+                        let package_id = customButtons[i]
+                        let app_id = ""
+                        let icon = customIcons[i]
+                        let newButton = UIButton()
+                        newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
+                        newButton.translatesAutoresizingMaskIntoConstraints = false
+                        DispatchQueue.global().async {
+                            let data = try? Data(contentsOf: URL(string: "https://DigiX.io/dashboardv2/uploads/fb_icon/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
+                            DispatchQueue.main.async {
+                                if data != nil {
+                                    newButton.setImage(UIImage(data: data!), for: .normal)
+                                }
+                            }
+                        }
+                        groupView.addArrangedSubview(newButton)
+                        newButton.restorationIdentifier = package_id
+                        newButton.accessibilityIdentifier = app_id
+                        newButton.addTarget(self, action: #selector(fbTap), for: .touchUpOutside)
+                    }
+                    let countSubviewsAfter = groupView.subviews.count
+                    if countSubviewsAfter <= 4 {
+                        scrollView.isScrollEnabled = false
+                    }
+                }
+                return
+            }
             if let response = DigiX.writeSync(message: CoreMessage_TMessageBank.pullFloatingButton(), timeout: 30 * 1000){
                 if response.isOk() {
                     let data = response.getBody(key: CoreMessage_TMessageKey.DATA, default_value: "")
@@ -142,14 +210,16 @@ public class FloatingButton: UIView {
                             DispatchQueue.main.async { [self] in
                                 groupView.subviews.forEach({ $0.removeFromSuperview() })
                                 if jsonArray.count == 0 {
+                                    countMenuFB = CGFloat(4)
                                     getDefaultButton()
                                 } else {
+                                    countMenuFB = CGFloat(jsonArray.count > 5 ? 5 : jsonArray.count)
                                     for json in jsonArray {
                                         let package_id = json["package_id"] as! String
                                         let app_id = (json["app_id"] as? String) ?? ""
                                         let icon = (json["icon"] as? String) ?? ""
                                         let newButton = UIButton()
-                                        newButton.heightAnchor.constraint(equalToConstant: 40).isActive = true
+                                        newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
                                         newButton.translatesAutoresizingMaskIntoConstraints = false
                                         if icon.isEmpty {
                                             var indexTap = 0
@@ -211,14 +281,14 @@ public class FloatingButton: UIView {
     
     func getDefaultButton() {
         button_fb1 = UIButton()
-        button_fb1.heightAnchor.constraint(equalToConstant: 40).isActive = true
+        button_fb1.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
         button_fb1.translatesAutoresizingMaskIntoConstraints = false
         button_fb1.setImage(UIImage(named: "pb_button_cc", in: Bundle.resourceBundle(for: DigiX.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb1)
         button_fb1.addTarget(self, action: #selector(fb1Tap), for: .touchUpOutside)
         
         button_fb2 = UIButton()
-        button_fb2.heightAnchor.constraint(equalToConstant: 40).isActive = true
+        button_fb2.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
         button_fb2.translatesAutoresizingMaskIntoConstraints = false
         button_fb2.setImage(UIImage(named: "pb_button_chat", in: Bundle.resourceBundle(for: DigiX.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb2)
@@ -226,14 +296,14 @@ public class FloatingButton: UIView {
         checkCounter()
         
         button_fb3 = UIButton()
-        button_fb3.heightAnchor.constraint(equalToConstant: 40).isActive = true
+        button_fb3.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
         button_fb3.translatesAutoresizingMaskIntoConstraints = false
         button_fb3.setImage(UIImage(named: "pb_button_call", in: Bundle.resourceBundle(for: DigiX.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb3)
         button_fb3.addTarget(self, action: #selector(fb3Tap), for: .touchUpOutside)
         
         button_fb4 = UIButton()
-        button_fb4.heightAnchor.constraint(equalToConstant: 40).isActive = true
+        button_fb4.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
         button_fb4.translatesAutoresizingMaskIntoConstraints = false
         button_fb4.setImage(UIImage(named: "pb_button_stream", in: Bundle.resourceBundle(for: DigiX.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb4)
@@ -245,7 +315,7 @@ public class FloatingButton: UIView {
         let widthScreen = size.width
         let heightScreen = size.height
         let minimumx = (widthScreen + 30) - widthScreen
-        let maximumx = widthScreen - 30
+        var maximumx = widthScreen - 30
         let translation = sender.translation(in: self)
         var xPos = center.x + translation.x
         var yPos = center.y + translation.y
@@ -257,8 +327,14 @@ public class FloatingButton: UIView {
             xPos = maximumx
         }
         if(isShow) {
-            let minimumy = CGFloat(120.5) //30
-            let maximumy = heightScreen - 100
+            if Utils.getIconDock().contains(".gif") {
+                maximumx = widthScreen - 10 - defaultWidthHeightMenuFB
+                if (xPos > maximumx) {
+                    xPos = maximumx
+                }
+            }
+            let minimumy = (defaultWidthHeightMenuFB * countMenuFB) - defaultHeightFB - 10
+            let maximumy = heightScreen - defaultHeightFB - 10
             if(yPos < minimumy) {
                 yPos = minimumy
             }
@@ -266,8 +342,8 @@ public class FloatingButton: UIView {
                 yPos = maximumy
             }
         } else {
-            let minimumy = (heightScreen + 50) - heightScreen
-            let maximumy = heightScreen - 20
+            let minimumy = defaultHeightFB - 50
+            let maximumy = heightScreen - defaultHeightFB + 50
             if(yPos < minimumy) {
                 yPos = minimumy
             }
@@ -402,7 +478,7 @@ public class FloatingButton: UIView {
         if self.frame.origin.x < UIScreen.main.bounds.width / 2 - 30 {
             self.frame.origin.x = 0
         } else {
-            self.frame.origin.x = UIScreen.main.bounds.width - 50
+            self.frame.origin.x = UIScreen.main.bounds.width - defaultWidthFB
         }
     }
     
@@ -413,13 +489,23 @@ public class FloatingButton: UIView {
             if indicatorCounterFBBig.isDescendant(of: nexilis_button) {
                 indicatorCounterFBBig.isHidden = true
             }
-            let height = CGFloat(217) //40
-            var yPosition = frame.origin.y - height + 50
+            var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
+            var width = frame.width
+            var xPosition = frame.origin.x
+            if Utils.getIconDock().contains(".gif") {
+                height = CGFloat((defaultWidthHeightMenuFB * (countMenuFB - 2)) + defaultHeightFB - 5)
+                width = frame.width + defaultWidthHeightMenuFB
+                if xPosition > UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB {
+                    xPosition = UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB
+                }
+                scrollView.isHidden = false
+            }
+            var yPosition = frame.origin.y - height + defaultHeightFB
             if yPosition <= 25 {
                 lastPosY = frame.origin.y
                 yPosition = 25
             }
-            frame = CGRect(x: frame.origin.x, y: yPosition, width: frame.width, height: height)
+            frame = CGRect(x: xPosition, y: yPosition, width: width, height: height)
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: { [self] in
                 if isShow {
                     let countSubviewsAfter = groupView.subviews.count
@@ -432,12 +518,16 @@ public class FloatingButton: UIView {
             if indicatorCounterFBBig.isDescendant(of: nexilis_button) {
                 indicatorCounterFBBig.isHidden = false
             }
-            let height = CGFloat(217) //40
-            var yPosition = frame.origin.y + height - 50
+            var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
+            if Utils.getIconDock().contains(".gif") {
+                height = CGFloat((defaultWidthHeightMenuFB * 3) + defaultHeightFB - 5)
+                scrollView.isHidden = true
+            }
+            var yPosition = frame.origin.y + height - defaultHeightFB
             if lastPosY != nil {
                 yPosition = lastPosY!
             }
-            frame = CGRect(x: frame.origin.x, y: yPosition, width: frame.width, height: frame.width)
+            frame = CGRect(x: frame.origin.x, y: yPosition, width: defaultWidthFB, height: defaultHeightFB)
         }
     }
 }

+ 21 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/IncomingThread.swift

@@ -223,6 +223,27 @@ class IncomingThread {
                     if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_center_anim" {
                         Utils.setIconCenterAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
                     }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_ac_theme" {
+                        Utils.setACTheme(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_url" {
+                        Utils.setButtonURL(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_buttons" {
+                        Utils.setCustomButtons(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_config_mode" {
+                        Utils.setConfigModeFB(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_icon" {
+                        Utils.setCustomFBIcon(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
                 }
             }
         }

+ 64 - 11
appbuilder-ios/DigiXLite/DigiXLite/Source/Utils.swift

@@ -54,13 +54,6 @@ public final class Utils {
         UserDefaults.standard.set(value, forKey: "is_change_profile")
     }
     
-    public static func sGetCurrentDateTime(sFormat: String!) -> String! {
-        let todaysDate = NSDate()
-        let dateFormatter = DateFormatter()
-        dateFormatter.dateFormat = sFormat
-        return dateFormatter.string(from: todaysDate as Date)
-    }
-    
     static func setIconCenterAnim(value: String){
         UserDefaults.standard.set(value, forKey: "fb_icon_center_anim")
     }
@@ -76,31 +69,91 @@ public final class Utils {
     static func setURLThirdTab(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_third_tab")
     }
+    
     static func setURLBase(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_base")
     }
+    
     static func setURLQMS(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_qms")
     }
+    
     static func setIconDock(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_icon_dock")
     }
+    
     static func setIconSS(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_icon_ss")
     }
+    
     static func setBackground(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_background")
     }
+    
     static func setURLPrivacyPolicy(value: String){
         UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
     }
+    
     static func setEnablePrivacyPolicy(value: Bool){
         UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
     }
+    
     static func setCustomTab(cust: String){
         UserDefaults.standard.set(cust, forKey: "custom_tab")
     }
     
+    static func setACTheme(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_ac_theme")
+    }
+    
+    static func setButtonURL(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_button_url")
+    }
+    
+    static func setCustomButtons(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_custom_buttons")
+    }
+    
+    static func getCustomButtons() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_button_icon") ?? ""
+    }
+    
+    static func setCustomFBIcon(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_button_icon")
+    }
+    
+    static func getCustomFBIcon() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_button_icon") ?? ""
+    }
+    
+    static func setEnableMobileBuilder(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_enable_mobile_builder")
+    }
+    
+    static func setFinishInitPrefs(value: Bool){
+        UserDefaults.standard.set(value, forKey: "finish_init_prefs")
+    }
+    
+    static func getFinishInitPrefsr() -> Bool {
+        UserDefaults.standard.bool(forKey: "finish_init_prefs")
+    }
+    
+    static func setConfigModeFB(value: String) {
+        UserDefaults.standard.set(value, forKey: "fb_config_mode")
+    }
+    
+    static func getConfigModeFB() -> String {
+        UserDefaults.standard.string(forKey: "fb_config_mode") ?? "1"
+    }
+    
+    
+    public static func sGetCurrentDateTime(sFormat: String!) -> String! {
+        let todaysDate = NSDate()
+        let dateFormatter = DateFormatter()
+        dateFormatter.dateFormat = sFormat
+        return dateFormatter.string(from: todaysDate as Date)
+    }
+    
 //    public static func getMD5(string: String) -> Data {
 //        let length = Int(CC_MD5_DIGEST_LENGTH)
 //        let messageData = string.data(using:.utf8)!
@@ -165,15 +218,15 @@ public final class Utils {
     }
     
     static func getURLBase() -> String? {
-        return UserDefaults.standard.string(forKey: "app_builder_url_base")
+        return UserDefaults.standard.string(forKey: "app_builder_url_base") ?? "https://newuniverse.io/"
     }
     
-    static func getIconDock() -> String? {
-        return UserDefaults.standard.string(forKey: "app_builder_icon_dock")
+    static func getIconDock() -> String {
+        return UserDefaults.standard.string(forKey: "app_builder_icon_dock") ?? ""
     }
     
     static func getUrlDock() -> String? {
-        return Utils.getURLBase()! + "dashboardv2/uploads/fb_icon/" + Utils.getIconDock()!
+        return Utils.getURLBase()! + "dashboardv2/uploads/fb_icon/" + Utils.getIconDock()
     }
     
     static func setDefaultCC(value: String){

+ 1 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Extension.swift

@@ -338,6 +338,7 @@ extension NSObject {
             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "TASK_PIC", _where: "")
             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "TASK_DETAIL", _where: "")
         })
+        Utils.setFinishInitPrefs(value: false)
     }
     
 }

+ 47 - 5
appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -41,6 +41,14 @@ public class FloatingButton: UIView {
     let widthFBAnim = (UIScreen.main.bounds.height * 1) / 7.5
     let heightFBAnim = (UIScreen.main.bounds.height * 1) / 7.5
     
+    var countMenuFB: CGFloat = 5 {
+        didSet {
+            if isShow {
+                show(isShow: isShow)
+            }
+        }
+    }
+    
     public weak var mySettingDelegate: SettingMABDelegate?
     
     public var isShow: Bool = false
@@ -162,6 +170,38 @@ public class FloatingButton: UIView {
             return
         }
         DispatchQueue.global().async { [self] in
+            if !Utils.getCustomButtons().isEmpty {
+                DispatchQueue.main.async { [self] in
+                    let customButtons = Utils.getCustomButtons().components(separatedBy: ",")
+                    let customIcons = Utils.getCustomFBIcon().components(separatedBy: ",")
+                    countMenuFB = CGFloat(customButtons.count > 5 ? 5 : customButtons.count)
+                    for i in 0..<customButtons.count {
+                        let package_id = customButtons[i]
+                        let app_id = ""
+                        let icon = customIcons[i]
+                        let newButton = UIButton()
+                        newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
+                        newButton.translatesAutoresizingMaskIntoConstraints = false
+                        DispatchQueue.global().async {
+                            let data = try? Data(contentsOf: URL(string: "https://nexilis.io/dashboardv2/uploads/fb_icon/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
+                            DispatchQueue.main.async {
+                                if data != nil {
+                                    newButton.setImage(UIImage(data: data!), for: .normal)
+                                }
+                            }
+                        }
+                        groupView.addArrangedSubview(newButton)
+                        newButton.restorationIdentifier = package_id
+                        newButton.accessibilityIdentifier = app_id
+                        newButton.addTarget(self, action: #selector(fbTap), for: .touchUpOutside)
+                    }
+                    let countSubviewsAfter = groupView.subviews.count
+                    if countSubviewsAfter <= 4 {
+                        scrollView.isScrollEnabled = false
+                    }
+                }
+                return
+            }
             if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.pullFloatingButton(), timeout: 30 * 1000){
                 if response.isOk() {
                     let data = response.getBody(key: CoreMessage_TMessageKey.DATA, default_value: "")
@@ -170,8 +210,10 @@ public class FloatingButton: UIView {
                             DispatchQueue.main.async { [self] in
                                 groupView.subviews.forEach({ $0.removeFromSuperview() })
                                 if jsonArray.count == 0 {
+                                    countMenuFB = CGFloat(4)
                                     getDefaultButton()
                                 } else {
+                                    countMenuFB = CGFloat(jsonArray.count > 5 ? 5 : jsonArray.count)
                                     for json in jsonArray {
                                         let package_id = json["package_id"] as! String
                                         let app_id = (json["app_id"] as? String) ?? ""
@@ -286,12 +328,12 @@ public class FloatingButton: UIView {
         }
         if(isShow) {
             if Utils.getIconDock().contains(".gif") {
-                maximumx = widthScreen - 30 - defaultWidthHeightMenuFB
+                maximumx = widthScreen - 10 - defaultWidthHeightMenuFB
                 if (xPos > maximumx) {
                     xPos = maximumx
                 }
             }
-            let minimumy = (defaultWidthHeightMenuFB * 5) - defaultHeightFB
+            let minimumy = (defaultWidthHeightMenuFB * countMenuFB) - defaultHeightFB - 10
             let maximumy = heightScreen - defaultHeightFB - 10
             if(yPos < minimumy) {
                 yPos = minimumy
@@ -447,11 +489,11 @@ public class FloatingButton: UIView {
             if indicatorCounterFBBig.isDescendant(of: nexilis_button) {
                 indicatorCounterFBBig.isHidden = true
             }
-            var height = CGFloat((defaultWidthHeightMenuFB * 5) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
+            var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
             var width = frame.width
             var xPosition = frame.origin.x
             if Utils.getIconDock().contains(".gif") {
-                height = CGFloat((defaultWidthHeightMenuFB * 3) + defaultHeightFB - 5)
+                height = CGFloat((defaultWidthHeightMenuFB * (countMenuFB - 2)) + defaultHeightFB - 5)
                 width = frame.width + defaultWidthHeightMenuFB
                 if xPosition > UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB {
                     xPosition = UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB
@@ -476,7 +518,7 @@ public class FloatingButton: UIView {
             if indicatorCounterFBBig.isDescendant(of: nexilis_button) {
                 indicatorCounterFBBig.isHidden = false
             }
-            var height = CGFloat((defaultWidthHeightMenuFB * 5) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
+            var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
             if Utils.getIconDock().contains(".gif") {
                 height = CGFloat((defaultWidthHeightMenuFB * 3) + defaultHeightFB - 5)
                 scrollView.isHidden = true

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

@@ -223,7 +223,31 @@ class IncomingThread {
                     if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_center_anim" {
                         Utils.setIconCenterAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
                     }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_ac_theme" {
+                        Utils.setACTheme(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_url" {
+                        Utils.setButtonURL(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_buttons" {
+                        Utils.setCustomButtons(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_config_mode" {
+                        Utils.setConfigModeFB(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_button_icon" {
+                        Utils.setCustomFBIcon(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
                 }
+                Utils.setFinishInitPrefs(value: true)
+            } else {
+                Utils.setFinishInitPrefs(value: true)
             }
         }
         ack(message: message)

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

@@ -221,7 +221,7 @@ public class Nexilis: NSObject {
                         var notNull = false
                         while !notNull {
                             viewController = UIApplication.shared.windows.first?.rootViewController
-                            if viewController != nil {
+                            if viewController != nil && Utils.getFinishInitPrefsr() {
                                 notNull = true
                             }
                         }

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

@@ -69,31 +69,84 @@ public final class Utils {
     static func setURLThirdTab(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_third_tab")
     }
+    
     static func setURLBase(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_base")
     }
+    
     static func setURLQMS(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_url_qms")
     }
+    
     static func setIconDock(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_icon_dock")
     }
+    
     static func setIconSS(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_icon_ss")
     }
+    
     static func setBackground(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_background")
     }
+    
     static func setURLPrivacyPolicy(value: String){
         UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
     }
+    
     static func setEnablePrivacyPolicy(value: Bool){
         UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
     }
+    
     static func setCustomTab(cust: String){
         UserDefaults.standard.set(cust, forKey: "custom_tab")
     }
     
+    static func setACTheme(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_ac_theme")
+    }
+    
+    static func setButtonURL(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_button_url")
+    }
+    
+    static func setCustomButtons(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_custom_buttons")
+    }
+    
+    static func getCustomButtons() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_button_icon") ?? ""
+    }
+    
+    static func setCustomFBIcon(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_button_icon")
+    }
+    
+    static func getCustomFBIcon() -> String {
+        UserDefaults.standard.string(forKey: "app_builder_button_icon") ?? ""
+    }
+    
+    static func setEnableMobileBuilder(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_enable_mobile_builder")
+    }
+    
+    static func setFinishInitPrefs(value: Bool){
+        UserDefaults.standard.set(value, forKey: "finish_init_prefs")
+    }
+    
+    static func getFinishInitPrefsr() -> Bool {
+        UserDefaults.standard.bool(forKey: "finish_init_prefs")
+    }
+    
+    static func setConfigModeFB(value: String) {
+        UserDefaults.standard.set(value, forKey: "fb_config_mode")
+    }
+    
+    static func getConfigModeFB() -> String {
+        UserDefaults.standard.string(forKey: "fb_config_mode") ?? "1"
+    }
+    
+    
     public static func sGetCurrentDateTime(sFormat: String!) -> String! {
         let todaysDate = NSDate()
         let dateFormatter = DateFormatter()