268 lines
7.3 KiB
Swift
268 lines
7.3 KiB
Swift
//
|
|
// NavigationView.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/16.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
#if !targetEnvironment(simulator)
|
|
import AMapNaviKit
|
|
#endif
|
|
|
|
class NavigationView: UIView {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
private func setupRx() {
|
|
backBtn.rx.tap.subscribe(onNext: { _ in
|
|
AppRouter.shared.popOrDismiss()
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
|
|
private func setupUI() {
|
|
// addSubview(navBgView)
|
|
|
|
#if !targetEnvironment(simulator)
|
|
addSubview(mapView)
|
|
#endif
|
|
|
|
addSubview(navBarView)
|
|
navBarView.addSubview(backBtn)
|
|
navBarView.addSubview(navTitleLabel)
|
|
|
|
addSubview(bottomView)
|
|
bottomView.addSubview(avatarImgView)
|
|
bottomView.addSubview(nameLab)
|
|
bottomView.addSubview(locationLab)
|
|
bottomView.addSubview(distanceLab)
|
|
bottomView.addSubview(lineView)
|
|
bottomView.addSubview(groupTitleLab)
|
|
bottomView.addSubview(groupIconView)
|
|
bottomView.addSubview(groupNameLab)
|
|
bottomView.addSubview(navigationBtn)
|
|
|
|
// navBgView.layoutChain
|
|
// .edges(excludingEdge: .bottom)
|
|
// .height(kNaviHeight)
|
|
|
|
navBarView.layoutChain
|
|
.edges(excludingEdge: .bottom)
|
|
.height(kNaviHeight)
|
|
|
|
backBtn.layoutChain
|
|
.centerY(navTitleLabel)
|
|
.left(15)
|
|
.width(24).height(24)
|
|
|
|
navTitleLabel.layoutChain
|
|
.top(kStatusBarHeight + 12)
|
|
.centerX()
|
|
|
|
#if !targetEnvironment(simulator)
|
|
mapView.layoutChain
|
|
.top()
|
|
.edgesHorzontal()
|
|
.bottom()
|
|
#endif
|
|
|
|
bottomView.layoutChain
|
|
.edgesHorzontal(15)
|
|
.bottom(kSafeBottomMargin + 25)
|
|
.height(190)
|
|
|
|
avatarImgView.layoutChain
|
|
.top(15)
|
|
.left(15)
|
|
.width(30)
|
|
.height(30)
|
|
|
|
nameLab.layoutChain
|
|
.centerY(avatarImgView)
|
|
.leftToRightOfView(avatarImgView, offset: 8)
|
|
|
|
locationLab.layoutChain
|
|
.topToBottomOfView(avatarImgView, offset: 10)
|
|
.leftToView(avatarImgView)
|
|
.rightToLeftOfView(navigationBtn, offset: -8)
|
|
|
|
navigationBtn.layoutChain
|
|
.right(15)
|
|
.width(83)
|
|
.height(40)
|
|
.centerY(locationLab)
|
|
|
|
distanceLab.layoutChain
|
|
.topToBottomOfView(locationLab, offset: 2)
|
|
.leftToView(locationLab)
|
|
|
|
lineView.layoutChain
|
|
.topToBottomOfView(distanceLab, offset: 12)
|
|
.edgesHorzontal(15)
|
|
.height(0.5)
|
|
|
|
groupTitleLab.layoutChain
|
|
.topToBottomOfView(lineView, offset: 15)
|
|
.left(15)
|
|
|
|
groupIconView.layoutChain
|
|
.topToBottomOfView(groupTitleLab, offset: 10)
|
|
.left(15)
|
|
.width(30)
|
|
.height(30)
|
|
|
|
groupNameLab.layoutChain
|
|
.leftToRightOfView(groupIconView, offset: 10)
|
|
.centerY(groupIconView)
|
|
}
|
|
|
|
func configure(member: CircleMember, groupName: String = "", groupIcon: String = "") {
|
|
avatarImgView.image = UIImage(named: "UserIcon/\(member.avatar)")
|
|
nameLab.text = member.name
|
|
locationLab.text = member.address
|
|
groupIconView.image = UIImage(named: "GroupIcon/\(groupIcon)")
|
|
groupNameLab.text = groupName
|
|
}
|
|
|
|
// 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 v = UIView()
|
|
v.backgroundColor = .clear
|
|
return v
|
|
}()
|
|
|
|
lazy var backBtn: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setImage(UIImage(named: "Common/back"), for: .normal)
|
|
btn.extendEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 30)
|
|
return btn
|
|
}()
|
|
|
|
lazy var navTitleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 18, weight: .medium)
|
|
label.textColor = ThemeManager.shared.color.titleAuxColor
|
|
label.text = "查看位置"
|
|
return label
|
|
}()
|
|
|
|
#if !targetEnvironment(simulator)
|
|
lazy var mapView: MAMapView! = {
|
|
let mv = MAMapView()
|
|
mv.zoomLevel = 14
|
|
mv.showsUserLocation = false
|
|
mv.showsCompass = false
|
|
mv.userTrackingMode = .none
|
|
return mv
|
|
}()
|
|
#endif
|
|
|
|
lazy var bottomView: UIView = {
|
|
let v = UIView()
|
|
v.backgroundColor = .white
|
|
v.layer.cornerRadius = 20
|
|
// v.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
|
|
v.layer.shadowColor = UIColor.black.withAlphaComponent(0.1).cgColor
|
|
v.layer.shadowOffset = CGSize(width: 0, height: -2)
|
|
v.layer.shadowRadius = 10
|
|
v.layer.shadowOpacity = 1
|
|
return v
|
|
}()
|
|
|
|
lazy var lineView: UIView = {
|
|
let v = UIView()
|
|
v.backgroundColor = ThemeManager.shared.color.lineColor
|
|
return v
|
|
}()
|
|
|
|
lazy var avatarImgView: UIImageView = {
|
|
let iv = UIImageView()
|
|
iv.contentMode = .scaleAspectFill
|
|
iv.cornerRadius = 15
|
|
iv.clipsToBounds = true
|
|
iv.backgroundColor = UIColor(hexStr: "#E0E0E0")
|
|
return iv
|
|
}()
|
|
|
|
lazy var nameLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 16, weight: .semibold)
|
|
label.textColor = UIColor(hexStr: "#0F2846")
|
|
return label
|
|
}()
|
|
|
|
lazy var locationLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 12)
|
|
label.textColor = UIColor(hexStr: "#333333")
|
|
return label
|
|
}()
|
|
|
|
lazy var distanceLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 12)
|
|
label.textColor = UIColor(hexStr: "#999999")
|
|
return label
|
|
}()
|
|
|
|
lazy var navigationBtn: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setTitle("开始导航", for: .normal)
|
|
btn.setTitleColor(.white, for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
|
btn.backgroundColor = UIColor(hexStr: "#16B3FF")
|
|
btn.cornerRadius = 6
|
|
return btn
|
|
}()
|
|
|
|
lazy var groupTitleLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "所在圈子"
|
|
label.font = .systemFont(ofSize: 16, weight: .medium)
|
|
label.textColor = .black
|
|
return label
|
|
}()
|
|
|
|
lazy var groupIconView: UIImageView = {
|
|
let iv = UIImageView()
|
|
iv.contentMode = .scaleAspectFill
|
|
return iv
|
|
}()
|
|
|
|
lazy var groupNameLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 14, weight: .medium)
|
|
label.textColor = UIColor(hexStr: "#333333")
|
|
return label
|
|
}()
|
|
|
|
|
|
#if !targetEnvironment(simulator)
|
|
func cleanupMap() {
|
|
mapView?.delegate = nil
|
|
mapView?.removeFromSuperview()
|
|
mapView = nil
|
|
}
|
|
#endif
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = .clear
|
|
setupUI()
|
|
setupRx()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|