| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- //
- // LNRoomApplySeatPanel.swift
- // Gami
- //
- // Created by OneeChan on 2026/3/11.
- //
- import Foundation
- import UIKit
- import SnapKit
- class LNRoomApplySeatPanel: LNPopupView {
- private let titleLabel = UILabel()
- private let avatarView = UIImageView()
- private let nameLabel = UILabel()
- private let applyButton = UIButton()
-
- private weak var roomSession: LNRoomViewModel?
-
- override init(frame: CGRect) {
- super.init(frame: frame)
-
- setupViews()
- }
-
- func update(_ room: LNRoomViewModel?) {
- roomSession = room
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- extension LNRoomApplySeatPanel {
- private func setupViews() {
- container.backgroundColor = .fill_7
-
- let header = buildHeader()
- container.addSubview(header)
- header.snp.makeConstraints { make in
- make.top.horizontalEdges.equalToSuperview()
- make.height.equalTo(52)
- }
-
- avatarView.sd_setImage(with: URL(string: myUserInfo.avatar))
- avatarView.clipsToBounds = true
- avatarView.contentMode = .scaleAspectFill
- avatarView.layer.cornerRadius = 38
- avatarView.layer.borderWidth = 1
- avatarView.layer.borderColor = .fill
- container.addSubview(avatarView)
- avatarView.snp.makeConstraints { make in
- make.top.equalTo(header.snp.bottom).offset(20)
- make.centerX.equalToSuperview()
- make.width.height.equalTo(76)
- }
-
- nameLabel.text = myUserInfo.nickname
- nameLabel.font = .heading_h2
- nameLabel.textColor = .text_1
- nameLabel.textAlignment = .center
- container.addSubview(nameLabel)
- nameLabel.snp.makeConstraints { make in
- make.horizontalEdges.equalToSuperview()
- make.top.equalTo(avatarView.snp.bottom).offset(13)
- }
-
- applyButton.setTitle(.init(key: "A00322"), for: .normal)
- applyButton.setTitleColor(.text_1, for: .normal)
- applyButton.titleLabel?.font = .heading_h3
- applyButton.setBackgroundImage(.primary_8, for: .normal)
- applyButton.layer.cornerRadius = 23.5
- applyButton.clipsToBounds = true
- applyButton.addAction(UIAction(handler: { [weak self] _ in
- guard let self else { return }
- guard let roomSession else { return }
- roomSession.applySeat { [weak self] success in
- guard let self else { return }
- guard success else { return }
- dismiss()
- }
- }), for: .touchUpInside)
- container.addSubview(applyButton)
- applyButton.snp.makeConstraints { make in
- make.horizontalEdges.equalToSuperview().inset(16)
- make.top.equalTo(nameLabel.snp.bottom).offset(46)
- make.height.equalTo(47)
- make.bottom.equalToSuperview().offset(commonBottomInset)
- }
- }
-
- private func buildHeader() -> UIView {
- let header = UIView()
-
- titleLabel.font = .heading_h3
- titleLabel.textColor = .text_1
- titleLabel.text = .init(key: "A00330")
- header.addSubview(titleLabel)
- titleLabel.snp.makeConstraints { make in
- make.center.equalToSuperview()
- }
-
- return header
- }
- }
|