소스 검색

update move tab to setting if exist in tab

alqindiirsyam 2 년 전
부모
커밋
effaddd71e

+ 9 - 0
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -122,6 +122,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
                 if response.mBodies[CoreMessage_TMessageKey.ERRCOD] == "00" {
                     let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
                     if let json = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: []) as? [[String: Any?]] {
+                        UserDefaults.standard.removeObject(forKey: "app_builder_url_first_tab")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_url_third_tab")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_custom_tab")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_url_base")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_url_qms")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_dock")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_ss")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_background")
+                        UserDefaults.standard.removeObject(forKey: "app_builder_compressor")
                         for j in json {
                             if let firstTab = j["app_builder_url_first_tab"] as? String {
                                 PrefsUtil.setURLFirstTab(value: firstTab)

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

@@ -250,6 +250,9 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         backgroundImage.image = nil
         DispatchQueue.global().async {
             if let listBg = PrefsUtil.getBackground() {
+                if listBg.isEmpty {
+                   return
+                }
                 var bgChoosen = ""
                 let arrayBg = listBg.split(separator: ",")
                 bgChoosen = String(arrayBg[Int.random(in: 0..<arrayBg.count)])

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

@@ -303,6 +303,9 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         backgroundImage.backgroundColor = .white
         DispatchQueue.global().async {
             if let listBg = PrefsUtil.getBackground() {
+                if listBg.isEmpty {
+                   return
+                }
                 var bgChoosen = ""
                 let arrayBg = listBg.split(separator: ",")
                 bgChoosen = String(arrayBg[Int.random(in: 0..<arrayBg.count)])

+ 21 - 7
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -50,8 +50,6 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     let term = "Terms of Service.".localized()
     var firstLoad = true
     
-    var notDoubleCall: Date?
-    
     public static var def: ViewController?
 
     override func viewDidLoad() {
@@ -176,13 +174,12 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     }
     
     func settingDelegate() {
-        if notDoubleCall != nil && Int(Date().timeIntervalSince(notDoubleCall!)) < 1 {
-            return
-        }
-        notDoubleCall = Date()
-        if let vc = fourthTab == nil ? storyboard?.instantiateViewController(withIdentifier: "fourthTabVC") as? FourthTabViewController : fourthTab {
+        if self.viewControllers?.firstIndex(of: fourthTab!) == nil {
+            let vc = fourthTab!
             vc.notInTab = true
             self.navigationController?.show(vc, sender: nil)
+        } else {
+            self.selectedIndex = (self.viewControllers?.firstIndex(of: fourthTab!))!
         }
     }
     
@@ -347,6 +344,8 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         ViewController.middleButton.layer.masksToBounds = false
         ViewController.middleButton.layer.cornerRadius = 4.0
         ViewController.middleButton.addTarget(self, action: #selector(middleBtnTapped), for: .touchUpInside)
+        let longPressMidButton = UILongPressGestureRecognizer(target: self, action: #selector(longPressMidBtn(gestureRecognizer:)))
+        ViewController.middleButton.addGestureRecognizer(longPressMidButton)
         self.view.addSubview(ViewController.chatButton)
         self.view.addSubview(ViewController.callButton)
         self.view.addSubview(ViewController.ccButton)
@@ -357,6 +356,18 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         ViewController.hideDockedButton()
     }
     
+    @objc func longPressMidBtn(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state == .began {
+            if self.viewControllers?.firstIndex(of: fourthTab!) == nil {
+                let vc = fourthTab!
+                vc.notInTab = true
+                self.navigationController?.show(vc, sender: nil)
+            } else {
+                self.selectedIndex = (self.viewControllers?.firstIndex(of: fourthTab!))!
+            }
+        }
+    }
+    
     func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
         if(viewController == secondTab){
             if(!ViewController.checkIsChangePerson()){
@@ -455,6 +466,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             viewWelcome.backgroundColor = .white
             DispatchQueue.global().async {
                 if let listBg = PrefsUtil.getBackground() {
+                    if listBg.isEmpty {
+                       return
+                    }
                     var bgChoosen = ""
                     let arrayBg = listBg.split(separator: ",")
                     bgChoosen = String(arrayBg[Int.random(in: 0..<arrayBg.count)])

+ 25 - 16
appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -60,13 +60,20 @@ public class FloatingButton: UIView {
         nexilis_button = UIImageView()
         nexilis_button.translatesAutoresizingMaskIntoConstraints = false
         nexilis_button.isUserInteractionEnabled = true
-        nexilis_button.image = UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
+        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!)
+            }
+        } else {
+            nexilis_button.image = UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
+        }
         
         let qmeraTap = UITapGestureRecognizer(target: self, action: #selector(qmeraTap))
         qmeraTap.numberOfTouchesRequired = 1
         nexilis_button.addGestureRecognizer(qmeraTap)
         
-        let qmeraLongPress = UILongPressGestureRecognizer(target: self, action: #selector(qmeraLongPress))
+        let qmeraLongPress = UILongPressGestureRecognizer(target: self, action: #selector(qmeraLongPress(gestureRecognizer:)))
         nexilis_button.addGestureRecognizer(qmeraLongPress)
         
         addSubview(nexilis_button)
@@ -735,21 +742,23 @@ public class FloatingButton: UIView {
         hideButton()
     }
     
-    @objc func qmeraLongPress() {
-        if mySettingDelegate != nil {
-            mySettingDelegate?.settingDelegate()
-        } else {
-            let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
-            navigationController.modalPresentationStyle = .fullScreen
-            navigationController.navigationBar.tintColor = .white
-            navigationController.navigationBar.barTintColor = .mainColor
-            navigationController.navigationBar.isTranslucent = false
-            let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-            navigationController.navigationBar.titleTextAttributes = textAttributes
-            navigationController.view.backgroundColor = .mainColor
-            UIApplication.shared.rootViewController?.present(navigationController, animated: true, completion: nil)
+    @objc func qmeraLongPress(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state == .began {
+            if mySettingDelegate != nil {
+                mySettingDelegate?.settingDelegate()
+            } else {
+                let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
+                navigationController.modalPresentationStyle = .fullScreen
+                navigationController.navigationBar.tintColor = .white
+                navigationController.navigationBar.barTintColor = .mainColor
+                navigationController.navigationBar.isTranslucent = false
+                let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+                navigationController.navigationBar.titleTextAttributes = textAttributes
+                navigationController.view.backgroundColor = .mainColor
+                UIApplication.shared.rootViewController?.present(navigationController, animated: true, completion: nil)
+            }
+            hideButton()
         }
-        hideButton()
     }
     
     @objc func hideButton() {