|
@@ -21,17 +21,17 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
var startYVisible: CGFloat!
|
|
|
var endYVisible: CGFloat!
|
|
|
var indexSelected = 0
|
|
|
- var updateEditor: (([ImageGrouping], [String: Any?]) -> ())?
|
|
|
+ var updateEditor: (([ImageGrouping], [String: Any?], Bool) -> ())?
|
|
|
var isSelectAll = false
|
|
|
var viewMultipleSelect = UIView()
|
|
|
var constraintBottomViewMultipleSelect: NSLayoutConstraint!
|
|
|
+ let centeredTitleView = CenteredTitleSubtitleView(frame: CGRect(x: 0, y: 0, width: 200, height: 44))
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
view.backgroundColor = .white
|
|
|
|
|
|
- let centeredTitleView = CenteredTitleSubtitleView(frame: CGRect(x: 0, y: 0, width: 200, height: 44))
|
|
|
centeredTitleView.titleLabel.text = titleName
|
|
|
centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
|
|
|
navigationItem.titleView = centeredTitleView
|
|
@@ -55,7 +55,7 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
center.addObserver(self, selector: #selector(onStatusChat(notification:)), name: NSNotification.Name(rawValue: Nexilis.listenerStatusChat), object: nil)
|
|
|
|
|
|
self.view.addSubview(viewMultipleSelect)
|
|
|
- viewMultipleSelect.backgroundColor = .white.withAlphaComponent(0.8)
|
|
|
+ viewMultipleSelect.backgroundColor = .white.withAlphaComponent(0.9)
|
|
|
viewMultipleSelect.anchor(left: self.view.safeAreaLayoutGuide.leftAnchor, right: self.view.safeAreaLayoutGuide.rightAnchor, height: 50)
|
|
|
constraintBottomViewMultipleSelect = viewMultipleSelect.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: 50)
|
|
|
constraintBottomViewMultipleSelect.isActive = true
|
|
@@ -214,7 +214,7 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
iconSelected.anchor(top: containerSelect.topAnchor, left: containerSelect.leftAnchor, paddingTop: 10, paddingLeft: 10, width: 25.0, height: 25.0)
|
|
|
|
|
|
if listGroupingImages[indexPath.row].isSelected {
|
|
|
- containerSelect.backgroundColor = .white.withAlphaComponent(0.1)
|
|
|
+ containerSelect.backgroundColor = .white.withAlphaComponent(0.2)
|
|
|
iconSelected.image = UIImage(systemName: "checkmark.circle.fill")
|
|
|
}
|
|
|
}
|
|
@@ -254,11 +254,11 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
listGroupingImages[indexSelected].dataMessage["is_stared"] = "0"
|
|
|
}
|
|
|
tableViewImages.reloadRows(at: [IndexPath(row: indexSelected, section: 0)], with: .none)
|
|
|
- updateEditor!(listGroupingImages, [:])
|
|
|
+ updateEditor!(listGroupingImages, [:], false)
|
|
|
case 1:
|
|
|
popover.dismiss()
|
|
|
self.navigationController?.popViewController(animated: true)
|
|
|
- updateEditor!([], listGroupingImages[indexSelected].dataMessage)
|
|
|
+ updateEditor!([], listGroupingImages[indexSelected].dataMessage, false)
|
|
|
case 2:
|
|
|
popover.dismiss()
|
|
|
listGroupingImages[indexSelected].isSelected = true
|
|
@@ -349,24 +349,28 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
navigationItem.rightBarButtonItem = doneButton
|
|
|
deleteSession = isDeleteSession
|
|
|
forwardSession = !isDeleteSession
|
|
|
- addSubviewMultipleSelect()
|
|
|
- tableViewImages.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
|
|
|
constraintBottomViewMultipleSelect.constant = 0
|
|
|
UIView.animate(withDuration: 0.35, animations: {
|
|
|
self.view.layoutIfNeeded()
|
|
|
})
|
|
|
+ addSubviewMultipleSelect()
|
|
|
+ tableViewImages.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
|
|
|
tableViewImages.reloadData()
|
|
|
}
|
|
|
|
|
|
@objc func selectAllAction() {
|
|
|
listGroupingImages.forEach({ $0.isSelected = true })
|
|
|
changetoLeftBarButton(isSelectAllButton: false)
|
|
|
+ viewMultipleSelect.subviews.forEach({ $0.removeFromSuperview() })
|
|
|
+ addSubviewMultipleSelect()
|
|
|
tableViewImages.reloadData()
|
|
|
}
|
|
|
|
|
|
@objc func deselectAllAction() {
|
|
|
listGroupingImages.forEach({ $0.isSelected = false })
|
|
|
changetoLeftBarButton(isSelectAllButton: true)
|
|
|
+ viewMultipleSelect.subviews.forEach({ $0.removeFromSuperview() })
|
|
|
+ addSubviewMultipleSelect()
|
|
|
tableViewImages.reloadData()
|
|
|
}
|
|
|
|
|
@@ -403,6 +407,7 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
}
|
|
|
|
|
|
func addSubviewMultipleSelect() {
|
|
|
+ viewMultipleSelect.addTopBorder(with: .lightGray, andWidth: 1)
|
|
|
let container = UIView()
|
|
|
viewMultipleSelect.addSubview(container)
|
|
|
container.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -412,11 +417,6 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
container.bottomAnchor.constraint(equalTo: viewMultipleSelect.bottomAnchor),
|
|
|
container.heightAnchor.constraint(equalToConstant: 50)
|
|
|
])
|
|
|
- container.layer.shadowOpacity = 0.7
|
|
|
- container.layer.shadowOffset = CGSize(width: 3, height: 3)
|
|
|
- container.layer.shadowRadius = 3.0
|
|
|
- container.layer.shadowColor = UIColor.black.cgColor
|
|
|
- container.backgroundColor = .secondaryColor
|
|
|
|
|
|
let title = UILabel()
|
|
|
container.addSubview(title)
|
|
@@ -460,7 +460,77 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
|
|
|
}
|
|
|
|
|
|
@objc func sessionAction() {
|
|
|
-
|
|
|
+ if forwardSession {
|
|
|
+ let tempDataMessages = listGroupingImages.filter({ $0.isSelected })
|
|
|
+ var dataMessages: [[String: Any?]] = []
|
|
|
+ for i in 0..<tempDataMessages.count {
|
|
|
+ dataMessages.append(tempDataMessages[i].dataMessage)
|
|
|
+ }
|
|
|
+ let contactChatNav = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "contactChatNav") as! UINavigationController
|
|
|
+ contactChatNav.modalPresentationStyle = .custom
|
|
|
+ contactChatNav.navigationBar.tintColor = .white
|
|
|
+ contactChatNav.navigationBar.barTintColor = .mainColor
|
|
|
+ contactChatNav.navigationBar.isTranslucent = false
|
|
|
+ let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
|
|
|
+ contactChatNav.navigationBar.titleTextAttributes = textAttributes
|
|
|
+ contactChatNav.view.backgroundColor = .mainColor
|
|
|
+ if let controller = contactChatNav.viewControllers.first as? ContactChatViewController {
|
|
|
+ controller.isChooser = { [weak self] scope, pin in
|
|
|
+ if scope == "3" {
|
|
|
+ let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
|
|
|
+ editorPersonalVC.unique_l_pin = pin
|
|
|
+ editorPersonalVC.dataMessageForward = dataMessages
|
|
|
+ self?.navigationController?.replaceAllViewController(with: editorPersonalVC, animated: true)
|
|
|
+ } else {
|
|
|
+ let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
|
|
|
+ editorGroupVC.unique_l_pin = pin
|
|
|
+ editorGroupVC.dataMessageForward = dataMessages
|
|
|
+ self?.navigationController?.replaceAllViewController(with: editorGroupVC, animated: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.present(contactChatNav, animated: true, completion: nil)
|
|
|
+ } else if deleteSession {
|
|
|
+ let tempDataMessages = listGroupingImages.filter({ $0.isSelected })
|
|
|
+ var countSelected = tempDataMessages.count
|
|
|
+ if countSelected == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let alertController = LibAlertController(title: "Delete".localized() + " \(countSelected) " + "messages?", message: nil, preferredStyle: .actionSheet)
|
|
|
+
|
|
|
+ if let action = self.actionDelete(for: "me", title: "Delete".localized() + " \(countSelected) " + "For Me".localized(), dataMessages: tempDataMessages) {
|
|
|
+ alertController.addAction(action)
|
|
|
+ }
|
|
|
+ let idMe = UserDefaults.standard.string(forKey: "me") as String?
|
|
|
+ if tempDataMessages[0].dataMessage["f_pin"] as? String == idMe {
|
|
|
+ if let action = self.actionDelete(for: "everyone", title: "Delete".localized() + " \(countSelected) " + "For Everyone".localized(), dataMessages: tempDataMessages) {
|
|
|
+ alertController.addAction(action)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alertController.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel, handler: nil))
|
|
|
+ self.present(alertController, animated: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private func actionDelete(for type: String, title: String, dataMessages: [ImageGrouping]) -> UIAlertAction? {
|
|
|
+ return UIAlertAction(title: title, style: .destructive) { [unowned self] _ in
|
|
|
+ for i in 0..<dataMessages.count {
|
|
|
+ if (type == "me") {
|
|
|
+ self.deleteMessage(l_pin: dataMessages[i].lPin, message_id: dataMessages[i].messageId, scope: "3", type: "1", chat: "")
|
|
|
+ listGroupingImages.removeAll(where: { $0.messageId == dataMessages[i].messageId })
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
|
|
|
+ updateEditor!(listGroupingImages, [:], true)
|
|
|
+ doneAction()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private func deleteMessage(l_pin: String, message_id: String, scope: String, type: String, chat: String) {
|
|
|
+ let tmessage = CoreMessage_TMessageBank.deleteMessage(l_pin: l_pin, messageId: message_id, scope: scope, type: type, chat: chat)
|
|
|
+ Nexilis.deleteQueueMessage(message: tmessage)
|
|
|
}
|
|
|
|
|
|
static func getImageSize(image: String, screenWidth: CGFloat, screenHeight: CGFloat) -> CGSize? {
|