// // GroupSettingView.swift // QuickLocation // // Created by 八条 on 2026/6/9. // import UIKit import RxSwift import RxCocoa import TagListView class GroupSettingView: UIView { var disposeBag = DisposeBag() func setupData(_ model: GroupInfoModel) { navTitleLabel.text = model.name groupNameLab.text = model.name groupIcon.image = model.groupIcon groupDescLab.text = model.description.isEmpty ? "暂无描述" : model.description switchBtn.isOn = model.review tagListView.removeAllTags() tagListView.addTags(model.labels) tagListView.tagViews.forEach { $0.layer.cornerRadius = 4 } tagListView.invalidateIntrinsicContentSize() // 通知系统重新算高 auditSwitchView.isHidden = !model.is_owner groupNameEditIcon.isHidden = !model.is_owner groupIconArrowIcon.isHidden = !model.is_owner groupDescEditIcon.isHidden = !model.is_owner groupTagArrowIcon.isHidden = !model.is_owner auditMemberView.isHidden = !model.is_owner removeMemberView.isHidden = !model.is_owner dismissGroupView.isHidden = !model.is_owner leaveGroupView.isHidden = model.is_owner } 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(scrollView) scrollView.addSubview(scrollContentView) scrollContentView.addSubview(infoView) infoView.addSubview(infoStackView) scrollContentView.addSubview(groupManagerTitleLab) scrollContentView.addSubview(groupManagerView) groupManagerView.addSubview(groupManagerStackView) 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) scrollView.layoutChain .topToBottomOfView(navBarView) .edges(excludingEdge: .top) scrollContentView.layoutChain .edges() .widthToView(scrollView) infoView.layoutChain .top(10) .edgesHorzontal(15) infoStackView.layoutChain .edges() groupNameView.layoutChain .height(60) groupIconView.layoutChain .height(60) auditSwitchView.layoutChain .height(57) groupManagerTitleLab.layoutChain .topToBottomOfView(infoView, offset: 20) .left(15) groupManagerView.layoutChain .topToBottomOfView(groupManagerTitleLab, offset: 15) .edgesHorzontal(15) .bottom(30) groupManagerStackView.layoutChain .edges() inviteView.layoutChain.height(57) auditMemberView.layoutChain.height(57) removeMemberView.layoutChain.height(57) dismissGroupView.layoutChain.height(57) leaveGroupView.layoutChain.height(57) } 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.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 scrollView: UIScrollView = { let view = UIScrollView() view.backgroundColor = .clear // view.showsVerticalScrollIndicator = false // view.bounces = false return view }() lazy var scrollContentView: UIView = { let view = UIView() view.backgroundColor = .clear return view }() // MARK: - 圈子信息 lazy var infoView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#F5FBFF") view.cornerRadius = 10 return view }() lazy var infoStackView: UIStackView = { let view = UIStackView(arrangedSubviews: [groupNameView, groupIconView, groupDescView, auditSwitchView, tagView]) view.axis = .vertical view.alignment = .fill view.distribution = .fill view.spacing = 0 view.backgroundColor = .clear return view }() // 圈子名字 lazy var groupNameView: UIView = { let view = UIView() view.backgroundColor = .clear 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) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) view.addSubview(groupNameEditIcon) groupNameEditIcon.layoutChain .right(15) .width(20) .height(20) .centerY() view.addSubview(groupNameLab) groupNameLab.layoutChain .leftToRightOfView(titleLab, offset: 20) .rightToLeftOfView(groupNameEditIcon, offset: -17, relation: .greaterThanOrEqual) .centerY() return view }() lazy var groupNameLab: UILabel = { let label = UILabel() label.textColor = ThemeManager.shared.color.titleAuxColor label.font = .systemFont(ofSize: 14, weight: .medium) return label }() lazy var groupNameEditIcon: UIImageView = { let view = UIImageView(image: UIImage(named: "Group/edit")) view.isHidden = true return view }() // 圈子图标 lazy var groupIconView: UIView = { let view = UIView() view.backgroundColor = .clear 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) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) view.addSubview(groupIconArrowIcon) groupIconArrowIcon.layoutChain .right(15) .width(14) .height(14) .centerY() view.addSubview(groupIcon) groupIcon.layoutChain .leftToRightOfView(titleLab, offset: 20) .centerY() .width(40) .heightToWidth(1) return view }() lazy var groupIcon: UIImageView = { let view = UIImageView() view.backgroundColor = .clear view.contentMode = .scaleAspectFill view.cornerRadius = 10 return view }() lazy var groupIconArrowIcon: UIImageView = { let view = UIImageView(image: UIImage(named: "Group/arrow")) view.isHidden = true return view }() // 圈子描述 lazy var groupDescView: UIView = { let view = UIView() view.backgroundColor = .clear 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) let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) view.addSubview(groupDescEditIcon) groupDescEditIcon.layoutChain .right(15) .width(20) .height(20) .centerY(titleLab) view.addSubview(groupDescLab) groupDescLab.layoutChain .top(20) .leftToRightOfView(titleLab, offset: 20) .rightToLeftOfView(groupDescEditIcon, offset: -17) .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 groupDescEditIcon: UIImageView = { let view = UIImageView(image: UIImage(named: "Group/edit")) view.isHidden = true return view }() // 审核开关 lazy var auditSwitchView: UIView = { let view = UIView() view.backgroundColor = .clear view.clipsToBounds = true 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) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) view.addSubview(switchBtn) switchBtn.layoutChain .right(15) .centerY() .width(51) .height(30) view.isHidden = true return view }() lazy var switchBtn: UISwitch = { let view = UISwitch() view.isOn = false return view }() // 标签 lazy var tagView: UIView = { let view = UIView() view.backgroundColor = .clear 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(groupTagArrowIcon) groupTagArrowIcon.layoutChain .right(15) .width(14) .height(14) .centerY(titleLab) view.addSubview(tagListView) tagListView.layoutChain .top(15) .leftToRightOfView(titleLab, offset: 23) .height(27, relation: .greaterThanOrEqual) .rightToLeftOfView(groupTagArrowIcon, offset: -17) let tipsLab = UILabel() tipsLab.text = "如选择为私密圈子,将不能被分享到探索和被搜索。" tipsLab.textColor = ThemeManager.shared.color.contentColor tipsLab.font = .systemFont(ofSize: 10, weight: .regular) view.addSubview(tipsLab) tipsLab.layoutChain .topToBottomOfView(tagListView, offset: 10) .leftToView(titleLab) .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 groupTagArrowIcon: UIImageView = { let view = UIImageView(image: UIImage(named: "Group/arrow")) view.isHidden = true return view }() // MARK: - 圈子管理 lazy var groupManagerTitleLab: UILabel = { let label = UILabel() label.text = "圈子管理" label.textColor = ThemeManager.shared.color.titleAuxColor label.font = .systemFont(ofSize: 16, weight: .semibold) return label }() lazy var groupManagerView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#F5FBFF") view.cornerRadius = 10 return view }() lazy var groupManagerStackView: UIStackView = { let view = UIStackView(arrangedSubviews: [inviteView, auditMemberView, removeMemberView, dismissGroupView, leaveGroupView]) view.axis = .vertical view.alignment = .fill view.distribution = .fill view.spacing = 0 view.backgroundColor = .clear return view }() // 邀请成员 lazy var inviteView: UIView = { let view = UIView() view.backgroundColor = .clear 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) let icon = UIImageView(image: UIImage(named: "Group/arrow")) view.addSubview(icon) icon.layoutChain .right(15) .width(14) .height(14) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) return view }() // 审核成员 lazy var auditMemberView = { let view = UIView() view.backgroundColor = .clear view.isHidden = true 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) let icon = UIImageView(image: UIImage(named: "Group/arrow")) view.addSubview(icon) icon.layoutChain .right(15) .width(14) .height(14) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) return view }() // 移除成员 lazy var removeMemberView = { let view = UIView() view.backgroundColor = .clear view.isHidden = true 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) let icon = UIImageView(image: UIImage(named: "Group/arrow")) view.addSubview(icon) icon.layoutChain .right(15) .width(14) .height(14) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) return view }() // 解散圈子 lazy var dismissGroupView = { let view = UIView() view.backgroundColor = .clear view.isHidden = true 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) let icon = UIImageView(image: UIImage(named: "Group/arrow")) view.addSubview(icon) icon.layoutChain .right(15) .width(14) .height(14) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) return view }() // 退出圈子 lazy var leaveGroupView = { let view = UIView() view.backgroundColor = .clear view.isHidden = true 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) let icon = UIImageView(image: UIImage(named: "Group/arrow")) view.addSubview(icon) icon.layoutChain .right(15) .width(14) .height(14) .centerY() let line = UIView() line.backgroundColor = ThemeManager.shared.color.lineColor view.addSubview(line) line.layoutChain .bottom() .height(0.5) .edgesHorzontal(15) return view }() override init(frame: CGRect) { super.init(frame: .zero) backgroundColor = .white setupUI() setupRx() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }