// // GroupInfoView.swift // QuickLocation // // Created by 八条 on 2026/6/12. // import UIKit import RxSwift import RxCocoa import TagListView class GroupInfoView: UIView { var disposeBag = DisposeBag() func setupData(_ model: GroupInfoModel) { groupDescLab.text = model.description.isEmpty ? "暂无描述" : model.description tagListView.addTags(model.labels) tagListView.tagViews.forEach { $0.layer.cornerRadius = 4 } tagListView.invalidateIntrinsicContentSize() // 通知系统重新算高 } private func setupRx() { backBtn.rx.tap.subscribe(onNext: { _ in AppRouter.shared.popOrDismiss() }).disposed(by: disposeBag) } private func setupUI() { addSubview(navBgView) addSubview(navBarView) navBarView.addSubview(navTitleLabel) navBarView.addSubview(backBtn) addSubview(groupIcon) addSubview(groupNameLab) addSubview(groupDescView) addSubview(tagView) addSubview(applyBtn) navBgView.layoutChain .edges(excludingEdge: .bottom) .heightToWidth(160/375) navBarView.layoutChain .edges(excludingEdge: .bottom) .height(kNaviHeight) navTitleLabel.layoutChain .top(kStatusBarHeight + 12) .centerY(backBtn) .centerX() backBtn.layoutChain .centerY(navTitleLabel) .left(15) .width(24) .height(24) groupIcon.layoutChain .topToBottomOfView(navBarView, offset: 24) .width(80) .height(80) .centerX() groupNameLab.layoutChain .topToBottomOfView(groupIcon, offset: 4) .centerX() groupDescView.layoutChain .topToBottomOfView(groupNameLab, offset: 30) .edgesHorzontal(15) tagView.layoutChain .topToBottomOfView(groupDescView, offset: 10) .edgesHorzontal(15) applyBtn.layoutChain .edgesHorzontal(30) .bottom(kSafeBottomMargin + 10) .height(50) } lazy var navBgView: UIImageView = { let iv = UIImageView() iv.image = UIImage(named: "Common/navBar_bg_2") iv.contentMode = .scaleAspectFill return iv }() lazy var navBarView: UIView = { let view = UIView() view.backgroundColor = .clear return view }() lazy var navTitleLabel: UILabel = { let label = UILabel() label.text = "圈子资料" label.font = .systemFont(ofSize: 18, weight: .medium) label.textColor = ThemeManager.shared.color.titleAuxColor label.textAlignment = .center return label }() lazy var backBtn: UIButton = { let btn = UIButton(type: .custom) btn.setImage(UIImage(named: "Common/back"), for: .normal) btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100) return btn }() lazy var groupIcon: UIImageView = { let view = UIImageView() view.backgroundColor = .clear view.cornerRadius = 40 return view }() lazy var groupNameLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 16, weight: .medium) label.textColor = ThemeManager.shared.color.titleAuxColor return label }() lazy var groupDescView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#F5FBFF") view.cornerRadius = 10 let titleLab = UILabel() titleLab.text = "圈子描述" titleLab.textColor = ThemeManager.shared.color.titleAuxColor titleLab.font = .systemFont(ofSize: 12, weight: .medium) view.addSubview(titleLab) titleLab.layoutChain .left(15) .width(50) .top(22) view.addSubview(groupDescLab) groupDescLab.layoutChain .top(20) .leftToRightOfView(titleLab, offset: 20) .right(15) .bottom(20) return view }() lazy var groupDescLab: UILabel = { let label = UILabel() label.textColor = ThemeManager.shared.color.titleAuxColor label.font = .systemFont(ofSize: 14, weight: .medium) label.numberOfLines = 0 return label }() // 标签 lazy var tagView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#F5FBFF") view.cornerRadius = 10 let titleLab = UILabel() titleLab.text = "圈子标签" titleLab.textColor = ThemeManager.shared.color.titleAuxColor titleLab.font = .systemFont(ofSize: 12, weight: .medium) view.addSubview(titleLab) titleLab.layoutChain .left(15) .width(50) .top(20) view.addSubview(tagListView) tagListView.layoutChain .top(15) .leftToRightOfView(titleLab, offset: 23) .height(27, relation: .greaterThanOrEqual) .right(15) .bottom(20) return view }() lazy var tagListView: TagListView = { let view = TagListView() view.textFont = UIFont.systemFont(ofSize: 12, weight: .medium) view.textColor = UIColor(hexStr: "#16B3FF") view.tagBackgroundColor = UIColor(hexStr: "#E3F6FF") view.paddingX = 20 // 水平内边距 view.paddingY = 6 // 垂直内边距 view.alignment = .left // 对齐 view.translatesAutoresizingMaskIntoConstraints = false return view }() lazy var applyBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitle("申请加入", for: .normal) btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium) btn.setTitleColor(.white, for: .normal) btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal) btn.cornerRadius = 25 return btn }() override init(frame: CGRect) { super.init(frame: .zero) backgroundColor = .white setupUI() setupRx() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }