jsdw_ios/QuickLocation/Section/Home/SearchLocation/SearchLocationResultView.swift

415 lines
13 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// SearchLocationResultView.swift
// QuickLocation
//
// Created by on 2026/6/27.
//
import UIKit
import RxSwift
import RxCocoa
import Lottie
class SearchLocationResultView: UIView {
var disposeBag = DisposeBag()
private func setupRx() {
backBtn.rx.tap.subscribe(onNext: { _ in
AppRouter.shared.popOrDismiss()
}).disposed(by: disposeBag)
}
private func setupUI() {
addSubview(unlockVipView)
addSubview(navBgView)
addSubview(navBarView)
navBarView.addSubview(navTitleLabel)
navBarView.addSubview(backBtn)
addSubview(normalView)
addSubview(successLottieView)
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)
unlockVipView.layoutChain.edges()
successLottieView.layoutChain.edges()
normalView.layoutChain
.topToBottomOfView(navBarView)
.edges(excludingEdge: .top)
}
// MARK: - Views
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
}()
// MARK: - Lottie
lazy var successLottieView: LottieAnimationView = {
let view = LottieAnimationView(name: "phone_search_fireworks")
view.loopMode = .loop
view.isUserInteractionEnabled = false
return view
}()
// MARK: - vip
lazy var normalView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.addSubview(normalLottieView)
normalLottieView.layoutChain
.top(20)
.width(270)
.heightToWidth(1)
.centerX()
view.addSubview(phoneAreaLab)
phoneAreaLab.layoutChain
.topToBottomOfView(normalLottieView)
.centerX()
view.addSubview(messageLab)
messageLab.layoutChain
.topToBottomOfView(phoneAreaLab, offset: 10)
.centerX()
view.addSubview(tipsLab)
tipsLab.layoutChain
.topToBottomOfView(messageLab, offset: 15)
.edgesHorzontal(31)
view.addSubview(inviteBtn)
inviteBtn.layoutChain
.topToBottomOfView(tipsLab, offset: 30)
.edgesHorzontal(68)
.height(50)
view.addSubview(inviteView)
inviteView.layoutChain
.topToBottomOfView(tipsLab, offset: 25)
.edgesHorzontal(15)
.height(80)
return view
}()
lazy var phoneAreaLab: UILabel = {
let label = UILabel()
label.text = " "
label.font = .systemFont(ofSize: 20, weight: .semibold)
label.textColor = UIColor(hexStr: "#16B3FF")
return label
}()
lazy var messageLab: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 16, weight: .bold)
label.textColor = UIColor(hexStr: "#333333")
return label
}()
lazy var tipsLab: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 12, weight: .medium)
label.textColor = UIColor(hexStr: "#999999")
label.numberOfLines = 0
return label
}()
lazy var normalLottieView: LottieAnimationView = {
let view = LottieAnimationView()
view.loopMode = .loop
return view
}()
lazy var inviteBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("邀请Ta加入", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal)
btn.cornerRadius = 25
btn.isHidden = true
return btn
}()
lazy var inviteView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hexStr: "#EFF9FF")
view.cornerRadius = 16
view.isHidden = true
view.addSubview(successBtn)
successBtn.layoutChain
.right(15)
.centerY()
.width(90)
.height(36)
view.addSubview(successTipsLab)
successTipsLab.layoutChain
.topToCenterYOfView(view)
.left(15)
view.addSubview(phoneLab)
phoneLab.layoutChain
.bottomToCenterYOfView(view)
.left(15)
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.text = "邀请加入圈子后分享位置"
label.font = .systemFont(ofSize: 10, weight: .medium)
label.textColor = UIColor(hexStr: "#999999")
return label
}()
lazy var successBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("邀请Ta", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal)
btn.cornerRadius = 18
return btn
}()
// MARK: - vip
lazy var unlockVipView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.clipsToBounds = true
view.isHidden = true
let bgImgView = UIImageView(image: UIImage(named: "SearchLocation/result_bg"))
bgImgView.contentMode = .scaleAspectFill
view.addSubview(bgImgView)
bgImgView.layoutChain
.edges(excludingEdge: .bottom)
.heightToWidth(457/357)
view.addSubview(unlockVipLottieView)
unlockVipLottieView.layoutChain
.edgesHorzontal(60)
.heightToWidth(1)
.top(150)
// .bottomToView(bgImgView, offset: -15)
view.addSubview(unlockVipPhoneAreaLab)
unlockVipPhoneAreaLab.layoutChain
.topToBottomOfView(unlockVipLottieView)
.centerX()
let locationView = UIView()
locationView.backgroundColor = .clear
view.addSubview(locationView)
locationView.layoutChain
.topToBottomOfView(unlockVipPhoneAreaLab, offset: 10)
.centerX()
let locationTitleLab = UILabel()
locationTitleLab.text = "位置:"
locationTitleLab.font = .systemFont(ofSize: 16, weight: .bold)
locationTitleLab.textColor = UIColor(hexStr: "#16B3FF")
locationView.addSubview(locationTitleLab)
locationTitleLab.layoutChain
.left()
.centerY()
let maskView = UIImageView(image: UIImage(named: "SearchLocation/mask"))
locationView.addSubview(maskView)
maskView.layoutChain
.leftToRightOfView(locationTitleLab)
.right()
.edgesVertical()
.width(144)
.height(30)
let unlockVipBtn = UIButton()
unlockVipBtn.setTitle("开通会员", for: .normal)
unlockVipBtn.setTitleColor(.white, for: .normal)
unlockVipBtn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
unlockVipBtn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal)
unlockVipBtn.cornerRadius = 25
unlockVipBtn.rx.tap.subscribe(onNext: { _ in
AppRouter.push(Route.vipRecharge)
}).disposed(by: disposeBag)
view.addSubview(unlockVipBtn)
unlockVipBtn.layoutChain
.edgesHorzontal(15)
.bottom(kSafeBottomMargin + 20)
.height(50)
//
let tipsDot3 = UIView()
tipsDot3.backgroundColor = UIColor(hexStr: "#16B3FF")
tipsDot3.cornerRadius = 2.5
let tipsLab3 = UILabel()
tipsLab3.text = "最后出现地点"
tipsLab3.font = .systemFont(ofSize: 12, weight: .medium)
tipsLab3.textColor = UIColor(hexStr: "#333333")
view.addSubview(tipsLab3)
view.addSubview(tipsDot3)
tipsLab3.layoutChain
.bottomToTopOfView(unlockVipBtn, offset: -20)
.rightToCenterXOfView(view, offset: 30)
tipsDot3.layoutChain
.rightToLeftOfView(tipsLab3, offset: -8)
.width(5)
.heightToWidth(1)
.centerY(tipsLab3)
// "24"
let tipsDot4 = UIView()
tipsDot4.backgroundColor = UIColor(hexStr: "#16B3FF")
tipsDot4.cornerRadius = 2.5
let tipsLab4 = UILabel()
tipsLab4.text = "近24小时轨迹"
tipsLab4.font = .systemFont(ofSize: 12, weight: .medium)
tipsLab4.textColor = UIColor(hexStr: "#333333")
view.addSubview(tipsLab4)
view.addSubview(tipsDot4)
tipsDot4.layoutChain
.leftToCenterXOfView(view, offset: 30)
.width(5)
.heightToWidth(1)
.centerY(tipsLab4)
tipsLab4.layoutChain
.bottomToTopOfView(unlockVipBtn, offset: -20)
.leftToRightOfView(tipsDot4, offset: 8)
// 线
let tipsDot1 = UIView()
tipsDot1.backgroundColor = UIColor(hexStr: "#16B3FF")
tipsDot1.cornerRadius = 2.5
let tipsLab1 = UILabel()
tipsLab1.text = "是否在线"
tipsLab1.font = .systemFont(ofSize: 12, weight: .medium)
tipsLab1.textColor = UIColor(hexStr: "#333333")
view.addSubview(tipsLab1)
view.addSubview(tipsDot1)
tipsDot1.layoutChain
.leftToView(tipsDot3)
.width(5)
.heightToWidth(1)
.centerY(tipsLab1)
tipsLab1.layoutChain
.bottomToTopOfView(tipsLab3, offset: -10)
.leftToRightOfView(tipsDot1, offset: 8)
//
let tipsDot2 = UIView()
tipsDot2.backgroundColor = UIColor(hexStr: "#16B3FF")
tipsDot2.cornerRadius = 2.5
let tipsLab2 = UILabel()
tipsLab2.text = "实时位置变化"
tipsLab2.font = .systemFont(ofSize: 12, weight: .medium)
tipsLab2.textColor = UIColor(hexStr: "#333333")
view.addSubview(tipsLab2)
view.addSubview(tipsDot2)
tipsDot2.layoutChain
.leftToView(tipsDot4)
.width(5)
.heightToWidth(1)
.centerY(tipsLab2)
tipsLab2.layoutChain
.bottomToTopOfView(tipsLab4, offset: -10)
.leftToRightOfView(tipsDot2, offset: 8)
//
let unlockVipTitleLab = UILabel()
unlockVipTitleLab.text = "再迈一步,你就能看到:"
unlockVipTitleLab.font = .systemFont(ofSize: 14, weight: .medium)
unlockVipTitleLab.textColor = UIColor(hexStr: "#16B3FF")
view.addSubview(unlockVipTitleLab)
unlockVipTitleLab.layoutChain
.bottomToTopOfView(tipsLab1, offset: -8)
.centerX()
return view
}()
lazy var unlockVipLottieView: LottieAnimationView = {
let view = LottieAnimationView(name: "phone_search_no_vip")
view.loopMode = .loop
return view
}()
lazy var unlockVipPhoneAreaLab: UILabel = {
let label = UILabel()
label.text = " "
label.font = .systemFont(ofSize: 20, weight: .semibold)
label.textColor = UIColor(hexStr: "#16B3FF")
return label
}()
override init(frame: CGRect) {
super.init(frame: .zero)
backgroundColor = .white
setupUI()
setupRx()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}