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

264 lines
7.9 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
//
import UIKit
import Lottie
class SearchLocationResultView: UIView {
let headerView = SearchLocationHeaderView()
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)
}
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)
contentView.addSubview(actionBtn)
actionBtn.layoutChain
.topToBottomOfView(resultCard, offset: 24)
.edgesHorzontal(30)
.height(56)
.bottom(kSafeBottomMargin + 30)
return view
}()
lazy var resultCard: UIView = {
let card = UIView()
card.backgroundColor = UIColor(hexStr: "#EFF9FF")
card.cornerRadius = 16
let locationRow = UIView()
card.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
card.addSubview(pillContainer)
pillContainer.addSubview(statusPillLab)
statusPillLab.layoutChain.edgesHorzontal(58).edgesVertical(13)
pillContainer.layoutChain
.topToBottomOfView(locationRow, offset: 11)
.centerX()
.height(48)
card.addSubview(disclaimerIcon)
disclaimerIcon.layoutChain
.topToBottomOfView(pillContainer, offset: 14)
.left(24)
.width(12)
.height(12)
card.addSubview(disclaimerLab)
disclaimerLab.layoutChain
.topToBottomOfView(pillContainer, offset: 11)
.leftToRightOfView(disclaimerIcon, offset: 3)
.right(23)
card.addSubview(inviteView)
inviteView.layoutChain
.topToBottomOfView(disclaimerLab, offset: 0)
.edgesHorzontal(12)
.height(0)
.bottom(16)
return card
}()
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
}()
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
}()
// VC
lazy var messageLab: UILabel = statusPillLab
lazy var tipsLab: UILabel = disclaimerLab
lazy var normalLottieView: LottieAnimationView = {
let view = LottieAnimationView()
view.isHidden = true
return view
}()
lazy var successLottieView: LottieAnimationView = {
let view = LottieAnimationView(name: "phone_search_fireworks")
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")
}
}