// // SearchLocationResultView.swift // QuickLocation // import UIKit import Lottie class SearchLocationResultView: UIView { let headerView = SearchLocationHeaderView() private var vipResultHeightConstraint: NSLayoutConstraint? private func setupUI() { addSubview(navBgView) addSubview(navView) addSubview(scrollView) navBgView.layoutChain .edges(excludingEdge: .bottom) .heightToWidth(160 / 375) navView.layoutChain .edges(excludingEdge: .bottom) .height(kNaviHeight) scrollView.layoutChain .topToBottomOfView(navView) .edges(excludingEdge: .top) } func startMarqueeAnimation() { headerView.startMarqueeAnimation() } func configureResult(status: String, disclaimer: String, showInviteRow: Bool) { statusPillLab.text = status disclaimerLab.text = disclaimer disclaimerLab.textAlignment = disclaimer.contains("去查看") ? .center : .left disclaimerIcon.isHidden = disclaimer.contains("去查看") inviteView.isHidden = !showInviteRow // 隐藏时高度归零,避免仍占 72pt 把卡片撑高 inviteView.layoutChain .topToBottomOfView(disclaimerLab, offset: showInviteRow ? 16 : 0) .height(showInviteRow ? 72 : 0) } func updateVipAccess(isUnlocked: Bool) { normalResultContentView.isHidden = !isUnlocked vipMaskView.isHidden = isUnlocked vipOfferImageView.isHidden = isUnlocked vipResultHeightConstraint?.isActive = !isUnlocked actionBtn.setBackgroundImage( UIImage(named: isUnlocked ? "Common/button_bg_2" : "VipFeature/wide_button_bg"), for: .normal ) } lazy var navBgView: UIImageView = { let iv = UIImageView() iv.image = UIImage(named: "Common/navBar_bg_2") iv.contentMode = .scaleAspectFill return iv }() lazy var navView: BaseNavigationView = { BaseNavigationView(title: " ") }() lazy var scrollView: UIScrollView = { let view = UIScrollView() view.backgroundColor = .clear view.showsVerticalScrollIndicator = false view.bounces = false let contentView = UIView() contentView.backgroundColor = .clear view.addSubview(contentView) contentView.layoutChain.edges().widthToView(view) contentView.addSubview(headerView) headerView.layoutChain.top(12).edgesHorzontal() contentView.addSubview(resultCard) resultCard.layoutChain .topToBottomOfView(headerView, offset: 20) .edgesHorzontal(15) vipResultHeightConstraint = resultCard.heightAnchor.constraint(equalToConstant: 158) contentView.addSubview(actionBtn) actionBtn.layoutChain .topToBottomOfView(resultCard, offset: 24) .edgesHorzontal(30) .height(56) .bottom(kSafeBottomMargin + 30) contentView.addSubview(vipOfferImageView) vipOfferImageView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ vipOfferImageView.trailingAnchor.constraint(equalTo: actionBtn.trailingAnchor, constant: -6), vipOfferImageView.bottomAnchor.constraint(equalTo: actionBtn.topAnchor, constant: 10), vipOfferImageView.widthAnchor.constraint(equalToConstant: 94), vipOfferImageView.heightAnchor.constraint(equalToConstant: 32) ]) return view }() lazy var resultCard: UIView = { let card = UIView() card.backgroundColor = UIColor(hexStr: "#EFF9FF") card.cornerRadius = 16 card.addSubview(resultStackView) resultStackView.layoutChain.edges() resultStackView.addArrangedSubview(normalResultContentView) card.addSubview(vipMaskView) vipMaskView.layoutChain.edges() return card }() private lazy var resultStackView: UIStackView = { let stackView = UIStackView() stackView.axis = .vertical return stackView }() private lazy var normalResultContentView: UIView = { let contentView = UIView() let locationRow = UIView() contentView.addSubview(locationRow) let pinIcon = UIImageView(image: UIImage(named: "Home/member_location")) pinIcon.contentMode = .scaleAspectFit locationRow.addSubview(pinIcon) locationRow.addSubview(phoneAreaLab) // locationRow.addSubview(areaBlurView) pinIcon.layoutChain.left().centerY().width(18).height(18) phoneAreaLab.layoutChain .leftToRightOfView(pinIcon, offset: 6) .right() .top() .bottom() // areaBlurView.layoutChain // .topToView(phoneAreaLab, offset: -2) // .bottomToView(phoneAreaLab, offset: 2) // .leftToView(phoneAreaLab, offset: -4) // .rightToView(phoneAreaLab, offset: 4) locationRow.layoutChain.top(20).centerX() let pillContainer = UIView() pillContainer.backgroundColor = .white pillContainer.cornerRadius = 14 contentView.addSubview(pillContainer) pillContainer.addSubview(statusPillLab) statusPillLab.layoutChain.edgesHorzontal(58).edgesVertical(13) pillContainer.layoutChain .topToBottomOfView(locationRow, offset: 11) .centerX() .height(48) contentView.addSubview(disclaimerIcon) disclaimerIcon.layoutChain .topToBottomOfView(pillContainer, offset: 14) .left(24) .width(12) .height(12) contentView.addSubview(disclaimerLab) disclaimerLab.layoutChain .topToBottomOfView(pillContainer, offset: 11) .leftToRightOfView(disclaimerIcon, offset: 3) .right(23) contentView.addSubview(inviteView) inviteView.layoutChain .topToBottomOfView(disclaimerLab, offset: 0) .edgesHorzontal(12) .height(0) .bottom(16) return contentView }() lazy var phoneAreaLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 18, weight: .bold) label.textColor = UIColor(hexStr: "#293445") return label }() lazy var areaBlurView: UIVisualEffectView = { let view = UIVisualEffectView(effect: UIBlurEffect(style: .light)) view.isUserInteractionEnabled = false view.isHidden = true view.cornerRadius = 4 view.clipsToBounds = true return view }() lazy var statusPillLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 16, weight: .medium) label.textColor = UIColor(hexStr: "#16B3FF") label.textAlignment = .center return label }() private lazy var disclaimerIcon: UIImageView = { let iv = UIImageView(image: UIImage(named: "SearchLocation/warning")) iv.contentMode = .scaleAspectFit return iv }() lazy var disclaimerLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 12, weight: .regular) label.textColor = UIColor(hexStr: "#999999") label.numberOfLines = 0 return label }() lazy var actionBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitleColor(.white, for: .normal) btn.titleLabel?.font = FontManager.boboBold(18) btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal) btn.cornerRadius = 20 btn.isHidden = true return btn }() private lazy var vipOfferImageView: UIImageView = { let view = UIImageView(image: UIImage(named: "VipFeature/limited_offer")) view.contentMode = .scaleAspectFit view.isHidden = true return view }() var inviteBtn: UIButton { actionBtn } lazy var inviteView: UIView = { let view = UIView() view.backgroundColor = .white view.cornerRadius = 12 view.isHidden = true view.addSubview(successBtn) successBtn.layoutChain.right(12).centerY().width(90).height(36) view.addSubview(successTipsLab) successTipsLab.layoutChain.topToCenterYOfView(view).left(12) view.addSubview(phoneLab) phoneLab.layoutChain.bottomToCenterYOfView(view).left(12) return view }() lazy var phoneLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 16, weight: .bold) label.textColor = UIColor(hexStr: "#333333") return label }() lazy var successTipsLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 10, weight: .medium) label.textColor = UIColor(hexStr: "#999999") return label }() lazy var successBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitleColor(.white, for: .normal) btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium) btn.backgroundColor = UIColor(hexStr: "#16B3FF") btn.cornerRadius = 18 return btn }() lazy var vipMaskView: UIButton = { let view = UIButton(type: .custom) view.setBackgroundImage(UIImage(named: "VipFeature/realtime_location"), for: .normal) view.isHidden = true return view }() override init(frame: CGRect) { super.init(frame: .zero) backgroundColor = .white setupUI() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }