Bladeren bron

update FB with gif

alqindiirsyam 1 jaar geleden
bovenliggende
commit
336415b01b

+ 3 - 3
appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift

@@ -55,8 +55,8 @@ class PrefsUtil {
     static func getURLQMS() -> String? {
         return UserDefaults.standard.string(forKey: "app_builder_url_qms")
     }
-    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 getIconSS() -> String? {
         return UserDefaults.standard.string(forKey: "app_builder_icon_ss")
@@ -68,7 +68,7 @@ class PrefsUtil {
         return PrefsUtil.getURLBase() + "dashboardv2/uploads/splashscreen/" + PrefsUtil.getIconSS()!
     }
     static func getUrlDock() -> String? {
-        return PrefsUtil.getURLBase() + "dashboardv2/uploads/fb_icon/" + PrefsUtil.getIconDock()!
+        return PrefsUtil.getURLBase() + "dashboardv2/uploads/fb_icon/" + PrefsUtil.getIconDock()
     }
     
     static func setURLFirstTab(value: String) {

+ 3 - 3
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -190,7 +190,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
 //                }),
             ]
             let menu = UIMenu(title: "", children: childrenMenu)
-            if PrefsUtil.getIconDock() != nil {
+            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 }
@@ -496,7 +496,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         //print("buttonCenterX \(buttonCenterX)")
         //print("buttonCenterY \(buttonCenterY)")
         ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
-        if PrefsUtil.getIconDock() != nil {
+        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 }
@@ -587,7 +587,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                 childrenMenu.append(contentsOf: vc.childrenMenu)
             }
             let menu = UIMenu(title: "", children: childrenMenu)
-            if PrefsUtil.getIconDock() != nil {
+            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 }

+ 62 - 29
appbuilder-ios/NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -35,6 +35,11 @@ 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
     
     public weak var mySettingDelegate: SettingMABDelegate?
     
@@ -51,18 +56,17 @@ 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 {
+        if !Utils.getIconDock().isEmpty {
             var dataImage: Data?
-            if Utils.getIconDock()!.contains(".gif"){
+            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)")
@@ -84,6 +88,9 @@ public class FloatingButton: UIView {
             nexilis_button.image = UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.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)
@@ -93,9 +100,9 @@ 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()
@@ -107,10 +114,16 @@ public class FloatingButton: UIView {
 //        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
@@ -119,7 +132,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
@@ -164,7 +177,7 @@ public class FloatingButton: UIView {
                                         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
@@ -226,14 +239,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: Nexilis.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: Nexilis.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb2)
@@ -241,14 +254,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: Nexilis.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: Nexilis.self), with: nil), for: .normal)
         groupView.addArrangedSubview(button_fb4)
@@ -260,7 +273,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
@@ -272,8 +285,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 - 30 - defaultWidthHeightMenuFB
+                if (xPos > maximumx) {
+                    xPos = maximumx
+                }
+            }
+            let minimumy = (defaultWidthHeightMenuFB * 5) - defaultHeightFB
+            let maximumy = heightScreen - defaultHeightFB - 10
             if(yPos < minimumy) {
                 yPos = minimumy
             }
@@ -281,8 +300,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
             }
@@ -417,7 +436,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
         }
     }
     
@@ -428,13 +447,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 * 5) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
+            var width = frame.width
+            var xPosition = frame.origin.x
+            if Utils.getIconDock().contains(".gif") {
+                height = CGFloat((defaultWidthHeightMenuFB * 3) + 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
@@ -447,12 +476,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 * 5) + 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)
         }
     }
 }

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

@@ -136,12 +136,12 @@ public final class Utils {
         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 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -3332,7 +3332,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
             
             let pictureImage = dataProfile["image_id"]
             if dataMessages[indexPath.row]["f_pin"] as? String == "-999" {
-                if Utils.getIconDock() != nil {
+                if !Utils.getIconDock().isEmpty {
                     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 {
                         profileMessage.image = UIImage(data: dataImage!)

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

@@ -673,7 +673,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
             } else if dataPerson["f_pin"]!! == "-999" {
                 viewAppBar.addSubview(imageProfile)
-                if Utils.getIconDock() != nil {
+                if !Utils.getIconDock().isEmpty {
                     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 {
                         imageProfile.image = UIImage(data: dataImage!)

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

@@ -283,7 +283,7 @@ public class EditorStarMessages: UIViewController, UITableViewDataSource, UITabl
             
             let pictureImage = dataProfile["image_id"]
             if dataMessages[indexPath.row]["f_pin"] as! String == "-999" {
-                if Utils.getIconDock() != nil {
+                if !Utils.getIconDock().isEmpty {
                     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 {
                         profileMessage.image = UIImage(data: dataImage!)

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

@@ -940,7 +940,7 @@ extension ContactChatViewController {
                         imageView.image = UIImage(named: "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
                     }
                 } else {
-                    if Utils.getIconDock() != nil {
+                    if !Utils.getIconDock().isEmpty {
                         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 {
                             getImage(name: data.profile, placeholderImage: UIImage(data: dataImage!), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in

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

@@ -135,7 +135,7 @@ class HistoryBroadcastViewController: UIViewController, UITableViewDelegate, UIT
                     imageView.image = UIImage(named: "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
                 }
             } else {
-                if Utils.getIconDock() != nil {
+                if !Utils.getIconDock().isEmpty {
                     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 {
                         getImage(name: data.profile, placeholderImage: UIImage(data: dataImage!), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in