LNRoomMessageInputView.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // LNRoomMessageInputView.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/3/11.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. class LNRoomMessageInputView: UIView {
  11. private weak var roomSession: LNRoomViewModel?
  12. override init(frame: CGRect) {
  13. super.init(frame: frame)
  14. setupViews()
  15. }
  16. func update(_ room: LNRoomViewModel?) {
  17. roomSession = room
  18. }
  19. required init?(coder: NSCoder) {
  20. fatalError("init(coder:) has not been implemented")
  21. }
  22. }
  23. extension LNRoomMessageInputView {
  24. private func setupViews() {
  25. onTap { [weak self] in
  26. guard let self else { return }
  27. let panel = LNCommonInputPanel()
  28. panel.handler = { [weak self] message in
  29. guard let self else { return }
  30. guard let roomSession else { return }
  31. roomSession.sendMessage(text: message) { success in }
  32. }
  33. panel.popup()
  34. }
  35. backgroundColor = .fill.withAlphaComponent(0.15)
  36. layer.cornerRadius = 15
  37. snp.makeConstraints { make in
  38. make.width.equalTo(140)
  39. make.height.equalTo(30)
  40. }
  41. let titleLabel = UILabel()
  42. titleLabel.text = .init(key: "A00325")
  43. titleLabel.font = .body_s
  44. titleLabel.textColor = .text_1
  45. addSubview(titleLabel)
  46. titleLabel.snp.makeConstraints { make in
  47. make.horizontalEdges.equalToSuperview().inset(10)
  48. make.centerY.equalToSuperview()
  49. }
  50. }
  51. }