You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // HotLineViewController.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon Devik Kim on 23/05/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. import PanModal
  10. class HotLineViewController: UIViewController {
  11. // MARK: Properties
  12. var presenter: HotLineModuleInterface?
  13. let CellHeight: CGFloat = 90
  14. // MARK: Computed Properties
  15. var hotLines: [HotLine]? {
  16. didSet {
  17. tableView.reloadData()
  18. }
  19. }
  20. // MARK: IBOutlets
  21. @IBOutlet weak var tableView: UITableView!
  22. @IBOutlet weak var informationLabel: UILabel!
  23. // MARK: VC's Life cycle
  24. override func viewDidLoad() {
  25. super.viewDidLoad()
  26. setup()
  27. }
  28. // MARK: IBActions
  29. @IBAction func touchHeadOfficeButton(_ sender: UIButton) {
  30. if let url = URL(string: "tel://1588-6864"), UIApplication.shared.canOpenURL(url) {
  31. if #available(iOS 10, *) {
  32. UIApplication.shared.open(url)
  33. } else {
  34. UIApplication.shared.openURL(url)
  35. }
  36. }
  37. }
  38. }
  39. // MARK: HotLineViewInterface
  40. extension HotLineViewController: HotLineViewInterface {
  41. func setHotLine(with model: [HotLine]?) {
  42. hotLines = model
  43. }
  44. func setError(with error: Error) {
  45. alert(type: .error, message: error.localizedDescription)
  46. }
  47. }
  48. // MARK: Other Functions
  49. extension HotLineViewController {
  50. private func setup() {
  51. // all setup should be done here
  52. tableView.dataSource = self
  53. informationLabel.text = "help_you_text".localized()
  54. presenter?.fetchHotLines()
  55. }
  56. }
  57. // MARK: - UITableViewDataSource
  58. extension HotLineViewController: UITableViewDataSource {
  59. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  60. return hotLines?.count ?? 0
  61. }
  62. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  63. guard let cell = tableView.dequeueReusableCell(withIdentifier: "HotLineCell") as? HotLineCell else {
  64. return UITableViewCell()
  65. }
  66. cell.setModel(hotLines?[indexPath.row])
  67. return cell
  68. }
  69. }
  70. // MARK: - PanModalPresentable
  71. extension HotLineViewController: PanModalPresentable {
  72. var panScrollable: UIScrollView? {
  73. return self.tableView
  74. }
  75. var shortFormHeight: PanModalHeight {
  76. return .contentHeight(CellHeight + 100)
  77. }
  78. var longFormHeight: PanModalHeight {
  79. return .maxHeight
  80. }
  81. }