|
@@ -7,10 +7,12 @@
|
|
|
|
|
|
import UIKit
|
|
import UIKit
|
|
|
|
|
|
-class ListGroupImages: UIViewController {
|
|
|
|
|
|
+class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDelegate {
|
|
var listGroupingImages: [ImageGrouping]!
|
|
var listGroupingImages: [ImageGrouping]!
|
|
var imageTapped: Int!
|
|
var imageTapped: Int!
|
|
var titleName: String!
|
|
var titleName: String!
|
|
|
|
+ let tableViewImages = UITableView()
|
|
|
|
+ var isInitiator = false
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
@@ -21,6 +23,84 @@ class ListGroupImages: UIViewController {
|
|
centeredTitleView.titleLabel.text = titleName
|
|
centeredTitleView.titleLabel.text = titleName
|
|
centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
|
|
centeredTitleView.subtitleLabel.text = String(listGroupingImages.count) + " " + "images".localized()
|
|
navigationItem.titleView = centeredTitleView
|
|
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
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|