BroadcastModeViewController.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // BroadcastModeTableViewController.swift
  3. // Qmera
  4. //
  5. // Created by Kevin Maulana on 28/09/21.
  6. //
  7. import UIKit
  8. class BroadcastModeViewController: UITableViewController {
  9. var data: [String] = ["One Time".localized(), "Daily".localized(), "Weekly".localized(), "Monthly".localized()]
  10. var selected: String?
  11. override func viewDidLoad() {
  12. super.viewDidLoad()
  13. }
  14. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  15. return data.count
  16. }
  17. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  18. let cell = tableView.dequeueReusableCell(withIdentifier: "reuseCell", for: indexPath )
  19. let selectedCell = data[indexPath.row]
  20. cell.textLabel?.text = selectedCell
  21. cell.accessoryType = selected == selectedCell ? .checkmark : .none
  22. cell.tag = indexPath.row
  23. return cell
  24. }
  25. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  26. let cell = sender as! UITableViewCell
  27. if let destination = segue.destination as? BroadcastViewController {
  28. destination.broadcastModeLabel.text = cell.textLabel?.text
  29. destination.broadcastModeLabel.tag = cell.tag
  30. destination.mode = "\(cell.tag + 1)"
  31. if(cell.tag == 0){
  32. destination.endTimeCell.isHidden = true
  33. }
  34. else {
  35. destination.endTimeCell.isHidden = false
  36. }
  37. destination.tableView.reloadData()
  38. }
  39. }
  40. }