|
@@ -14,6 +14,7 @@ public class FloatingButton: UIView {
|
|
|
|
|
|
var groupView: UIStackView!
|
|
|
var scrollView: UIScrollView!
|
|
|
+ var imageScrollView: UIImageView!
|
|
|
var button_fb1: UIButton!
|
|
|
var button_fb2: UIButton!
|
|
|
var button_fb3: UIButton!
|
|
@@ -47,13 +48,16 @@ public class FloatingButton: UIView {
|
|
|
let heightFBAnim = (UIScreen.main.bounds.height * 1) / 7.5
|
|
|
let heightFBSideTab = (UIScreen.main.bounds.height * 1.05) / 7.5
|
|
|
let widthFBSideTab: CGFloat = 18
|
|
|
+ let widthVerticalSideTab: CGFloat = 50
|
|
|
+ let heightVerticalSideTab: CGFloat = 220
|
|
|
|
|
|
final let MODE_VERTICAL_FLOATING_BUTTON = "1"
|
|
|
final let MODE_VERTICAL_ANIMATION = "2"
|
|
|
final let MODE_HORIZONTAL_ANIMATION = "3"
|
|
|
final let MODE_HORIZONTAL_SIDE_TAB = "4"
|
|
|
+ final let MODE_VERTICAL_SIDE_TAB = "5"
|
|
|
|
|
|
- var countMenuFB: CGFloat = 5 {
|
|
|
+ var countMenuFB: CGFloat = 6 {
|
|
|
didSet {
|
|
|
if isShow {
|
|
|
show(isShow: isShow)
|
|
@@ -85,7 +89,11 @@ public class FloatingButton: UIView {
|
|
|
var dataImage: Data?
|
|
|
if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
|
|
|
defaultWidthFB = widthFBAnim
|
|
|
- defaultHeightFB = heightFBAnim
|
|
|
+ if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
|
|
|
+ defaultHeightFB = heightFBAnim + 30
|
|
|
+ } else {
|
|
|
+ defaultHeightFB = heightFBAnim
|
|
|
+ }
|
|
|
var urlGif = URL(string: Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? Utils.getIconCenterAnim2() : Utils.getIconCenterAnim4())
|
|
|
if (urlGif == nil) {
|
|
|
urlGif = Bundle.resourceBundle(for: Nexilis.self).url(forResource: Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? "pb_def_icon_mode2" : "pb_def_icon_mode4", withExtension: "gif")! //resourcesMediaBundle
|
|
@@ -111,16 +119,16 @@ public class FloatingButton: UIView {
|
|
|
nexilis_button.image = UIImage(named: Utils.getFBIconBg() == "1" ? "pb_button" : "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
|
|
|
}
|
|
|
} else {
|
|
|
- if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB || Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
defaultWidthFB = widthFBSideTab
|
|
|
defaultHeightFB = heightFBSideTab
|
|
|
}
|
|
|
- nexilis_button.image = UIImage(named: Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB ? "pb_button" : "pb_side_tab", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
|
|
|
+ nexilis_button.image = UIImage(named: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? "pb_side_tab_vtc" : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? "pb_side_tab" : "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: Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? UIScreen.main.bounds.width - defaultWidthFB : defaultWidthFB, height: defaultHeightFB)
|
|
|
+ frame = CGRect(x: UIScreen.main.bounds.width - defaultWidthFB, y: (UIScreen.main.bounds.height / 2) - defaultHeightFB, width: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? 50 + defaultWidthFB : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? UIScreen.main.bounds.width - defaultWidthFB : defaultWidthFB, height: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab : defaultHeightFB)
|
|
|
|
|
|
if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
|
|
|
if configAnim == 0 { //left to right
|
|
@@ -149,7 +157,11 @@ public class FloatingButton: UIView {
|
|
|
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
|
|
|
+ if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ nexilis_button.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
|
|
+ } else {
|
|
|
+ nexilis_button.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
|
+ }
|
|
|
|
|
|
scrollView = UIScrollView()
|
|
|
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -162,7 +174,15 @@ public class FloatingButton: UIView {
|
|
|
}
|
|
|
addSubview(scrollView)
|
|
|
|
|
|
- if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ let bgImage = resizeImage(image: UIImage(named: "pb_button_background_vtcst", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: widthVerticalSideTab, height: heightVerticalSideTab))
|
|
|
+ scrollView.backgroundColor = UIColor.init(patternImage: bgImage)
|
|
|
+
|
|
|
+ scrollView.leftAnchor.constraint(equalTo: nexilis_button.rightAnchor).isActive = true
|
|
|
+ scrollView.centerYAnchor.constraint(equalTo: nexilis_button.centerYAnchor).isActive = true
|
|
|
+ scrollView.widthAnchor.constraint(equalToConstant: widthVerticalSideTab).isActive = true
|
|
|
+ scrollView.heightAnchor.constraint(equalToConstant: heightVerticalSideTab).isActive = true
|
|
|
+ } else if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB {
|
|
|
scrollView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
|
if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION {
|
|
|
scrollView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
@@ -195,7 +215,13 @@ public class FloatingButton: UIView {
|
|
|
|
|
|
scrollView.addSubview(groupView)
|
|
|
|
|
|
- if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ groupView.spacing = 10.0
|
|
|
+ groupView.centerYAnchor.constraint(equalTo: scrollView.centerYAnchor).isActive = true
|
|
|
+ groupView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
|
|
|
+ groupView.heightAnchor.constraint(equalToConstant: heightVerticalSideTab - 20).isActive = true
|
|
|
+ groupView.widthAnchor.constraint(equalToConstant: 30).isActive = true
|
|
|
+ } else if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB {
|
|
|
groupView.leftAnchor.constraint(equalTo: scrollView.leftAnchor).isActive = true
|
|
|
groupView.rightAnchor.constraint(equalTo: scrollView.rightAnchor).isActive = true
|
|
|
groupView.centerYAnchor.constraint(equalTo: scrollView.centerYAnchor).isActive = true
|
|
@@ -282,7 +308,7 @@ public class FloatingButton: UIView {
|
|
|
getDefaultButton()
|
|
|
}
|
|
|
DispatchQueue.global().async { [self] in
|
|
|
- if !Utils.getCustomButtons().isEmpty && Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_HORIZONTAL_ANIMATION {
|
|
|
+ if !Utils.getCustomButtons().isEmpty && Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_HORIZONTAL_ANIMATION && Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
|
|
|
DispatchQueue.main.async { [self] in
|
|
|
groupView.subviews.forEach({ $0.removeFromSuperview() })
|
|
|
let customButtons = Utils.getCustomButtons().components(separatedBy: ",")
|
|
@@ -319,21 +345,15 @@ public class FloatingButton: UIView {
|
|
|
if !data.isEmpty {
|
|
|
if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
|
|
|
DispatchQueue.main.async { [self] in
|
|
|
- groupView.subviews.forEach({ $0.removeFromSuperview() })
|
|
|
- if jsonArray.count == 0 {
|
|
|
- countMenuFB = CGFloat(4)
|
|
|
- getDefaultButton()
|
|
|
- } else {
|
|
|
- if Utils.getConfigModeFB() != MODE_HORIZONTAL_ANIMATION {
|
|
|
- countMenuFB = CGFloat(jsonArray.count > 5 ? 5 : jsonArray.count)
|
|
|
- } else {
|
|
|
- countMenuFB = CGFloat(jsonArray.filter({ $0["mode"] as? Int == Int(MODE_HORIZONTAL_ANIMATION) }).count)
|
|
|
- }
|
|
|
- for json in jsonArray {
|
|
|
+ let filteredData = jsonArray.filter({ $0["mode"] as? Int == Int(Utils.getConfigModeFB()) })
|
|
|
+ if filteredData.count != 0 {
|
|
|
+ groupView.subviews.forEach({ $0.removeFromSuperview() })
|
|
|
+ countMenuFB = CGFloat(filteredData.count > 5 ? 5 : filteredData.count)
|
|
|
+ for json in filteredData {
|
|
|
let package_id = json["package_id"] as! String
|
|
|
let app_id = (json["app_id"] as? String) ?? ""
|
|
|
let icon = (json["icon"] as? String) ?? ""
|
|
|
- let mode = "\((json["mode"] as? Int) ?? 1)"
|
|
|
+ let mode = "\((json["mode"] as? Int) ?? 1)"
|
|
|
let newButton = UIButton()
|
|
|
if mode != Utils.getConfigModeFB() {
|
|
|
continue
|
|
@@ -344,33 +364,36 @@ public class FloatingButton: UIView {
|
|
|
} else if mode == MODE_HORIZONTAL_ANIMATION {
|
|
|
newButton.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
+ } else if mode == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ newButton.imageView?.contentMode = .scaleAspectFit
|
|
|
} else {
|
|
|
newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
}
|
|
|
newButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
var indexTap = 0
|
|
|
if package_id.contains("_fb"){
|
|
|
- let numIdx = package_id.split(separator: "_")[1]
|
|
|
+ let listSplit = package_id.split(separator: "_", maxSplits: 1)
|
|
|
+ let numIdx = listSplit[listSplit.firstIndex(where: { $0.contains("fb") }) ?? 0]
|
|
|
indexTap = Int(String(numIdx).substring(from: 2, to: numIdx.count))!
|
|
|
}
|
|
|
if indexTap == Nexilis.IDX_CHAT {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_chat" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_chat" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CONVERSATION {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_conversation" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_conversation" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_chat" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_conversation" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_conversation" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CALL {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_call" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_call" : "pb_button_call", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CC {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_cc" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_cc" : "pb_button_cc", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_cc" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_cc" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_cc" : "pb_button_cc", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_STREAM {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_stream" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_stream" : "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_stream" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_stream" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_stream" : "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_SOCIAL_COMMERCE {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_social_commerce" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_commerce" : "pb_button_commerce", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_commerce" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_social_commerce" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_commerce" : "pb_button_commerce", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_NEWS {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_news" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_news" : "pb_button_news", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_POST {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_post" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_post" : "pb_button_post", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_NOTIF_CENTER {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_notif_center" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_notif_center" : "pb_button_notification", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_notif_center" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_notif_center" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_notif_center" : "pb_button_notification", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_more" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_more" : "pb_button_others", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
}
|
|
@@ -412,16 +435,23 @@ public class FloatingButton: UIView {
|
|
|
}
|
|
|
|
|
|
func getDefaultButton() {
|
|
|
- let data = [Nexilis.IDX_NOTIF_CENTER, Nexilis.IDX_CC, Nexilis.IDX_CONVERSATION, Nexilis.IDX_CALL, Nexilis.IDX_STREAM]
|
|
|
+ let mode = Utils.getConfigModeFB()
|
|
|
+ var data = [Nexilis.IDX_NOTIF_CENTER, Nexilis.IDX_CC, Nexilis.IDX_CONVERSATION, Nexilis.IDX_CALL, Nexilis.IDX_STREAM]
|
|
|
+ if mode == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ data = [Nexilis.IDX_NOTIF_CENTER, Nexilis.IDX_CC, Nexilis.IDX_CONVERSATION, Nexilis.IDX_STREAM, Nexilis.IDX_SOCIAL_COMMERCE]
|
|
|
+ } else if mode == MODE_HORIZONTAL_ANIMATION {
|
|
|
+ data = [Nexilis.IDX_NOTIF_CENTER, Nexilis.IDX_CC, Nexilis.IDX_CONVERSATION, Nexilis.IDX_SOCIAL_COMMERCE, Nexilis.IDX_STREAM]
|
|
|
+ }
|
|
|
for i in 0..<data.count {
|
|
|
let newButton = UIButton()
|
|
|
- let mode = Utils.getConfigModeFB()
|
|
|
if mode == MODE_HORIZONTAL_SIDE_TAB {
|
|
|
newButton.widthAnchor.constraint(equalToConstant: defaultHeightFB - 10).isActive = true
|
|
|
newButton.heightAnchor.constraint(equalToConstant: defaultHeightFB - 10).isActive = true
|
|
|
} else if mode == MODE_HORIZONTAL_ANIMATION {
|
|
|
newButton.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
+ } else if mode == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ newButton.imageView?.contentMode = .scaleAspectFit
|
|
|
} else {
|
|
|
newButton.heightAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB).isActive = true
|
|
|
}
|
|
@@ -430,21 +460,24 @@ public class FloatingButton: UIView {
|
|
|
if indexTap == Nexilis.IDX_CHAT {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_chat" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CONVERSATION {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_conversation" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_conversation" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_chat" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_conversation" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_conversation" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CALL {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_call" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_call" : "pb_button_call", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_CC {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_cc" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_cc" : "pb_button_cc", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_cc" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_cc" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_cc" : "pb_button_cc", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_STREAM {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_stream" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_stream" : "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_stream" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_stream" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_stream" : "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_SOCIAL_COMMERCE {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_social_commerce" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_commerce" : "pb_button_commerce", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_commerce" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_social_commerce" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_commerce" : "pb_button_commerce", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_NEWS {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_news" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_news" : "pb_button_news", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_POST {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_post" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_post" : "pb_button_post", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
} else if indexTap == Nexilis.IDX_NOTIF_CENTER {
|
|
|
- newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_notif_center" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_notif_center" : "pb_button_notification", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ newButton.setImage(UIImage(named: mode == MODE_VERTICAL_SIDE_TAB ? "pb_button_vtcst_notif_center" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_notif_center" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_notif_center" : "pb_button_notification", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
+ if mode == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ newButton.imageView?.contentMode = .scaleAspectFit
|
|
|
+ }
|
|
|
} else {
|
|
|
newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_more" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_more" : "pb_button_others", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
|
|
|
}
|
|
@@ -459,14 +492,14 @@ public class FloatingButton: UIView {
|
|
|
let size = UIScreen.main.bounds
|
|
|
let widthScreen = size.width
|
|
|
let heightScreen = size.height
|
|
|
- let minimumx: CGFloat = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? 80 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? 60 : 40
|
|
|
- let maximumx = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? widthScreen - frame.width + 20 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? widthScreen - 10 - defaultWidthHeightMenuFB : widthScreen - 40
|
|
|
+ let minimumx: CGFloat = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? widthFBAnim + defaultWidthHeightMenuFB : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? 60 : 40
|
|
|
+ let maximumx = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? widthScreen - widthFBAnim - defaultWidthHeightMenuFB : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? widthScreen - 10 - defaultWidthHeightMenuFB : widthScreen - 40
|
|
|
let maxMinXSideTab = isShow ? center.x : widthScreen + (center.x - widthScreen)
|
|
|
let translation = sender.translation(in: self)
|
|
|
var xPos = center.x + translation.x
|
|
|
var yPos = center.y + translation.y
|
|
|
bringSubviewToFront(self)
|
|
|
- if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB || Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
xPos = maxMinXSideTab
|
|
|
} else {
|
|
|
if (xPos < minimumx) {
|
|
@@ -477,8 +510,8 @@ public class FloatingButton: UIView {
|
|
|
}
|
|
|
}
|
|
|
if(isShow) {
|
|
|
- let minimumy = Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? 50 : (defaultWidthHeightMenuFB * countMenuFB) - defaultHeightFB - 10
|
|
|
- let maximumy = Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? heightScreen - 50 : heightScreen - defaultHeightFB - 10
|
|
|
+ let minimumy = Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab - 100 : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? 50 : Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? defaultWidthHeightMenuFB * 2 + 10 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? defaultHeightFB + defaultWidthHeightMenuFB : defaultHeightFB * 3 + 20
|
|
|
+ let maximumy = Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightScreen - (heightVerticalSideTab - 100) : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? heightScreen - 50 : Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? heightScreen - defaultWidthHeightMenuFB - 30 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? heightScreen - defaultHeightFB - 30 : heightScreen - defaultHeightFB * 3 - 20
|
|
|
if(yPos < minimumy) {
|
|
|
yPos = minimumy
|
|
|
}
|
|
@@ -561,6 +594,7 @@ public class FloatingButton: UIView {
|
|
|
}
|
|
|
|
|
|
@objc func fbTap(_ sender: UIButton) {
|
|
|
+ print("LOHE")
|
|
|
let package_id = sender.restorationIdentifier!
|
|
|
var app_id = sender.accessibilityIdentifier!
|
|
|
var indexTap = 0
|
|
@@ -632,8 +666,8 @@ public class FloatingButton: UIView {
|
|
|
} else if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
|
|
|
height = defaultHeightFB + defaultWidthHeightMenuFB
|
|
|
width = defaultWidthHeightMenuFB * (countMenuFB - 1)
|
|
|
- if xPosition > UIScreen.main.bounds.width - defaultWidthHeightMenuFB * (countMenuFB) {
|
|
|
- xPosition = UIScreen.main.bounds.width - defaultWidthHeightMenuFB * (countMenuFB)
|
|
|
+ if xPosition > UIScreen.main.bounds.width - width {
|
|
|
+ xPosition = UIScreen.main.bounds.width - width
|
|
|
}
|
|
|
}
|
|
|
var yPosition = frame.origin.y - height + defaultHeightFB
|
|
@@ -641,11 +675,22 @@ public class FloatingButton: UIView {
|
|
|
lastPosY = frame.origin.y
|
|
|
yPosition = 25
|
|
|
}
|
|
|
- if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
|
|
|
frame = CGRect(x: xPosition, y: yPosition, width: width, height: height)
|
|
|
} else {
|
|
|
- UIView.animate(withDuration: 0.5, animations: {
|
|
|
- self.frame.origin.x = 0
|
|
|
+ UIView.animate(withDuration: 0.5, animations: { [self] in
|
|
|
+ var vst: CGFloat = 0.0
|
|
|
+ if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
|
|
|
+ vst = UIScreen.main.bounds.width - defaultWidthFB - widthVerticalSideTab
|
|
|
+ let size = UIScreen.main.bounds
|
|
|
+ let heightScreen = size.height
|
|
|
+ if frame.origin.y < 20 {
|
|
|
+ frame.origin.y = 20
|
|
|
+ } else if frame.origin.y > heightScreen - heightVerticalSideTab {
|
|
|
+ frame.origin.y = heightScreen - heightVerticalSideTab
|
|
|
+ }
|
|
|
+ }
|
|
|
+ frame.origin.x = 0 + vst
|
|
|
})
|
|
|
}
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: { [self] in
|
|
@@ -673,7 +718,7 @@ public class FloatingButton: UIView {
|
|
|
if lastPosY != nil {
|
|
|
yPosition = lastPosY!
|
|
|
}
|
|
|
- if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB {
|
|
|
+ if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
|
|
|
frame = CGRect(x: frame.origin.x, y: yPosition, width: width, height: defaultHeightFB)
|
|
|
} else {
|
|
|
UIView.animate(withDuration: 0.5, animations: { [self] in
|