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.

75 lines
2.1 KiB

  1. //
  2. // RechargeHistoryCell.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 2019/11/04.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class RechargeHistoryCell: UITableViewCell {
  10. private enum Status: String {
  11. case success = "0"
  12. case failure = "1"
  13. case waiting = "5"
  14. var name: String {
  15. switch self {
  16. case .success:
  17. return "success_uppercase_text".localized()
  18. case .failure:
  19. return "failure_uppercase_text".localized()
  20. case .waiting:
  21. return "waiting_uppercase_text".localized()
  22. }
  23. }
  24. var color: UIColor {
  25. switch self {
  26. case .success:
  27. return .themeBlue
  28. case .failure:
  29. return .themeRed
  30. case .waiting:
  31. return .themeGreen
  32. }
  33. }
  34. }
  35. @IBOutlet private weak var dateLabel: UILabel!
  36. @IBOutlet private weak var cellPhoneLabel: UILabel!
  37. @IBOutlet private weak var cellPhoneCarrierLabel: UILabel!
  38. @IBOutlet private weak var rechargeTypeLabel: UILabel!
  39. @IBOutlet private weak var rechargeAmountLabel: UILabel!
  40. @IBOutlet private weak var rechargeStatusLabel: UILabel!
  41. @IBOutlet private weak var controlNoLabel: UILabel!
  42. @IBOutlet private weak var errorMessage: UILabel!
  43. override func awakeFromNib() {
  44. super.awakeFromNib()
  45. // Initialization code
  46. }
  47. func setModel(with model: RechargeHistory) {
  48. dateLabel.text = model.requestTime
  49. cellPhoneLabel.text = model.phoneNo
  50. cellPhoneCarrierLabel.text = model.chargeType
  51. rechargeTypeLabel.text = model.cardName
  52. rechargeAmountLabel.text = model.productPrice?.decimalToCurrency()
  53. controlNoLabel.text = model.controlNo
  54. errorMessage.text = model.errorMessage
  55. guard let type = Status(rawValue: model.status ?? "0") else {
  56. rechargeStatusLabel.text = Status.failure.name
  57. rechargeStatusLabel.backgroundColor = Status.failure.color
  58. rechargeStatusLabel.layer.cornerRadius = 5
  59. return
  60. }
  61. rechargeStatusLabel.text = type.name
  62. rechargeStatusLabel.backgroundColor = type.color
  63. rechargeStatusLabel.layer.cornerRadius = 5
  64. }
  65. }