LNRoomJoinMenuView.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // LNRoomJoinMenuView.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/3/9.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. class LNRoomJoinMenuView: UIView {
  11. private let button = UIButton()
  12. private let redCountView = UIView()
  13. private let redCountLabel = UILabel()
  14. private weak var roomSession: LNRoomViewModel?
  15. override init(frame: CGRect) {
  16. super.init(frame: frame)
  17. setupViews()
  18. toBeOffMic()
  19. }
  20. func update(_ room: LNRoomViewModel) {
  21. roomSession = room
  22. }
  23. required init?(coder: NSCoder) {
  24. fatalError("init(coder:) has not been implemented")
  25. }
  26. }
  27. extension LNRoomJoinMenuView {
  28. private func setupViews() {
  29. button.backgroundColor = .fill.withAlphaComponent(0.15)
  30. button.setTitleColor(.text_1, for: .normal)
  31. button.titleLabel?.font = .heading_h5
  32. button.contentEdgeInsets = .init(top: 0, left: 12, bottom: 0, right: 12)
  33. button.imageEdgeInsets = .init(top: 0, left: 0, bottom: 0, right: 4)
  34. button.layer.cornerRadius = 15
  35. button.clipsToBounds = true
  36. addSubview(button)
  37. button.snp.makeConstraints { make in
  38. make.edges.equalToSuperview()
  39. }
  40. redCountView.backgroundColor = .fill_6
  41. redCountView.layer.cornerRadius = 7
  42. addSubview(redCountView)
  43. redCountView.snp.makeConstraints { make in
  44. make.trailing.equalToSuperview()
  45. make.centerY.equalTo(snp.top)
  46. make.width.greaterThanOrEqualTo(15)
  47. }
  48. redCountLabel.text = "9"
  49. redCountLabel.font = .body_xs
  50. redCountLabel.textColor = .text_1
  51. redCountView.addSubview(redCountLabel)
  52. redCountLabel.snp.makeConstraints { make in
  53. make.horizontalEdges.equalToSuperview().inset(4)
  54. make.verticalEdges.equalToSuperview()
  55. }
  56. }
  57. private func toBeOffMic() {
  58. redCountView.isHidden = true
  59. button.setBackgroundImage(.primary_8, for: .normal)
  60. button.setImage(.icSeat, for: .normal)
  61. button.setTitle(.init(key: "A00322"), for: .normal)
  62. }
  63. private func toBePending() {
  64. redCountView.isHidden = false
  65. button.setBackgroundImage(nil, for: .normal)
  66. button.setImage(nil, for: .normal)
  67. button.setTitle(.init(key: "A00323"), for: .normal)
  68. }
  69. private func toBeRequests() {
  70. redCountView.isHidden = false
  71. button.setBackgroundImage(nil, for: .normal)
  72. button.setImage(nil, for: .normal)
  73. button.setTitle(.init(key: "A00324"), for: .normal)
  74. }
  75. }