// // InformasiSertifikasiVC.swift // Sirani // // Created by Anhar Solehudin on 31/03/19. // Copyright © 2019 Anhar Solehudin. All rights reserved. // import UIKit class InformasiSertifikasiVC: UIViewController { @IBOutlet weak var informasiSertifikasiTV: UITableView! private let informasiSertifikasiList = [ OptionItem(label: "Persyaratan dan Kewajiban", value: 0), OptionItem(label: "Prosedur Sertifikasi", value: 1), OptionItem(label: "Prosedur Perubahan", value: 2), OptionItem(label: "Informasi Pembayaran SIMPONI", value: 3), OptionItem(label: "Prosedur Penerbitan, Perubahan, dan Pencabutan", value: 4), OptionItem(label: "Prosedur Keluhan dan Banding", value: 5) ] private var selectedInformasiSertifikasi: OptionItem? // View Lifecycles override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } override func viewDidLoad() { super.viewDidLoad() informasiSertifikasiTV.delegate = self informasiSertifikasiTV.dataSource = self informasiSertifikasiTV.tableFooterView = UIView() } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let destVC = segue.destination as? DetailInformasiSertifikasiVC { let selectedInfo = selectedInformasiSertifikasi?.value as? Int ?? 0 let selectedLabel = selectedInformasiSertifikasi?.label ?? "" destVC.selectedInfo = selectedInfo destVC.subtitleLabel = selectedLabel } } @IBAction func onBackTapped(_ sender: Any) { performSegue(withIdentifier: "unwindInfoSertifikasiToHome", sender: self) } @IBAction func unwindToInfoSertifikasi(segue: UIStoryboardSegue) {} } extension InformasiSertifikasiVC: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return informasiSertifikasiList.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if let cell = tableView.dequeueReusableCell(withIdentifier: "InformasiSertifikasiCell", for: indexPath) as? OptionsCell { let optionItem = informasiSertifikasiList[indexPath.row] cell.updateViews(item: optionItem) return cell } else { return OptionsCell() } } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { selectedInformasiSertifikasi = informasiSertifikasiList[indexPath.row] performSegue(withIdentifier: "DetailInformasiSertifikasiSegueId", sender: self) } }