|
@@ -46,7 +46,7 @@ public class Nexilis: NSObject {
|
|
|
|
|
|
public static let shared = Nexilis()
|
|
public static let shared = Nexilis()
|
|
|
|
|
|
- public static var broadcastTimer = Timer()
|
|
|
|
|
|
+// public static var broadcastTimer = Timer()
|
|
|
|
|
|
public static var broadcastList = [[String: String]]()
|
|
public static var broadcastList = [[String: String]]()
|
|
|
|
|
|
@@ -1826,17 +1826,23 @@ public class Nexilis: NSObject {
|
|
return permissionCheck
|
|
return permissionCheck
|
|
}
|
|
}
|
|
|
|
|
|
- public static func startTimer(){
|
|
|
|
- broadcastTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: {_ in
|
|
|
|
- if(!openBroadcast && !broadcastList.isEmpty){
|
|
|
|
- openBroadcast = true
|
|
|
|
- let m = broadcastList.removeFirst()
|
|
|
|
- //print("broadcast show: \(m)")
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- Nexilis.shared.showBroadcastMessage(m: m)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+// public static func startTimer(){
|
|
|
|
+// broadcastTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: {_ in
|
|
|
|
+// if(!openBroadcast && !broadcastList.isEmpty){
|
|
|
|
+// openBroadcast = true
|
|
|
|
+// let m = broadcastList.removeFirst()
|
|
|
|
+// //print("broadcast show: \(m)")
|
|
|
|
+// DispatchQueue.main.async {
|
|
|
|
+// Nexilis.shared.showBroadcastMessage(m: m)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+// }
|
|
|
|
+ public static func debugBroadcast(){
|
|
|
|
+ if(!broadcastList.isEmpty) {
|
|
|
|
+ let m = broadcastList[0]
|
|
|
|
+ Nexilis.shared.showBroadcastMessage(m: m)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2253,241 +2259,249 @@ extension Nexilis: MessageDelegate {
|
|
|
|
|
|
func showBroadcastMessage(m: [String: String]) {
|
|
func showBroadcastMessage(m: [String: String]) {
|
|
let fileType = m[CoreMessage_TMessageKey.CATEGORY_FLAG]!
|
|
let fileType = m[CoreMessage_TMessageKey.CATEGORY_FLAG]!
|
|
|
|
+ let gifId = m[CoreMessage_TMessageKey.GIF_ID] ?? ""
|
|
let broadcastVC = UIViewController()
|
|
let broadcastVC = UIViewController()
|
|
if let viewBroadcast = broadcastVC.view {
|
|
if let viewBroadcast = broadcastVC.view {
|
|
broadcastVC.modalPresentationStyle = .custom
|
|
broadcastVC.modalPresentationStyle = .custom
|
|
viewBroadcast.backgroundColor = .black.withAlphaComponent(0.3)
|
|
viewBroadcast.backgroundColor = .black.withAlphaComponent(0.3)
|
|
-
|
|
|
|
- let stringLink = m[CoreMessage_TMessageKey.LINK] ?? ""
|
|
|
|
-
|
|
|
|
- let containerView = UIView()
|
|
|
|
- viewBroadcast.addSubview(containerView)
|
|
|
|
- if stringLink.isEmpty {
|
|
|
|
- containerView.anchor(centerX: viewBroadcast.centerXAnchor, centerY: viewBroadcast.centerYAnchor, width: viewBroadcast.bounds.width - 40, minHeight: 100, maxHeight: viewBroadcast.bounds.height - 100)
|
|
|
|
|
|
+ if !gifId.isEmpty {
|
|
|
|
+ let containerView = UIView()
|
|
|
|
+ viewBroadcast.addSubview(containerView)
|
|
|
|
+ containerView.anchor(centerX: viewBroadcast.centerXAnchor, centerY: viewBroadcast.centerYAnchor, width: 100, height: 100)
|
|
|
|
+ containerView.backgroundColor = .yellow.withAlphaComponent(0.5)
|
|
} else {
|
|
} else {
|
|
- containerView.anchor(centerX: viewBroadcast.centerXAnchor, centerY: viewBroadcast.centerYAnchor, width: viewBroadcast.bounds.width - 40, minHeight: 200, maxHeight: viewBroadcast.bounds.height - 100)
|
|
|
|
- }
|
|
|
|
- containerView.backgroundColor = .white.withAlphaComponent(0.9)
|
|
|
|
- containerView.layer.cornerRadius = 15.0
|
|
|
|
- containerView.clipsToBounds = true
|
|
|
|
-
|
|
|
|
- let subContainerView = UIView()
|
|
|
|
- subContainerView.backgroundColor = .clear
|
|
|
|
- containerView.addSubview(subContainerView)
|
|
|
|
- subContainerView.anchor(top: containerView.topAnchor, left: containerView.leftAnchor, bottom: containerView.bottomAnchor, right: containerView.rightAnchor, paddingTop: 20.0, paddingLeft: 10.0, paddingBottom: 20.0, paddingRight: 10.0)
|
|
|
|
-
|
|
|
|
- let buttonClose = UIButton(type: .close)
|
|
|
|
- buttonClose.frame.size = CGSize(width: 30, height: 30)
|
|
|
|
- buttonClose.layer.cornerRadius = 15.0
|
|
|
|
- buttonClose.clipsToBounds = true
|
|
|
|
- buttonClose.backgroundColor = .secondaryColor.withAlphaComponent(0.5)
|
|
|
|
- buttonClose.actionHandle(controlEvents: .touchUpInside,
|
|
|
|
- ForAction:{() -> Void in
|
|
|
|
- broadcastVC.dismiss(animated: true, completion: {
|
|
|
|
- Nexilis.broadcastList.remove(at: 0)
|
|
|
|
- if Nexilis.broadcastList.count > 0 {
|
|
|
|
- Nexilis.shared.showBroadcastMessage(m: Nexilis.broadcastList[0])
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- containerView.addSubview(buttonClose)
|
|
|
|
- buttonClose.anchor(top: containerView.topAnchor, right: containerView.rightAnchor, width: 30, height: 30)
|
|
|
|
-
|
|
|
|
- let title = UILabel()
|
|
|
|
- title.font = .systemFont(ofSize: 18, weight: .bold)
|
|
|
|
- title.text = m["MERNAM"]
|
|
|
|
- title.textAlignment = .center
|
|
|
|
- subContainerView.addSubview(title)
|
|
|
|
- title.anchor(top: subContainerView.topAnchor, left: subContainerView.leftAnchor, right: subContainerView.rightAnchor)
|
|
|
|
-
|
|
|
|
- let titleBroadcast = UILabel()
|
|
|
|
- subContainerView.addSubview(titleBroadcast)
|
|
|
|
- titleBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- NSLayoutConstraint.activate([
|
|
|
|
- titleBroadcast.topAnchor.constraint(equalTo: title.bottomAnchor, constant: 20.0),
|
|
|
|
- titleBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
- titleBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
- ])
|
|
|
|
- titleBroadcast.font = UIFont.systemFont(ofSize: 14, weight: .semibold)
|
|
|
|
- titleBroadcast.numberOfLines = 0
|
|
|
|
- titleBroadcast.attributedText = m[CoreMessage_TMessageKey.TITLE]!.richText()
|
|
|
|
- titleBroadcast.textColor = .black
|
|
|
|
-
|
|
|
|
- let descBroadcast = UILabel()
|
|
|
|
- subContainerView.addSubview(descBroadcast)
|
|
|
|
- descBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- let constraintDesc = descBroadcast.bottomAnchor.constraint(equalTo: subContainerView.bottomAnchor)
|
|
|
|
- if !stringLink.isEmpty{
|
|
|
|
- constraintDesc.constant = constraintDesc.constant - 30
|
|
|
|
- }
|
|
|
|
- if fileType != BroadcastViewController.FILE_TYPE_CHAT {
|
|
|
|
- constraintDesc.constant = constraintDesc.constant - 260
|
|
|
|
- }
|
|
|
|
- NSLayoutConstraint.activate([
|
|
|
|
- descBroadcast.topAnchor.constraint(equalTo: titleBroadcast.bottomAnchor, constant: 10),
|
|
|
|
- descBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
- descBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
- constraintDesc,
|
|
|
|
- ])
|
|
|
|
- descBroadcast.font = UIFont.systemFont(ofSize: 12)
|
|
|
|
- descBroadcast.numberOfLines = 0
|
|
|
|
- descBroadcast.attributedText = m[CoreMessage_TMessageKey.MESSAGE_TEXT_ENG]!.richText()
|
|
|
|
- descBroadcast.textColor = .black
|
|
|
|
-
|
|
|
|
- let linkBroadcast = UILabel()
|
|
|
|
- if !stringLink.isEmpty {
|
|
|
|
- subContainerView.addSubview(linkBroadcast)
|
|
|
|
- linkBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
+ let stringLink = m[CoreMessage_TMessageKey.LINK] ?? ""
|
|
|
|
+
|
|
|
|
+ let containerView = UIView()
|
|
|
|
+ viewBroadcast.addSubview(containerView)
|
|
|
|
+ if stringLink.isEmpty {
|
|
|
|
+ containerView.anchor(centerX: viewBroadcast.centerXAnchor, centerY: viewBroadcast.centerYAnchor, width: viewBroadcast.bounds.width - 40, minHeight: 100, maxHeight: viewBroadcast.bounds.height - 100)
|
|
|
|
+ } else {
|
|
|
|
+ containerView.anchor(centerX: viewBroadcast.centerXAnchor, centerY: viewBroadcast.centerYAnchor, width: viewBroadcast.bounds.width - 40, minHeight: 200, maxHeight: viewBroadcast.bounds.height - 100)
|
|
|
|
+ }
|
|
|
|
+ containerView.backgroundColor = .white.withAlphaComponent(0.9)
|
|
|
|
+ containerView.layer.cornerRadius = 15.0
|
|
|
|
+ containerView.clipsToBounds = true
|
|
|
|
+
|
|
|
|
+ let subContainerView = UIView()
|
|
|
|
+ subContainerView.backgroundColor = .clear
|
|
|
|
+ containerView.addSubview(subContainerView)
|
|
|
|
+ subContainerView.anchor(top: containerView.topAnchor, left: containerView.leftAnchor, bottom: containerView.bottomAnchor, right: containerView.rightAnchor, paddingTop: 20.0, paddingLeft: 10.0, paddingBottom: 20.0, paddingRight: 10.0)
|
|
|
|
+
|
|
|
|
+ let buttonClose = UIButton(type: .close)
|
|
|
|
+ buttonClose.frame.size = CGSize(width: 30, height: 30)
|
|
|
|
+ buttonClose.layer.cornerRadius = 15.0
|
|
|
|
+ buttonClose.clipsToBounds = true
|
|
|
|
+ buttonClose.backgroundColor = .secondaryColor.withAlphaComponent(0.5)
|
|
|
|
+ buttonClose.actionHandle(controlEvents: .touchUpInside,
|
|
|
|
+ ForAction:{() -> Void in
|
|
|
|
+ broadcastVC.dismiss(animated: true, completion: {
|
|
|
|
+ Nexilis.broadcastList.remove(at: 0)
|
|
|
|
+ if Nexilis.broadcastList.count > 0 {
|
|
|
|
+ Nexilis.shared.showBroadcastMessage(m: Nexilis.broadcastList[0])
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ containerView.addSubview(buttonClose)
|
|
|
|
+ buttonClose.anchor(top: containerView.topAnchor, right: containerView.rightAnchor, width: 30, height: 30)
|
|
|
|
+
|
|
|
|
+ let title = UILabel()
|
|
|
|
+ title.font = .systemFont(ofSize: 18, weight: .bold)
|
|
|
|
+ title.text = m["MERNAM"]
|
|
|
|
+ title.textAlignment = .center
|
|
|
|
+ subContainerView.addSubview(title)
|
|
|
|
+ title.anchor(top: subContainerView.topAnchor, left: subContainerView.leftAnchor, right: subContainerView.rightAnchor)
|
|
|
|
+
|
|
|
|
+ let titleBroadcast = UILabel()
|
|
|
|
+ subContainerView.addSubview(titleBroadcast)
|
|
|
|
+ titleBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
NSLayoutConstraint.activate([
|
|
NSLayoutConstraint.activate([
|
|
- linkBroadcast.topAnchor.constraint(equalTo: descBroadcast.bottomAnchor, constant: 10),
|
|
|
|
- linkBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
- linkBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
|
|
+ titleBroadcast.topAnchor.constraint(equalTo: title.bottomAnchor, constant: 20.0),
|
|
|
|
+ titleBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
+ titleBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
])
|
|
])
|
|
- linkBroadcast.font = UIFont.systemFont(ofSize: 12)
|
|
|
|
- linkBroadcast.isUserInteractionEnabled = true
|
|
|
|
- linkBroadcast.numberOfLines = 2
|
|
|
|
- let attributedString = NSMutableAttributedString(string: stringLink, attributes:[NSAttributedString.Key.link: URL(string: stringLink)!])
|
|
|
|
- linkBroadcast.attributedText = attributedString
|
|
|
|
- let tap = ObjectGesture(target: self, action: #selector(tapLinkBroadcast))
|
|
|
|
- tap.message_id = stringLink
|
|
|
|
- linkBroadcast.addGestureRecognizer(tap)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let thumb = m[CoreMessage_TMessageKey.THUMB_ID] ?? ""
|
|
|
|
- let image = m[CoreMessage_TMessageKey.IMAGE_ID] ?? ""
|
|
|
|
- let video = m[CoreMessage_TMessageKey.VIDEO_ID] ?? ""
|
|
|
|
- let file = m[CoreMessage_TMessageKey.FILE_ID] ?? ""
|
|
|
|
- if fileType != BroadcastViewController.FILE_TYPE_CHAT {
|
|
|
|
- let imageBroadcast = UIImageView()
|
|
|
|
- subContainerView.addSubview(imageBroadcast)
|
|
|
|
- imageBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- var constImage = imageBroadcast.topAnchor.constraint(equalTo: descBroadcast.bottomAnchor, constant: 10)
|
|
|
|
- if !stringLink.isEmpty {
|
|
|
|
- constImage = imageBroadcast.topAnchor.constraint(equalTo: linkBroadcast.bottomAnchor, constant: 10)
|
|
|
|
|
|
+ titleBroadcast.font = UIFont.systemFont(ofSize: 14, weight: .semibold)
|
|
|
|
+ titleBroadcast.numberOfLines = 0
|
|
|
|
+ titleBroadcast.attributedText = m[CoreMessage_TMessageKey.TITLE]!.richText()
|
|
|
|
+ titleBroadcast.textColor = .black
|
|
|
|
+
|
|
|
|
+ let descBroadcast = UILabel()
|
|
|
|
+ subContainerView.addSubview(descBroadcast)
|
|
|
|
+ descBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
+ let constraintDesc = descBroadcast.bottomAnchor.constraint(equalTo: subContainerView.bottomAnchor)
|
|
|
|
+ if !stringLink.isEmpty{
|
|
|
|
+ constraintDesc.constant = constraintDesc.constant - 30
|
|
|
|
+ }
|
|
|
|
+ if fileType != BroadcastViewController.FILE_TYPE_CHAT {
|
|
|
|
+ constraintDesc.constant = constraintDesc.constant - 260
|
|
}
|
|
}
|
|
NSLayoutConstraint.activate([
|
|
NSLayoutConstraint.activate([
|
|
- constImage,
|
|
|
|
- imageBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
- imageBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
- imageBroadcast.heightAnchor.constraint(equalToConstant: 250)
|
|
|
|
|
|
+ descBroadcast.topAnchor.constraint(equalTo: titleBroadcast.bottomAnchor, constant: 10),
|
|
|
|
+ descBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
+ descBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
+ constraintDesc,
|
|
])
|
|
])
|
|
- imageBroadcast.layer.cornerRadius = 10.0
|
|
|
|
- imageBroadcast.clipsToBounds = true
|
|
|
|
- if fileType != BroadcastViewController.FILE_TYPE_DOCUMENT {
|
|
|
|
- imageBroadcast.contentMode = .scaleAspectFill
|
|
|
|
- imageBroadcast.setImage(name: thumb)
|
|
|
|
-
|
|
|
|
- if fileType == BroadcastViewController.FILE_TYPE_VIDEO {
|
|
|
|
- let imagePlay = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
|
|
|
- imageBroadcast.addSubview(imagePlay)
|
|
|
|
- imagePlay.clipsToBounds = true
|
|
|
|
- imagePlay.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- imagePlay.centerYAnchor.constraint(equalTo: imageBroadcast.centerYAnchor).isActive = true
|
|
|
|
- imagePlay.centerXAnchor.constraint(equalTo: imageBroadcast.centerXAnchor).isActive = true
|
|
|
|
- imagePlay.widthAnchor.constraint(equalToConstant: 60).isActive = true
|
|
|
|
- imagePlay.heightAnchor.constraint(equalToConstant: 60).isActive = true
|
|
|
|
- imagePlay.tintColor = .gray.withAlphaComponent(0.5)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- imageBroadcast.image = UIImage(systemName: "doc.fill")
|
|
|
|
- imageBroadcast.tintColor = .mainColor
|
|
|
|
- imageBroadcast.contentMode = .scaleAspectFit
|
|
|
|
|
|
+ descBroadcast.font = UIFont.systemFont(ofSize: 12)
|
|
|
|
+ descBroadcast.numberOfLines = 0
|
|
|
|
+ descBroadcast.attributedText = m[CoreMessage_TMessageKey.MESSAGE_TEXT_ENG]!.richText()
|
|
|
|
+ descBroadcast.textColor = .black
|
|
|
|
+
|
|
|
|
+ let linkBroadcast = UILabel()
|
|
|
|
+ if !stringLink.isEmpty {
|
|
|
|
+ subContainerView.addSubview(linkBroadcast)
|
|
|
|
+ linkBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
|
+ linkBroadcast.topAnchor.constraint(equalTo: descBroadcast.bottomAnchor, constant: 10),
|
|
|
|
+ linkBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
+ linkBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
+ ])
|
|
|
|
+ linkBroadcast.font = UIFont.systemFont(ofSize: 12)
|
|
|
|
+ linkBroadcast.isUserInteractionEnabled = true
|
|
|
|
+ linkBroadcast.numberOfLines = 2
|
|
|
|
+ let attributedString = NSMutableAttributedString(string: stringLink, attributes:[NSAttributedString.Key.link: URL(string: stringLink)!])
|
|
|
|
+ linkBroadcast.attributedText = attributedString
|
|
|
|
+ let tap = ObjectGesture(target: self, action: #selector(tapLinkBroadcast))
|
|
|
|
+ tap.message_id = stringLink
|
|
|
|
+ linkBroadcast.addGestureRecognizer(tap)
|
|
}
|
|
}
|
|
-
|
|
|
|
- imageBroadcast.actionHandle(controlEvents: .touchUpInside,
|
|
|
|
- ForAction:{() -> Void in
|
|
|
|
- let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
|
|
|
|
- let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
|
|
|
|
- let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
|
|
|
|
- if fileType == BroadcastViewController.FILE_TYPE_IMAGE {
|
|
|
|
- if let dirPath = paths.first {
|
|
|
|
- let imageURL = URL(fileURLWithPath: dirPath).appendingPathComponent(image)
|
|
|
|
- if FileManager.default.fileExists(atPath: imageURL.path) {
|
|
|
|
- let image = UIImage(contentsOfFile: imageURL.path)
|
|
|
|
- let previewImageVC = PreviewAttachmentImageVideo(nibName: "PreviewAttachmentImageVideo", bundle: Bundle.resourceBundle(for: Nexilis.self))
|
|
|
|
- previewImageVC.image = image
|
|
|
|
- previewImageVC.isHiddenTextField = true
|
|
|
|
- previewImageVC.modalPresentationStyle = .overFullScreen
|
|
|
|
- previewImageVC.modalTransitionStyle = .crossDissolve
|
|
|
|
- if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
- UIApplication.shared.visibleViewController?.navigationController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
- } else {
|
|
|
|
- UIApplication.shared.visibleViewController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Download().startHTTP(forKey: image) { (name, progress) in
|
|
|
|
- guard progress == 100 else {
|
|
|
|
- return
|
|
|
|
|
|
+
|
|
|
|
+ let thumb = m[CoreMessage_TMessageKey.THUMB_ID] ?? ""
|
|
|
|
+ let image = m[CoreMessage_TMessageKey.IMAGE_ID] ?? ""
|
|
|
|
+ let video = m[CoreMessage_TMessageKey.VIDEO_ID] ?? ""
|
|
|
|
+ let file = m[CoreMessage_TMessageKey.FILE_ID] ?? ""
|
|
|
|
+ if fileType != BroadcastViewController.FILE_TYPE_CHAT {
|
|
|
|
+ let imageBroadcast = UIImageView()
|
|
|
|
+ subContainerView.addSubview(imageBroadcast)
|
|
|
|
+ imageBroadcast.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
+ var constImage = imageBroadcast.topAnchor.constraint(equalTo: descBroadcast.bottomAnchor, constant: 10)
|
|
|
|
+ if !stringLink.isEmpty {
|
|
|
|
+ constImage = imageBroadcast.topAnchor.constraint(equalTo: linkBroadcast.bottomAnchor, constant: 10)
|
|
|
|
+ }
|
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
|
+ constImage,
|
|
|
|
+ imageBroadcast.leadingAnchor.constraint(equalTo: subContainerView.leadingAnchor),
|
|
|
|
+ imageBroadcast.trailingAnchor.constraint(equalTo: subContainerView.trailingAnchor),
|
|
|
|
+ imageBroadcast.heightAnchor.constraint(equalToConstant: 250)
|
|
|
|
+ ])
|
|
|
|
+ imageBroadcast.layer.cornerRadius = 10.0
|
|
|
|
+ imageBroadcast.clipsToBounds = true
|
|
|
|
+ if fileType != BroadcastViewController.FILE_TYPE_DOCUMENT {
|
|
|
|
+ imageBroadcast.contentMode = .scaleAspectFill
|
|
|
|
+ imageBroadcast.setImage(name: thumb)
|
|
|
|
+
|
|
|
|
+ if fileType == BroadcastViewController.FILE_TYPE_VIDEO {
|
|
|
|
+ let imagePlay = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
|
|
|
+ imageBroadcast.addSubview(imagePlay)
|
|
|
|
+ imagePlay.clipsToBounds = true
|
|
|
|
+ imagePlay.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
+ imagePlay.centerYAnchor.constraint(equalTo: imageBroadcast.centerYAnchor).isActive = true
|
|
|
|
+ imagePlay.centerXAnchor.constraint(equalTo: imageBroadcast.centerXAnchor).isActive = true
|
|
|
|
+ imagePlay.widthAnchor.constraint(equalToConstant: 60).isActive = true
|
|
|
|
+ imagePlay.heightAnchor.constraint(equalToConstant: 60).isActive = true
|
|
|
|
+ imagePlay.tintColor = .gray.withAlphaComponent(0.5)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ imageBroadcast.image = UIImage(systemName: "doc.fill")
|
|
|
|
+ imageBroadcast.tintColor = .mainColor
|
|
|
|
+ imageBroadcast.contentMode = .scaleAspectFit
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ imageBroadcast.actionHandle(controlEvents: .touchUpInside,
|
|
|
|
+ ForAction:{() -> Void in
|
|
|
|
+ let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
|
|
|
|
+ let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
|
|
|
|
+ let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
|
|
|
|
+ if fileType == BroadcastViewController.FILE_TYPE_IMAGE {
|
|
|
|
+ if let dirPath = paths.first {
|
|
|
|
+ let imageURL = URL(fileURLWithPath: dirPath).appendingPathComponent(image)
|
|
|
|
+ if FileManager.default.fileExists(atPath: imageURL.path) {
|
|
|
|
+ let image = UIImage(contentsOfFile: imageURL.path)
|
|
|
|
+ let previewImageVC = PreviewAttachmentImageVideo(nibName: "PreviewAttachmentImageVideo", bundle: Bundle.resourceBundle(for: Nexilis.self))
|
|
|
|
+ previewImageVC.image = image
|
|
|
|
+ previewImageVC.isHiddenTextField = true
|
|
|
|
+ previewImageVC.modalPresentationStyle = .overFullScreen
|
|
|
|
+ previewImageVC.modalTransitionStyle = .crossDissolve
|
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
+ } else {
|
|
|
|
+ UIApplication.shared.visibleViewController?.present(previewImageVC, animated: true, completion: nil)
|
|
}
|
|
}
|
|
-
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- let image = UIImage(contentsOfFile: imageURL.path)
|
|
|
|
- let previewImageVC = PreviewAttachmentImageVideo(nibName: "PreviewAttachmentImageVideo", bundle: Bundle.resourceBundle(for: Nexilis.self))
|
|
|
|
- previewImageVC.image = image
|
|
|
|
- previewImageVC.isHiddenTextField = true
|
|
|
|
- previewImageVC.modalPresentationStyle = .overFullScreen
|
|
|
|
- previewImageVC.modalTransitionStyle = .crossDissolve
|
|
|
|
- if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
- UIApplication.shared.visibleViewController?.navigationController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
- } else {
|
|
|
|
- UIApplication.shared.visibleViewController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ Download().startHTTP(forKey: image) { (name, progress) in
|
|
|
|
+ guard progress == 100 else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ let image = UIImage(contentsOfFile: imageURL.path)
|
|
|
|
+ let previewImageVC = PreviewAttachmentImageVideo(nibName: "PreviewAttachmentImageVideo", bundle: Bundle.resourceBundle(for: Nexilis.self))
|
|
|
|
+ previewImageVC.image = image
|
|
|
|
+ previewImageVC.isHiddenTextField = true
|
|
|
|
+ previewImageVC.modalPresentationStyle = .overFullScreen
|
|
|
|
+ previewImageVC.modalTransitionStyle = .crossDissolve
|
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
+ } else {
|
|
|
|
+ UIApplication.shared.visibleViewController?.present(previewImageVC, animated: true, completion: nil)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- } else if fileType == BroadcastViewController.FILE_TYPE_VIDEO {
|
|
|
|
- //https://qmera.io/filepalio/image/
|
|
|
|
- let player = AVPlayer(url: URL(string: "https://nexilis.io/get_file?account=\(Nexilis.sAPIKey)&image=\(video)")!)
|
|
|
|
- let playerVC = AVPlayerViewController()
|
|
|
|
- playerVC.player = player
|
|
|
|
- playerVC.modalPresentationStyle = .custom
|
|
|
|
- if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
- UIApplication.shared.visibleViewController?.navigationController?.present(playerVC, animated: true, completion: nil)
|
|
|
|
- } else {
|
|
|
|
- UIApplication.shared.visibleViewController?.present(playerVC, animated: true, completion: nil)
|
|
|
|
- }
|
|
|
|
- } else if fileType == BroadcastViewController.FILE_TYPE_DOCUMENT {
|
|
|
|
- if let dirPath = paths.first {
|
|
|
|
- let fileURL = URL(fileURLWithPath: dirPath).appendingPathComponent(file)
|
|
|
|
- if FileManager.default.fileExists(atPath: fileURL.path) {
|
|
|
|
- previewItem = fileURL as NSURL
|
|
|
|
- let previewController = QLPreviewController()
|
|
|
|
- let rightBarButton = UIBarButtonItem()
|
|
|
|
- previewController.navigationItem.rightBarButtonItem = rightBarButton
|
|
|
|
- previewController.dataSource = self
|
|
|
|
- previewController.modalPresentationStyle = .overFullScreen
|
|
|
|
-
|
|
|
|
- if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
- UIApplication.shared.visibleViewController?.navigationController?.present(previewController, animated: true, completion: nil)
|
|
|
|
- } else {
|
|
|
|
- UIApplication.shared.visibleViewController?.present(previewController, animated: true, completion: nil)
|
|
|
|
- }
|
|
|
|
|
|
+ } else if fileType == BroadcastViewController.FILE_TYPE_VIDEO {
|
|
|
|
+ //https://qmera.io/filepalio/image/
|
|
|
|
+ let player = AVPlayer(url: URL(string: "https://nexilis.io/get_file?account=\(Nexilis.sAPIKey)&image=\(video)")!)
|
|
|
|
+ let playerVC = AVPlayerViewController()
|
|
|
|
+ playerVC.player = player
|
|
|
|
+ playerVC.modalPresentationStyle = .custom
|
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(playerVC, animated: true, completion: nil)
|
|
} else {
|
|
} else {
|
|
- Download().startHTTP(forKey: file) { (name, progress) in
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- guard progress == 100 else {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- previewItem = fileURL as NSURL
|
|
|
|
- let previewController = QLPreviewController()
|
|
|
|
- let rightBarButton = UIBarButtonItem()
|
|
|
|
- previewController.navigationItem.rightBarButtonItem = rightBarButton
|
|
|
|
- previewController.dataSource = self
|
|
|
|
- previewController.modalPresentationStyle = .overFullScreen
|
|
|
|
-
|
|
|
|
- if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
- UIApplication.shared.visibleViewController?.navigationController?.present(previewController, animated: true, completion: nil)
|
|
|
|
- } else {
|
|
|
|
- UIApplication.shared.visibleViewController?.present(previewController, animated: true, completion: nil)
|
|
|
|
|
|
+ UIApplication.shared.visibleViewController?.present(playerVC, animated: true, completion: nil)
|
|
|
|
+ }
|
|
|
|
+ } else if fileType == BroadcastViewController.FILE_TYPE_DOCUMENT {
|
|
|
|
+ if let dirPath = paths.first {
|
|
|
|
+ let fileURL = URL(fileURLWithPath: dirPath).appendingPathComponent(file)
|
|
|
|
+ if FileManager.default.fileExists(atPath: fileURL.path) {
|
|
|
|
+ previewItem = fileURL as NSURL
|
|
|
|
+ let previewController = QLPreviewController()
|
|
|
|
+ let rightBarButton = UIBarButtonItem()
|
|
|
|
+ previewController.navigationItem.rightBarButtonItem = rightBarButton
|
|
|
|
+ previewController.dataSource = self
|
|
|
|
+ previewController.modalPresentationStyle = .overFullScreen
|
|
|
|
+
|
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(previewController, animated: true, completion: nil)
|
|
|
|
+ } else {
|
|
|
|
+ UIApplication.shared.visibleViewController?.present(previewController, animated: true, completion: nil)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Download().startHTTP(forKey: file) { (name, progress) in
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ guard progress == 100 else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ previewItem = fileURL as NSURL
|
|
|
|
+ let previewController = QLPreviewController()
|
|
|
|
+ let rightBarButton = UIBarButtonItem()
|
|
|
|
+ previewController.navigationItem.rightBarButtonItem = rightBarButton
|
|
|
|
+ previewController.dataSource = self
|
|
|
|
+ previewController.modalPresentationStyle = .overFullScreen
|
|
|
|
+
|
|
|
|
+ if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
|
|
+ UIApplication.shared.visibleViewController?.navigationController?.present(previewController, animated: true, completion: nil)
|
|
|
|
+ } else {
|
|
|
|
+ UIApplication.shared.visibleViewController?.present(previewController, animated: true, completion: nil)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
broadcastVC.modalTransitionStyle = .crossDissolve
|
|
broadcastVC.modalTransitionStyle = .crossDissolve
|
|
if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
if UIApplication.shared.visibleViewController?.navigationController != nil {
|
|
UIApplication.shared.visibleViewController?.navigationController?.present(broadcastVC, animated: true, completion: nil)
|
|
UIApplication.shared.visibleViewController?.navigationController?.present(broadcastVC, animated: true, completion: nil)
|
|
@@ -3249,12 +3263,12 @@ extension Nexilis: MessageDelegate {
|
|
let m = message.mBodies
|
|
let m = message.mBodies
|
|
if !message.getBody(key: CoreMessage_TMessageKey.MERCHANT_NAME).isEmpty {
|
|
if !message.getBody(key: CoreMessage_TMessageKey.MERCHANT_NAME).isEmpty {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
- if !Nexilis.broadcastList.isEmpty {
|
|
|
|
- Nexilis.broadcastList.append(m)
|
|
|
|
- } else {
|
|
|
|
|
|
+// if !Nexilis.broadcastList.isEmpty {
|
|
Nexilis.broadcastList.append(m)
|
|
Nexilis.broadcastList.append(m)
|
|
- Nexilis.shared.showBroadcastMessage(m: m)
|
|
|
|
- }
|
|
|
|
|
|
+// } else {
|
|
|
|
+// Nexilis.broadcastList.append(m)
|
|
|
|
+// Nexilis.shared.showBroadcastMessage(m: m)
|
|
|
|
+// }
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|