Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // TransaksiDetailViewController.swift
- // Logan Warehouse
- //
- // Created by Logan on 14/11/19.
- // Copyright (c) 2019 Ilham Malik Ibrahim. All rights reserved.
- //
- /// Modify By: * Ilham Malik Ibrahim
- // * ilhammalik19@gmail.com
- // * https://github.com/ilhammalik11
- //
- import UIKit
- import Alamofire
- import Toaster
- protocol setDone {
- func setCallBack()
- }
- class PaymentCell: UICollectionViewCell {
- @IBOutlet open weak var titleLabel: UILabel!
- @IBOutlet open weak var dateLabel: UILabel!
- @IBOutlet open weak var nominalLabel: UILabel!
- override func layoutSubviews() {
- super.layoutSubviews()
- }
- }
- class TransaksiQuotationCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {
- @IBOutlet open weak var titleLabel: UILabel!
- @IBOutlet open weak var subtitleLabel: UILabel!
- @IBOutlet open weak var capasitasLabel: UILabel!
- @IBOutlet open weak var mulaisewaLabel: UILabel!
- @IBOutlet open weak var selesaiLabel: UILabel!
- @IBOutlet open weak var kebutuhanLabel: UILabel!
- @IBOutlet open weak var storageLabel: UILabel!
- @IBOutlet open weak var totalLabel: UILabel!
- @IBOutlet open weak var pembayaranLabel: UILabel!
- @IBOutlet open weak var pembayaran2Label: UILabel!
- @IBOutlet open weak var pembayaran3Label: UILabel!
- @IBOutlet open weak var descLabel: UILabel!
- @IBOutlet open weak var collectionView: UICollectionView!
- let screenSize: CGRect = UIScreen.main.bounds
- private let cellReuseIdentifier = "cell"
- var data = [TransaksiDetail.Model.Fetch.PaymentSchedule]()
- override func layoutSubviews() {
- super.layoutSubviews()
- self.collectionView.register(UINib(nibName: "Cell_Payment", bundle: nil), forCellWithReuseIdentifier:cellReuseIdentifier)
- collectionView.delegate = self
- collectionView.dataSource = self
- }
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
- {
- return self.data.count
- }
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
- {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseIdentifier, for: indexPath) as! PaymentCell
- cell.titleLabel.text = checkNull(sender: data[indexPath.row].remarks)
- cell.dateLabel.text = convertStringUNIXDateIndo(data: checkNullInt(sender: data[indexPath.row].date))
- cell.nominalLabel.text = "Rp. \(checkNullInt(sender: data[indexPath.row].nominal))"
- return cell
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
- {
- return CGSize(width: screenSize.width-20, height: 30)
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets
- {
- return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- }
- override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
- let height = collectionView.contentSize.height
- return CGSize(width: targetSize.width, height: height)
- }
- }
- class TransaksiDetailCell: UITableViewCell {
- @IBOutlet open weak var avatar: UIImageView!
- @IBOutlet open weak var titleLabel: UILabel!
- @IBOutlet open weak var subtitleLabel: UILabel!
- @IBOutlet open weak var capasitasLabel: UILabel!
- @IBOutlet open weak var mulaisewaLabel: UILabel!
- @IBOutlet open weak var selesaiLabel: UILabel!
- @IBOutlet open weak var kebutuhanLabel: UILabel!
- @IBOutlet open weak var storageLabel: UILabel!
- @IBOutlet open weak var companyLabel: UILabel!
- @IBOutlet open weak var kontakLabel: UILabel!
- @IBOutlet open weak var statusLabel: UITextField!
- @IBOutlet open weak var dateLabel: UILabel!
- }
- class FeatureCell: UICollectionViewCell {
- @IBOutlet open weak var titleLabel: UILabel!
- override func layoutSubviews() {
- super.layoutSubviews()
- contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 5, left: 0, bottom: 10, right: 0))
- contentView.backgroundColor = UIColor.white
- contentView.cornerRadiuss = 5
- }
- }
- protocol TransaksiDetailDisplayLogic: class
- {
- func displayModel(viewModel: TransaksiDetail.Model.ViewModel)
- }
- class TransaksiDetailViewController: UITableViewController, TransaksiDetailDisplayLogic,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,setDone,UITextFieldDelegate
- {
- var interactor: TransaksiDetailBusinessLogic?
- var router: (NSObjectProtocol & TransaksiDetailRoutingLogic & TransaksiDetailDataPassing)?
- @IBOutlet open weak var CollectionView: UICollectionView!
- let leftAndRightPaddings: CGFloat = 80.0
- let numberOfItemsPerRow: CGFloat = 7.0
- let screenSize: CGRect = UIScreen.main.bounds
- private let cellReuseIdentifier = "cell"
- var items = ["Fork Lift", "Palet", "Racking","Security"]
- @IBOutlet open weak var avatar: UIImageView!
- @IBOutlet open weak var avatar2: UIImageView!
- @IBOutlet open weak var titleLabel: UILabel!
- @IBOutlet open weak var subtitleLabel: UILabel!
- @IBOutlet open weak var capasitasLabel: UILabel!
- @IBOutlet open weak var mulaisewaLabel: UILabel!
- @IBOutlet open weak var selesaiLabel: UILabel!
- @IBOutlet open weak var kebutuhanLabel: UILabel!
- @IBOutlet open weak var storageLabel: UILabel!
- @IBOutlet open weak var companyLabel: UILabel!
- @IBOutlet open weak var kontakLabel: UILabel!
- @IBOutlet open weak var titleQuotationLabel: UILabel!
- @IBOutlet open weak var placeholdeEmpty: UILabel!
- @IBOutlet open weak var statusLabel: UITextField!
- @IBOutlet open weak var subtitle2Label: UILabel!
- @IBOutlet open weak var regionLabel: UILabel!
- @IBOutlet open weak var capasitas2Label: UILabel!
- @IBOutlet open weak var mulaisewa2Label: UILabel!
- @IBOutlet open weak var selesai2Label: UILabel!
- @IBOutlet open weak var kebutuhan2Label: UILabel!
- @IBOutlet open weak var storage2Label: UILabel!
- @IBOutlet open weak var company2Label: UILabel!
- @IBOutlet open weak var kontak2Label: UILabel!
- @IBOutlet open weak var titleQuotation2Label: UILabel!
- @IBOutlet open weak var status2Label: UITextField!
- @IBOutlet open weak var kontrakUITextfield: UITextField!
- @IBOutlet open weak var dateLabel: UILabel!
- @IBOutlet open weak var titleStatusLabel: UILabel!
- @IBOutlet open weak var titleidLabel: UILabel!
- @IBOutlet open weak var titletrxLabel: UILabel!
- @IBOutlet open weak var views: UIView!
- @IBOutlet open weak var statusTrxLabel: UILabel!
- fileprivate var dataFacility = [TransaksiDetail.Model.Fetch.Facility]()
- fileprivate var dataQuotation = [TransaksiDetail.Model.Fetch.Quotation]()
- var data: TransaksiDetail.Model.Fetch.Data!
- var activityIndicator = LoganToast()
- var activity = LoganLoading()
- // MARK: Setup
- var status = 0
- var isStatus = 0
- var id : String = ""
- var code : String = ""
- var isDetail : Bool = false
- var isHistory : Bool = false
- var strAlasan : String = ""
- var strDesc : String = ""
- var heightBottom : Int = 320
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?){
- super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
- setup()
- }
- required init?(coder aDecoder: NSCoder)
- {
- super.init(coder: aDecoder)
- setup()
- }
- private func setup()
- {
- let viewController = self
- let interactor = TransaksiDetailInteractor()
- let presenter = TransaksiDetailPresenter()
- let router = TransaksiDetailRouter()
- viewController.interactor = interactor
- viewController.router = router
- interactor.presenter = presenter
- presenter.viewController = viewController
- router.viewController = viewController
- router.dataStore = interactor
- }
- // MARK: Routing
- // MARK: View lifecycle
- override func viewDidLoad()
- {
- super.viewDidLoad()
- navigationController?.navigationBar.tintColor = UIColor.black
- CollectionView.delegate = self
- CollectionView.dataSource = self
- navigationItem.title = "Transaksi"
- titleidLabel.text = "Transaksi ID \(code)"
- titletrxLabel.text = "Transaksi ID \(code)"
- kontrakUITextfield.delegate = self
- tableView.frame = tableView.bounds
- // tableView.layoutIfNeeded()
- if(UserDefaults.standard.isVendor() == true){
- titleQuotationLabel.text = "Kontrak Dikirim"
- }
- tableView.register(UINib(nibName: "Cell_Qoutation", bundle: nil), forCellReuseIdentifier: CellId.Dynamic)
- tableView.reloadData()
- addLoganLoading()
- }
- func textFieldDidBeginEditing(_ textField: UITextField) {
- if kontrakUITextfield.isEditing == true{
- view.endEditing(true)
- removeView()
- router?.routeToKontrak(id: "0", status: isStatus)
- }
- }
- override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(true)
- doModel()
- }
- func addLoganLoading(){
- self.navigationController?.view.addSubview(activityIndicator)
- activityIndicator.frame = CGRect(x: 0, y: 60, width: UIScreen.main.bounds.width, height:30)
- }
- func addLoading(){
- self.navigationController?.view.addSubview(activity)
- activity.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)
- }
- func addButtonChat(){
- let button = UIButton(frame: CGRect(x: UIScreen.main.bounds.width-80, y: UIScreen.main.bounds.height-150, width: 100, height: 100))
- button.tag = 2
- button.addTarget(self, action: #selector(showChat), for: .touchUpInside)
- button.setImage(UIImage(named: "ic_chat"), for: .normal)
- self.navigationController?.view.addSubview(button)
- }
- func addViewButton(){
- if let customView = Bundle.main.loadNibNamed("ButtomButton", owner: self, options: nil)?.first as? BottomView {
- customView.tag = 1
- let btn = UserDefaults.standard.isVendor() == true ? "Tolak" : "Batalkan"
- let btn2 = UserDefaults.standard.isVendor() == true ? "Buat Kontrak" : "Terima"
- customView.btn.setTitle("\(btn)", for: .normal)
- customView.btn2.setTitle("\(btn2)", for: .normal)
- customView.btn.addTarget(self, action: #selector(actionTolak), for: .touchUpInside)
- customView.btn2.addTarget(self, action: #selector(actionKontrak), for: .touchUpInside)
- self.navigationController?.view.addSubview(customView)
- customView.frame = CGRect(x: 0, y: UIScreen.main.bounds.height-70, width: UIScreen.main.bounds.width, height:50)
- }
- }
- // MARK: Do Model
- override func viewWillDisappear(_ animated: Bool) {
- super.viewWillDisappear(true)
- if let viewWithTag = self.navigationController?.view.viewWithTag(1) {
- viewWithTag.removeFromSuperview()
- }
- if let viewWithTag = self.navigationController?.view.viewWithTag(2) {
- viewWithTag.removeFromSuperview()
- }
- }
- @objc func showChat(){
- let destinationVC = ChatsViewController()
- destinationVC.id = id
- destinationVC.trxCode = code
- self.navigationController?.pushViewController(destinationVC, animated: true)
- }
- func removeView(){
- if let viewWithTag = self.navigationController?.view.viewWithTag(1) {
- viewWithTag.removeFromSuperview()
- }
- if let viewWithTag = self.navigationController?.view.viewWithTag(2) {
- viewWithTag.removeFromSuperview()
- }
- }
- //@IBOutlet weak var nameTextField: UITextField!
- func doModel()
- {
- let request = TransaksiDetail.Model.Request(id: id)
- interactor?.doModel(request: request)
- }
- func displayModel(viewModel: TransaksiDetail.Model.ViewModel)
- {
- titleLabel.text = checkNull(sender: viewModel.data.warehouseName)
- subtitleLabel.text = checkNull(sender: viewModel.data.warehouseName)
- capasitasLabel.text = "\(checkNullInt(sender: viewModel.data.warehouseCapacity))"
- let startRent = checkNullTypeInt(sender: "\(viewModel.data.startRent)")
- let endRent = checkNullTypeInt(sender: "\(viewModel.data.endRent)")
- let contract = checkNullTypeInt(sender: "\(viewModel.data.contractedAt)")
- let lastBit = checkNullTypeInt(sender: "\(viewModel.data.latestBidAt)")
- let reject = checkNullTypeInt(sender: "\(viewModel.data.rejectedAt)")
- mulaisewaLabel.text = convertStringUNIXDateIndo(data: startRent)
- selesaiLabel.text = convertStringUNIXDateIndo(data: endRent)
- kebutuhanLabel.text = "\(checkNullInt(sender: viewModel.data.demand))"
- storageLabel.text = checkNull(sender: viewModel.data.warehouseStorageType)
- subtitle2Label.text = checkNull(sender: viewModel.data.warehouseRegionName)
- regionLabel.text = checkNull(sender: viewModel.data.warehouseProvinceName)
- mulaisewa2Label.text = convertStringUNIXDateIndo(data: startRent)
- selesai2Label.text = convertStringUNIXDateIndo(data: endRent)
- kebutuhan2Label.text = "\(checkNullInt(sender: viewModel.data.demand)) m2"
- storage2Label.text = checkNull(sender: viewModel.data.warehouseStorageType)
- capasitas2Label.text = "\(checkNullInt(sender: viewModel.data.warehouseCapacity)) m2"
- company2Label.text = checkNull(sender: viewModel.data.warehouseName)
- companyLabel.text = checkNull(sender: viewModel.data.user?.companyName)
- kontakLabel.text = checkNull(sender: viewModel.data.user?.name)
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 0{
- status = 0
- addButtonChat()
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 1 && UserDefaults.standard.isVendor(){
- status = 0
- addButtonChat()
- addViewButton()
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 1 && !UserDefaults.standard.isVendor(){
- status = 0
- addButtonChat()
- addViewButton()
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 2 && !UserDefaults.standard.isVendor(){
- status = 0
- addButtonChat()
- addViewButton()
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 2 && UserDefaults.standard.isVendor(){
- status = 1
- addButtonChat()
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 3 {
- status = 1
- if let viewWithTag = self.navigationController?.view.viewWithTag(1) {
- viewWithTag.removeFromSuperview()
- }
- }
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 3 {
- views.backgroundColor = UIColor.init(hexString: "C74545")
- views.isHidden = false
- status = 3
- titleStatusLabel.text = "Transaksi Batal"
- statusTrxLabel.textColor = UIColor.red
- if let viewWithTag = self.navigationController?.view.viewWithTag(1) {
- viewWithTag.removeFromSuperview()
- }
- heightBottom = 250
- strAlasan = "Api ya belum ada"
- strDesc = "Api ya belum ada"
- isDetail = true
- if let customView = Bundle.main.loadNibNamed("DetailViewTolak", owner: self, options: nil)?.first as? DetailViewTolak {
- customView.tag = 1
- customView.btnLabel.addTarget(self, action: #selector(bottomsheetTolak), for: .touchUpInside)
- self.navigationController?.view.addSubview(customView)
- customView.frame = CGRect(x: 0, y: UIScreen.main.bounds.height-100, width: UIScreen.main.bounds.width, height:100)
- }
- }
- isStatus = checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent)
- if checkStatusInt(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent) == 4 {
- views.backgroundColor = UIColor.init(hexString: "519576")
- views.isHidden = false
- status = 4
- titleStatusLabel.text = "Transaksi Selesai"
- statusTrxLabel.textColor = UIColor.green
- if let viewWithTag = self.navigationController?.view.viewWithTag(1) {
- viewWithTag.removeFromSuperview()
- }
- }
- if(UserDefaults.standard.isVendor() == true){
- statusLabel.text = checkStatusVendor(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent)
- }else{
- statusLabel.text = checkStatus(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent)
- }
- statusTrxLabel.text = checkStatus(contract: contract, reject: reject, lastbit: lastBit, end_rent: endRent)
- avatar.kf.setImage(with: URL(string : "\(checkNull(sender: viewModel.data.warehouseImageURL))"), placeholder:UIImage(named: "ic_placeholder"), options: nil)
- avatar2.kf.setImage(with: URL(string : "\(checkNull(sender: viewModel.data.warehouseImageURL))"), placeholder:UIImage(named: "ic_placeholder_gudang"), options: nil)
- dataFacility = viewModel.data.facilities!
- if dataFacility.count>0 {
- placeholdeEmpty.isHidden = true
- }
- dataQuotation = viewModel.data.quotations!
- data = viewModel.data
- CollectionView.reloadData()
- tableView.reloadData()
- }
- @objc func actionKontrak(_ sender:UIButton){
- removeView()
- if(UserDefaults.standard.isVendor() == false){
- self.activity.startAnimating()
- Alamofire.request(apiCancel+"/\(id)/accept", method: .put, encoding: JSONEncoding.default, headers: APIManager.headersJwt()).responseJSON { response in
- if response.response?.statusCode == 200 || response.response?.statusCode == 201 {
- self.activityIndicator.startAnimating(string: "Transaksi Diprosess")
- self.activity.stopAnimating()
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.0) {
- self.activityIndicator.stopAnimating()
- self.navigationController?.popViewController(animated: true)
- }
- }
- if response.response?.statusCode == 400 || response.response?.statusCode == 401 || response.response?.statusCode == 422 || response.response?.statusCode == 500 {
- self.activityIndicator.stopAnimating()
- self.activity.stopAnimating()
- Toast(text: "Terjadi sesuatu server", delay: 0, duration: 1).show()
- }
- }
- }else{
- router?.routeToKontrak(id:(router?.dataStore!.id)!,status: isStatus)
- }
- }
- @objc func actionTolak(_ sender:UIButton){ bottomsheetTolak() }
- @objc func bottomsheetTolak(){
- let storyboard = UIStoryboard(name: "BottomSheetTolak", bundle: nil)
- let destinationVc = storyboard.instantiateViewController(withIdentifier: "BottomSheetTolakViewController") as! BottomSheetTolakViewController
- destinationVc.id = (router?.dataStore!.id)!
- destinationVc.isDetail = isDetail
- destinationVc.strDesc = strDesc
- destinationVc.strAlasan = strAlasan
- let sheetController = SheetViewController(controller: destinationVc, sizes: [.fixed(CGFloat(heightBottom))])
- destinationVc.delegateDone = self
- sheetController.extendBackgroundBehindHandle = true
- self.present(sheetController, animated: true, completion: { () in
- })
- }
- func setCallBack() {
- self.activityIndicator.startAnimating(string: "Transaksi DiTolak")
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.0) {
- self.activityIndicator.stopAnimating()
- self.navigationController?.popViewController(animated: true)
- }
- }
- @IBAction func actionHistoryPenawaran(_ sender:UIButton){
- router?.routeToPenawaran(id: checkNull(sender: router?.dataStore?.id))
- }
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
- {
- return self.dataFacility.count
- }
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
- {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseIdentifier, for: indexPath) as! FeatureCell
- cell.titleLabel.text = dataFacility[indexPath.row].name
- return cell
- }
- // func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- // return CGSize(width: self.tableView.frame.width / 5, height: 40)
- // }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- let label = UILabel(frame: CGRect.zero)
- label.text = dataFacility[indexPath.row].name
- label.sizeToFit()
- return CGSize(width: label.frame.width, height: 32)
- }
- // dyanmic height
- // func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- // let label = UILabel(frame: CGRect.zero)
- // label.text = textArray[indexPath.item]
- // label.sizeToFit()
- // return CGSize(width: 120, height: label.frame.height)
- // }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
- return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- }
- func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
- let height = CollectionView.contentSize.height
- return CGSize(width: targetSize.width, height: height)
- }
- private struct Section
- {
- static let Static = 1
- static let Static_two = 2
- static let Static_tree = 3
- static let Static_four = 4
- static let Static_five = 5
- static let Static_six = 6
- static let Static_seven = 7
- }
- private struct CellId
- {
- static let Dynamic = "cell"
- }
- func tableView(_ tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool
- {
- return false
- }
- // ----------
- func tableView(_ tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool
- {
- return false
- }
- override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
- {
- if section == Section.Static_tree {
- // count of your data source items
- return dataQuotation.count == 0 ? 0 : 1
- }
- return super.tableView(tableView, numberOfRowsInSection: section)
- }
- override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- if indexPath.section == Section.Static && UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 270
- }
- if indexPath.section == 0 && indexPath.row == 0 && !UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 270
- }
- if indexPath.section == 0 && indexPath.row == 1 && !UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 80
- }
- if indexPath.section == 0 && indexPath.row == 2 && !UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 66
- }
- if indexPath.section == 0 && indexPath.row == 3 && !UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 66
- }
- if indexPath.section == Section.Static_two{
- // custom or calculating height for dynamic cell
- return 44
- }
- if indexPath.section == Section.Static_five && dataQuotation.count == 0 {
- // custom or calculating height for dynamic cell
- return 150
- }
- if indexPath.section == Section.Static_tree {
- // custom or calculating height for dynamic cell
- var paymentData = 30*dataQuotation[indexPath.row].paymentSchedules!.count
- return CGFloat(320+paymentData)
- }
- if indexPath.section == Section.Static_six && status == 1 && UserDefaults.standard.isVendor(){
- // custom or calculating height for dynamic cell
- return 44
- }
- if indexPath.section == Section.Static_four && isHistory == true && dataQuotation.count != 0 {
- // custom or calculating height for dynamic cell
- return 60
- }
- if UserDefaults.standard.isVendor() && indexPath.section == Section.Static_seven{
- // custom or calculating height for dynamic cell
- return 200
- }
- return 0
- }
- // ---------
- override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- if indexPath.section == Section.Static_tree
- {
- var cell = tableView.dequeueReusableCell(withIdentifier: CellId.Dynamic)
- if cell == nil {
- // create dynamic cell from xib or with default style
- cell = UITableViewCell(style: .value1, reuseIdentifier: CellId.Dynamic)
- }
- // customize your dynamic cell
- if let cell = cell {
- var cell = tableView.dequeueReusableCell(withIdentifier: CellId.Dynamic) as! TransaksiQuotationCell;
- if (cell == nil)
- {
- //Functionality goes here when it not needed to happen every time.
- }
- //cell.capasitasLabel.text = "\(checkNullInt(sender: data!.warehouseCapacity)) m2"
- let startRent = checkNullTypeInt(sender: "\(dataQuotation.first?.startRent)")
- let endRent = checkNullTypeInt(sender: "\(dataQuotation.first?.endRent)")
- cell.mulaisewaLabel.text = convertStringUNIXDateIndo(data: startRent)
- cell.selesaiLabel.text = convertStringUNIXDateIndo(data: endRent)
- cell.kebutuhanLabel.text = "\(checkNullInt(sender: data.warehouseCapacity))"
- cell.storageLabel.text = "Rp. \(checkNullInt(sender: dataQuotation.first?.quotationPrice))"
- cell.totalLabel.text = "Rp.\(checkNullInt(sender: dataQuotation.first?.totalQuotationPrice))"
- cell.descLabel.text = checkNull(sender: dataQuotation.first?.remarks)
- cell.data = dataQuotation[indexPath.row].paymentSchedules!
- cell.collectionView.reloadData()
- cell.frame = tableView.bounds
- cell.layoutIfNeeded()
- return cell
- }
- }
- return super.tableView(tableView, cellForRowAt: indexPath as IndexPath)
- }
- override func viewWillAppear(_ animated: Bool) {
- self.tableView.layoutSubviews()
- }
- override func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int {
- if indexPath.section == Section.Static {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static) as IndexPath)
- }
- if indexPath.section == Section.Static_two {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static_two) as IndexPath)
- }
- if indexPath.section == Section.Static_tree {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static_tree) as IndexPath)
- }
- if indexPath.section == Section.Static_four {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static_four) as IndexPath)
- }
- if indexPath.section == Section.Static_five {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static_five) as IndexPath)
- }
- if indexPath.section == Section.Static_seven {
- // use only this indentation level for dynamic cell
- return super.tableView (tableView, indentationLevelForRowAt: NSIndexPath(row: 0, section: Section.Static_seven) as IndexPath)
- }
- return super.tableView(tableView, indentationLevelForRowAt: indexPath)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement