Kaynağa Gözat

update grouping images

alqindiirsyam 2 yıl önce
ebeveyn
işleme
460378878d

BIN
appbuilder-ios/DigiXLite/DigiXLite.xcworkspace/xcuserdata/akhmadalqindiirsyam.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 0
appbuilder-ios/DigiXLite/DigiXLite/Resource/id.lproj/Localizable.strings

@@ -318,3 +318,6 @@
 "111:You must Sign In as Admin to use this feature" = "111:Anda harus masuk sebagai admin agar dapat menggunakan fitur ini";
 "112:You already login or registered as Admin" = "112:Anda telah masuk atau terdaftar sebagai admin";
 "113:Password is empty" = "113:Kata sandi kosong";
+"images" = "gambar";
+"Forward All" = "Teruskan Semua";
+"Delete All" = "Hapus Semua";

+ 80 - 1
appbuilder-ios/DigiXLite/DigiXLite/Source/ListGroupImages.swift

@@ -7,10 +7,12 @@
 
 import UIKit
 
-class ListGroupImages: UIViewController {
+class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDelegate {
     var listGroupingImages: [ImageGrouping]!
     var imageTapped: Int!
     var titleName: String!
+    let tableViewImages = UITableView()
+    var isInitiator = false
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -21,6 +23,83 @@ class ListGroupImages: UIViewController {
         centeredTitleView.titleLabel.text = titleName
         centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
         navigationItem.titleView = centeredTitleView
+        
+        tableViewImages.register(UITableViewCell.self, forCellReuseIdentifier: "cellGrupingImages")
+        tableViewImages.dataSource = self
+        tableViewImages.delegate = self
+        tableViewImages.separatorStyle = .none
+        self.view.addSubview(tableViewImages)
+        tableViewImages.anchor(top: self.view.safeAreaLayoutGuide.topAnchor, left: self.view.safeAreaLayoutGuide.leftAnchor, bottom: self.view.safeAreaLayoutGuide.bottomAnchor, right: self.view.safeAreaLayoutGuide.rightAnchor)
+        
+        tableViewImages.scrollToRow(at: IndexPath(row: imageTapped, section: 0), at: .top, animated: false)
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return listGroupingImages.count
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "cellGrupingImages", for: indexPath as IndexPath)
+        cell.contentView.subviews.forEach({ $0.removeFromSuperview() })
+        cell.backgroundColor = .clear
+        cell.selectionStyle = .none
+        
+        let containerImages = UIImageView()
+        cell.contentView.addSubview(containerImages)
+        containerImages.anchor(top: cell.contentView.topAnchor, left: cell.contentView.leftAnchor, bottom: cell.contentView.bottomAnchor, right: cell.contentView.rightAnchor, paddingBottom: 15, height: view.bounds.height - 44)
+        
+        let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
+        let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
+        let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
+        if let dirPath = paths.first {
+            let imageURL = URL(fileURLWithPath: dirPath).appendingPathComponent(listGroupingImages[indexPath.row].imageId)
+            let image    = UIImage(contentsOfFile: imageURL.path)
+            containerImages.image = image
+            if !FileManager.default.fileExists(atPath: imageURL.path) {
+                let blurEffect = UIBlurEffect(style: UIBlurEffect.Style.light)
+                let blurEffectView = UIVisualEffectView(effect: blurEffect)
+                blurEffectView.frame = CGRect(x: 0, y: 0, width: containerImages.frame.size.width, height: containerImages.frame.size.height)
+                blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+                containerImages.addSubview(blurEffectView)
+            }
+
+        }
+        let containerTimeStatus = UIView()
+        containerImages.addSubview(containerTimeStatus)
+        containerTimeStatus.anchor(bottom: containerImages.bottomAnchor, right: containerImages.rightAnchor, height: 15)
+        let widthcontainerTimeStatus = containerTimeStatus.widthAnchor.constraint(equalToConstant: 50)
+        widthcontainerTimeStatus.isActive = true
+        containerTimeStatus.layer.cornerRadius = 5.0
+        containerTimeStatus.layer.masksToBounds = true
+        containerTimeStatus.backgroundColor = .black.withAlphaComponent(0.25)
+        
+        let timeInImage = UILabel()
+        containerTimeStatus.addSubview(timeInImage)
+        let date = Date(milliseconds: Int64(listGroupingImages[indexPath.row].time) ?? 100)
+        let formatter = DateFormatter()
+        formatter.dateFormat = "HH:mm"
+        formatter.locale = NSLocale(localeIdentifier: "id") as Locale?
+        timeInImage.text = formatter.string(from: date as Date)
+        timeInImage.textColor = .white
+        timeInImage.font = UIFont.systemFont(ofSize: 10, weight: .medium)
+        
+        if isInitiator {
+            let statusInImage = UIImageView()
+            containerTimeStatus.addSubview(statusInImage)
+            statusInImage.anchor(right: containerTimeStatus.rightAnchor, centerY: containerTimeStatus.centerYAnchor, width: 15, height: 15)
+            if listGroupingImages[indexPath.row].status == "1" || listGroupingImages[indexPath.row].status == "2"  {
+                statusInImage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: DigiX.self), with: nil)!.withTintColor(UIColor.white)
+            } else if listGroupingImages[indexPath.row].status == "3" {
+                statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: DigiX.self), with: nil)!.withTintColor(UIColor.white)
+            } else {
+                statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: DigiX.self), with: nil)!.withTintColor(UIColor.systemBlue)
+            }
+            timeInImage.anchor(right: statusInImage.leftAnchor, centerY: containerTimeStatus.centerYAnchor, height: 15)
+        } else {
+            timeInImage.anchor(right: containerTimeStatus.rightAnchor, paddingRight: 5, centerY: containerTimeStatus.centerYAnchor, height: 15)
+            widthcontainerTimeStatus.constant = 40
+        }
+        return cell
     }
 }
 

+ 10 - 9
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/EditorPersonal.swift

@@ -3456,7 +3456,13 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
 //        let copyOption = self.copyOption(indexPath: indexPath!)
         let idMe = UserDefaults.standard.string(forKey: "me") as String?
         if isContactCenter {
-            children = [reply, copy]
+            if (groupImages[dataMessages[indexPath!.row]["message_id"] as! String] != nil) {
+                children = [reply, copy]
+            }
+        } else if (groupImages[dataMessages[indexPath!.row]["message_id"] as! String] != nil) {
+            forward.title = "Forward All".localized()
+            delete.title = "Delete All".localized()
+            children = [forward, delete]
         } else if (dataMessages[indexPath!.row]["lock"] != nil && dataMessages[indexPath!.row]["lock"] as! String == "1") || dataMessages[indexPath!.row]["message_scope_id"] as! String == "18" || dataPerson["f_pin"] == "-999" || dataMessages[indexPath!.row]["credential"] as! String == "1" {
             children = [delete]
         } else if blocking == "1" || blocking == "-1" {
@@ -4817,14 +4823,6 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                             blurEffectView.frame = CGRect(x: 0, y: 0, width: listImageThumb[i].frame.size.width, height: listImageThumb[i].frame.size.height)
                             blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                             listImageThumb[i].addSubview(blurEffectView)
-                            if !listImages[i].imageId.isEmpty {
-                                let imageDownload = UIImageView(image: UIImage(systemName: "arrow.down.circle.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 50, weight: .bold, scale: .default)))
-                                listImageThumb[i].addSubview(imageDownload)
-                                imageDownload.tintColor = .black.withAlphaComponent(0.3)
-                                imageDownload.translatesAutoresizingMaskIntoConstraints = false
-                                imageDownload.centerXAnchor.constraint(equalTo: listImageThumb[i].centerXAnchor).isActive = true
-                                imageDownload.centerYAnchor.constraint(equalTo: listImageThumb[i].centerYAnchor).isActive = true
-                            }
                         }
 
                     }
@@ -4869,6 +4867,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                         listImageThumb[i].addGestureRecognizer(objectTap)
                         objectTap.indexImageTapped = i
                         objectTap.listImageFromGrouping = listImages
+                        objectTap.isInitiator = dataMessages[indexPath.row]["f_pin"] as? String == idMe
                     }
                 }
                 if  listImages.count > 4 {
@@ -5383,6 +5382,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
         listGroupingImages.imageTapped = sender.indexImageTapped
         listGroupingImages.listGroupingImages = sender.listImageFromGrouping
         listGroupingImages.titleName = titleText
+        listGroupingImages.isInitiator = sender.isInitiator
         self.navigationController?.pushViewController(listGroupingImages, animated: true)
     }
     
@@ -6175,6 +6175,7 @@ public class ObjectGesture: UITapGestureRecognizer {
     public var indexPath = IndexPath()
     public var indexImageTapped: Int!
     public var listImageFromGrouping: [ImageGrouping]!
+    public var isInitiator: Bool!
 }
 
 class navigationQLPreviewDocument: UIBarButtonItem {

+ 3 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/id.lproj/Localizable.strings

@@ -317,3 +317,6 @@
 "111:You must Sign In as Admin to use this feature" = "111:Anda harus masuk sebagai admin agar dapat menggunakan fitur ini";
 "112:You already login or registered as Admin" = "112:Anda telah masuk atau terdaftar sebagai admin";
 "113:Password is empty" = "113:Kata sandi kosong";
+"images" = "gambar";
+"Forward All" = "Teruskan Semua";
+"Delete All" = "Hapus Semua";

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

@@ -3466,7 +3466,13 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
 //        let copyOption = self.copyOption(indexPath: indexPath!)
         let idMe = UserDefaults.standard.string(forKey: "me") as String?
         if isContactCenter {
-            children = [reply, copy]
+            if (groupImages[dataMessages[indexPath!.row]["message_id"] as! String] != nil) {
+                children = [reply, copy]
+            }
+        } else if (groupImages[dataMessages[indexPath!.row]["message_id"] as! String] != nil) {
+            forward.title = "Forward All".localized()
+            delete.title = "Delete All".localized()
+            children = [forward, delete]
         } else if (dataMessages[indexPath!.row]["lock"] != nil && dataMessages[indexPath!.row]["lock"] as! String == "1") || dataMessages[indexPath!.row]["message_scope_id"] as! String == "18" || dataPerson["f_pin"] == "-999" || dataMessages[indexPath!.row]["credential"] as! String == "1" {
             children = [delete]
         } else if blocking == "1" || blocking == "-1" {
@@ -4827,14 +4833,6 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                             blurEffectView.frame = CGRect(x: 0, y: 0, width: listImageThumb[i].frame.size.width, height: listImageThumb[i].frame.size.height)
                             blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                             listImageThumb[i].addSubview(blurEffectView)
-                            if !listImages[i].imageId.isEmpty {
-                                let imageDownload = UIImageView(image: UIImage(systemName: "arrow.down.circle.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 50, weight: .bold, scale: .default)))
-                                listImageThumb[i].addSubview(imageDownload)
-                                imageDownload.tintColor = .black.withAlphaComponent(0.3)
-                                imageDownload.translatesAutoresizingMaskIntoConstraints = false
-                                imageDownload.centerXAnchor.constraint(equalTo: listImageThumb[i].centerXAnchor).isActive = true
-                                imageDownload.centerYAnchor.constraint(equalTo: listImageThumb[i].centerYAnchor).isActive = true
-                            }
                         }
 
                     }
@@ -4879,6 +4877,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                         listImageThumb[i].addGestureRecognizer(objectTap)
                         objectTap.indexImageTapped = i
                         objectTap.listImageFromGrouping = listImages
+                        objectTap.isInitiator = dataMessages[indexPath.row]["f_pin"] as? String == idMe
                     }
                 }
                 if  listImages.count > 4 {
@@ -5393,6 +5392,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
         listGroupingImages.imageTapped = sender.indexImageTapped
         listGroupingImages.listGroupingImages = sender.listImageFromGrouping
         listGroupingImages.titleName = titleText
+        listGroupingImages.isInitiator = sender.isInitiator
         self.navigationController?.pushViewController(listGroupingImages, animated: true)
     }
     
@@ -6186,6 +6186,7 @@ public class ObjectGesture: UITapGestureRecognizer {
     public var indexPath = IndexPath()
     public var indexImageTapped: Int!
     public var listImageFromGrouping: [ImageGrouping]!
+    public var isInitiator: Bool!
 }
 
 class navigationQLPreviewDocument: UIBarButtonItem {

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

@@ -7,10 +7,12 @@
 
 import UIKit
 
-class ListGroupImages: UIViewController {
+class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDelegate {
     var listGroupingImages: [ImageGrouping]!
     var imageTapped: Int!
     var titleName: String!
+    let tableViewImages = UITableView()
+    var isInitiator = false
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -21,6 +23,84 @@ class ListGroupImages: UIViewController {
         centeredTitleView.titleLabel.text = titleName
         centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
         navigationItem.titleView = centeredTitleView
+        
+        tableViewImages.register(UITableViewCell.self, forCellReuseIdentifier: "cellGrupingImages")
+        tableViewImages.dataSource = self
+        tableViewImages.delegate = self
+        tableViewImages.separatorStyle = .none
+        self.view.addSubview(tableViewImages)
+        tableViewImages.anchor(top: self.view.safeAreaLayoutGuide.topAnchor, left: self.view.safeAreaLayoutGuide.leftAnchor, bottom: self.view.safeAreaLayoutGuide.bottomAnchor, right: self.view.safeAreaLayoutGuide.rightAnchor)
+        
+        tableViewImages.scrollToRow(at: IndexPath(row: imageTapped, section: 0), at: .top, animated: false)
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return listGroupingImages.count
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "cellGrupingImages", for: indexPath as IndexPath)
+        cell.contentView.subviews.forEach({ $0.removeFromSuperview() })
+        cell.backgroundColor = .clear
+        cell.selectionStyle = .none
+        
+        let containerImages = UIImageView()
+        cell.contentView.addSubview(containerImages)
+        containerImages.anchor(top: cell.contentView.topAnchor, left: cell.contentView.leftAnchor, bottom: cell.contentView.bottomAnchor, right: cell.contentView.rightAnchor, paddingBottom: 15, height: view.bounds.height - 44)
+        
+        let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
+        let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
+        let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
+        if let dirPath = paths.first {
+            let imageURL = URL(fileURLWithPath: dirPath).appendingPathComponent(listGroupingImages[indexPath.row].imageId)
+            let image    = UIImage(contentsOfFile: imageURL.path)
+            containerImages.image = image
+            if !FileManager.default.fileExists(atPath: imageURL.path) {
+                let blurEffect = UIBlurEffect(style: UIBlurEffect.Style.light)
+                let blurEffectView = UIVisualEffectView(effect: blurEffect)
+                blurEffectView.frame = CGRect(x: 0, y: 0, width: containerImages.frame.size.width, height: containerImages.frame.size.height)
+                blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+                containerImages.addSubview(blurEffectView)
+            }
+
+        }
+        
+        let containerTimeStatus = UIView()
+        containerImages.addSubview(containerTimeStatus)
+        containerTimeStatus.anchor(bottom: containerImages.bottomAnchor, right: containerImages.rightAnchor, height: 15)
+        let widthcontainerTimeStatus = containerTimeStatus.widthAnchor.constraint(equalToConstant: 50)
+        widthcontainerTimeStatus.isActive = true
+        containerTimeStatus.layer.cornerRadius = 5.0
+        containerTimeStatus.layer.masksToBounds = true
+        containerTimeStatus.backgroundColor = .black.withAlphaComponent(0.25)
+        
+        let timeInImage = UILabel()
+        containerTimeStatus.addSubview(timeInImage)
+        let date = Date(milliseconds: Int64(listGroupingImages[indexPath.row].time) ?? 100)
+        let formatter = DateFormatter()
+        formatter.dateFormat = "HH:mm"
+        formatter.locale = NSLocale(localeIdentifier: "id") as Locale?
+        timeInImage.text = formatter.string(from: date as Date)
+        timeInImage.textColor = .white
+        timeInImage.font = UIFont.systemFont(ofSize: 10, weight: .medium)
+        
+        if isInitiator {
+            let statusInImage = UIImageView()
+            containerTimeStatus.addSubview(statusInImage)
+            statusInImage.anchor(right: containerTimeStatus.rightAnchor, centerY: containerTimeStatus.centerYAnchor, width: 15, height: 15)
+            if listGroupingImages[indexPath.row].status == "1" || listGroupingImages[indexPath.row].status == "2"  {
+                statusInImage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
+            } else if listGroupingImages[indexPath.row].status == "3" {
+                statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
+            } else {
+                statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.systemBlue)
+            }
+            timeInImage.anchor(right: statusInImage.leftAnchor, centerY: containerTimeStatus.centerYAnchor, height: 15)
+        } else {
+            timeInImage.anchor(right: containerTimeStatus.rightAnchor, paddingRight: 5, centerY: containerTimeStatus.centerYAnchor, height: 15)
+            widthcontainerTimeStatus.constant = 40
+        }
+        return cell
     }
 
 }