You are on page 1of 2

//

// ReportedIssueListVC.swift
// matrimonyy
//
// Created by iOS Developer on 13/04/21.
// Copyright © 2021 iOS Developer. All rights reserved.
//

import UIKit

class ReportedIssueListVC: UIViewController {


@IBOutlet weak var listTableView: UITableView!
let objIssuesListParameters = IssuesListParameters()

override func viewDidLoad() {


super.viewDidLoad()
listTableView.register(UINib(nibName:
CellIdentifier.ReportedIssueDetailsTableViewCell, bundle: nil),
forCellReuseIdentifier: CellIdentifier.ReportedIssueDetailsTableViewCell)
navigationBarColor()
setBackButton(true)
setNavigationBarTitle("View Reported Issues", isblackcolor: true)
}

override func viewWillAppear(_ animated: Bool) {


super.viewWillAppear(animated)
getIssueList()
}

extension ReportedIssueListVC: UITableViewDataSource,UITableViewDelegate{

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath)


-> CGFloat {
return UITableView.automaticDimension
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) ->


Int {
return objIssuesListParameters.IssueList.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->


UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:
CellIdentifier.ReportedIssueDetailsTableViewCell, for: indexPath) as!
ReportedIssueDetailsTableViewCell
let object = objIssuesListParameters.IssueList[indexPath.row]
cell.updateUI(object)
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {


let object = objIssuesListParameters.IssueList[indexPath.row]
let vc = UIStoryboard.init(name: "Main", bundle:
Bundle.main).instantiateViewController(withIdentifier:
StoryboardIdentifier.SupportTeamChatVC) as? SupportTeamChatVC
vc?.issueID = object.issueID ?? 0
self.navigationController?.pushViewController(vc!, animated: true)
}

//MARK:- Api Calls


extension ReportedIssueListVC{

func getIssueList(){
let memberID = Util.userDefault.integer(forKey:
UserDefaultIdentifier.memberid)
let token = Util.userDefault.string(forKey: UserDefaultIdentifier.token) ??
""
let url = MySingleton.sharedInstance.baseURL + ApiConstant.GetIssueList +
"/\(memberID)"
let parameters = ["":""]
print(url)

requestGETURL(url, VC: self, params:parameters as [String : AnyObject],


isShowProgressBar: true, token: token ,success:{ [self] (data)in
print(data)
let list = data["data"].arrayObject
if list?.count != 0 && list != nil{
objIssuesListParameters.IssueList.removeAll()
objIssuesListParameters.getResponse(list! as NSArray)
listTableView.isScrollEnabled = true
let noDataLabel: UILabel = UILabel(frame: CGRect(x: 0, y: 0,
width: listTableView.bounds.size.width, height: listTableView.bounds.size.height))
noDataLabel.text = ""
listTableView.backgroundView = noDataLabel
listTableView.reloadData()
}else{
objIssuesListParameters.IssueList.removeAll()
let noDataLabel: UILabel = UILabel(frame: CGRect(x: 0, y: 0,
width: listTableView.bounds.size.width, height: listTableView.bounds.size.height))
noDataLabel.text = AlertIdentifier.noRecordFound
noDataLabel.textColor = .black
noDataLabel.textAlignment = .center
noDataLabel.numberOfLines = 0
listTableView.backgroundView = noDataLabel
listTableView.isScrollEnabled = false
}
}) { (error) in
print(error)
}
}

You might also like