// // GroupMemberView2.swift // QuickLocation // // Created by 八条 on 2026/8/4. // import UIKit import RxSwift import RxCocoa class GroupMemberView2: UIView { private var navBarHeightConstraint: NSLayoutConstraint? /// 最大化时展开导航占位为 kNaviHeight,收起/dismiss 时为 0 func setNavBarExpanded(_ expanded: Bool) { navBarHeightConstraint?.constant = expanded ? kNaviHeight : 0 } func setupMemberInfo(_ model: GroupMemberModel, isOwner: Bool) { memberNameLab.text = model.nick_name ownView.isHidden = !isOwner statusDotView.backgroundColor = UIColor(hexStr: model.is_online ? "#67EA76" : "#D8D8D8") statusLab.text = model.is_online ? "在线" : "离线" locationLab.text = model.lastLocation } private func setupRx() { } private func setupUI() { addSubview(headerBgView) addSubview(navBarView) addSubview(scrollView) headerBgView.layoutChain .edges(excludingEdge: .bottom) .heightToWidth(160/375) navBarView.layoutChain .edges(excludingEdge: .bottom) .height(0) navBarHeightConstraint = navBarView.jh_constraint( .height, toAttribute: .notAnAttribute, otherView: nil, relation: .equal ) scrollView.layoutChain .topToBottomOfView(navBarView) .edges(excludingEdge: .top) scrollView.isScrollEnabled = false let lineView = UIView() lineView.backgroundColor = .black.withAlphaComponent(0.2) lineView.cornerRadius = 2 addSubview(lineView) lineView.layoutChain .top(9) .centerX() .width(40) .height(4) } lazy var headerBgView: UIImageView = { let view = UIImageView() view.image = UIImage(named: "Home/group_member_bg2") view.backgroundColor = .clear view.contentMode = .scaleAspectFill return view }() lazy var navBarView: UIView = { let view = UIView() view.backgroundColor = .clear view.clipsToBounds = true return view }() lazy var scrollView: UIScrollView = { let view = UIScrollView() view.backgroundColor = .clear view.showsHorizontalScrollIndicator = false view.bounces = false view.addSubview(scrollContentView) scrollContentView.layoutChain.edges().widthToView(view) scrollContentView.addSubview(memberView) memberView.layoutChain .edges() return view }() lazy var scrollContentView: UIView = { let view = UIView() view.backgroundColor = .clear return view }() // MARK: - 成员 lazy var memberView: UIView = { let view = UIView() view.backgroundColor = .clear let icon = UIImageView() icon.image = UIImage(named: "Home/group_name_icon") view.addSubview(icon) icon.layoutChain .top(23) .left(15) .width(18) .heightToWidth(1) view.addSubview(groupNameLab) groupNameLab.layoutChain .leftToRightOfView(icon, offset: 6) .centerY(icon) view.addSubview(changeGroupBtn) changeGroupBtn.layoutChain .centerY(icon) .right(15) .height(20) let memberView = UIView() memberView.backgroundColor = .white memberView.cornerRadius = 20 memberView.addSubview(memberCV) view.addSubview(memberView) memberView.layoutChain .topToBottomOfView(icon, offset: 12) .edgesHorzontal(15) .height(100) memberCV.layoutChain.edges(all: 5) view.addSubview(memberInfoView) memberInfoView.layoutChain .topToBottomOfView(memberView, offset: 12) .edgesHorzontal(15) .height(150) .bottom() return view }() lazy var groupNameLab: UILabel = { let label = UILabel() label.text = " " label.font = .systemFont(ofSize: 16, weight: .bold) label.textColor = UIColor(hexStr: "#353B4F") return label }() lazy var changeGroupBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitle("切换圈子 ", for: .normal) btn.setTitleColor(UIColor(hexStr: "#353B4F"), for: .normal) btn.titleLabel?.font = .systemFont(ofSize: 12, weight: .medium) btn.setImage(UIImage(named: "Common/arrow_right"), for: .normal) btn.semanticContentAttribute = .forceRightToLeft return btn }() /// 成员列表 lazy var memberCV: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: 61, height: 90) layout.minimumLineSpacing = 15 layout.sectionInset = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8) layout.scrollDirection = .horizontal let cv = UICollectionView(frame: .zero, collectionViewLayout: layout) cv.backgroundColor = .clear cv.showsHorizontalScrollIndicator = false cv.register(GroupMemberListCell.self) return cv }() /// 成员信息 lazy var memberInfoView: UIView = { let view = UIView() view.backgroundColor = .white view.cornerRadius = 20 view.addSubview(memberNameLab) memberNameLab.layoutChain .top(20) .left(18) view.addSubview(tagView) tagView.layoutChain .leftToRightOfView(memberNameLab, offset: 6) .centerY(memberNameLab) .height(20) ownView.layoutChain.height(16) let statusView = UIView() statusView.backgroundColor = .clear statusView.addSubview(statusDotView) statusView.addSubview(statusLab) view.addSubview(statusView) statusView.layoutChain .right(18) .centerY(memberNameLab) statusDotView.layoutChain .left() .width(8) .heightToWidth(1) .centerY() statusLab.layoutChain .leftToRightOfView(statusDotView, offset: 4) .edgesVertical() .right() let locationIcon = UIImageView() locationIcon.image = UIImage(named: "Home/member_location") view.addSubview(locationIcon) locationIcon.layoutChain .topToBottomOfView(memberNameLab, offset: 17) .left(20) .width(10) .height(10) view.addSubview(locationLab) locationLab.layoutChain .centerY(locationIcon) .leftToRightOfView(locationIcon, offset: 7) view.addSubview(distanceView) distanceView.layoutChain .right(18) .centerY(locationLab) locationLab.layoutChain.rightToLeftOfView(distanceView, offset: -30, relation: .greaterThanOrEqual) return view }() lazy var memberNameLab: UILabel = { let label = UILabel() label.text = " " label.font = .systemFont(ofSize: 12, weight: .bold) label.textColor = UIColor(hexStr: "#353B4F") return label }() lazy var tagView: UIStackView = { let view = UIStackView(arrangedSubviews: [ownView]) view.axis = .horizontal view.alignment = .center view.spacing = 5 view.backgroundColor = .clear return view }() // 圈主 lazy var ownView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#E3F6FF") view.cornerRadius = 6 view.isHidden = true let label = UILabel() label.textColor = UIColor(hexStr: "#128CC6") label.font = .systemFont(ofSize: 10, weight: .bold) label.text = "圈主" view.addSubview(label) label.layoutChain .edgesVertical(2) .edgesHorzontal(8) return view }() /// 在线状态 lazy var statusDotView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#D8D8D8") view.cornerRadius = 4 return view }() lazy var statusLab: UILabel = { let label = UILabel() label.text = " " label.font = .systemFont(ofSize: 10, weight: .medium) label.textColor = UIColor(hexStr: "#353B4F") return label }() // 位置 lazy var locationLab: UILabel = { let label = UILabel() label.textColor = UIColor(hexStr: "#767676") label.font = .systemFont(ofSize: 12, weight: .medium) return label }() // 距离 lazy var distanceView: UIView = { let view = UIView() view.backgroundColor = UIColor(hexStr: "#353B4F") view.cornerRadius = 6 view.isHidden = true let label = UILabel() label.textColor = UIColor(hexStr: "#58EDFF") label.font = .systemFont(ofSize: 10, weight: .bold) label.text = "距离" view.addSubview(label) label.layoutChain .left(5) .edgesVertical(3) view.addSubview(distanceLab) distanceLab.layoutChain .leftToRightOfView(label, offset: 2) .right(5) .centerY() return view }() lazy var distanceLab: UILabel = { let label = UILabel() label.textColor = .white label.font = .systemFont(ofSize: 10, weight: .bold) return label }() override init(frame: CGRect) { super.init(frame: frame) backgroundColor = UIColor(hexStr: "#FAFAFA") cornerRadius = 30 layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] setupUI() setupRx() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }