LNIMChatCallMessageCell.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // LNIMChatCallMessageCell.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/2/4.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. import TUICallEngine
  11. class LNIMChatCallMessageCell: LNIMChatBaseMessageCell {
  12. private let contextLabel = UILabel()
  13. override func update(_ data: LNIMMessageData, viewModel: LNIMChatViewModel) {
  14. super.update(data, viewModel: viewModel)
  15. guard let order: LNIMVoiceCallMessage = data.decodeCustomMessage() else { return }
  16. guard let callData = order.callData else { return }
  17. if order.actionType == SignalingActionType.invite.rawValue,
  18. let data = callData.data, data.cmd == "hangup" {
  19. contextLabel.text = .init(key: "C00001") + " " + callData.call_end.timeCountDisplay
  20. } else if order.actionType == SignalingActionType.cancel_Invite.rawValue {
  21. contextLabel.text = .init(key: "C00003")
  22. } else if order.actionType == SignalingActionType.reject_Invite.rawValue {
  23. if callData.data?.cmd == "line_busy" {
  24. contextLabel.text = .init(key: "C00004")
  25. } else {
  26. contextLabel.text = .init(key: "C00005")
  27. }
  28. } else if order.actionType == SignalingActionType.invite_Timeout.rawValue {
  29. contextLabel.text = .init(key: "C00002")
  30. } else {
  31. contextLabel.text = ""
  32. }
  33. }
  34. override func setupViews() {
  35. super.setupViews()
  36. let callIc = UIImageView()
  37. callIc.image = .icImChatCallOver
  38. container.addSubview(callIc)
  39. callIc.snp.makeConstraints { make in
  40. make.centerY.equalToSuperview()
  41. make.leading.equalToSuperview()
  42. }
  43. contextLabel.font = .body_l
  44. contextLabel.textColor = .text_5
  45. contextLabel.numberOfLines = 0
  46. container.addSubview(contextLabel)
  47. contextLabel.snp.makeConstraints { make in
  48. make.verticalEdges.equalToSuperview()
  49. make.trailing.equalToSuperview()
  50. make.leading.equalTo(callIc.snp.trailing).offset(12)
  51. }
  52. }
  53. }