576 lines
17 KiB
Swift
576 lines
17 KiB
Swift
//
|
|
// ScheduleDetailView.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/25.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class ScheduleDetailView: UIView {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
private func setupRx() {
|
|
backBtn.rx.tap.subscribe(onNext: { _ in
|
|
AppRouter.shared.popOrDismiss()
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
|
|
private func setupUI() {
|
|
addSubview(navBgView)
|
|
addSubview(navBarView)
|
|
navBarView.addSubview(navTitleLabel)
|
|
navBarView.addSubview(backBtn)
|
|
addSubview(headerView)
|
|
addSubview(travelRouteView)
|
|
addSubview(tableView)
|
|
addSubview(bottomView)
|
|
|
|
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)
|
|
|
|
headerView.layoutChain
|
|
.topToBottomOfView(navBarView)
|
|
.edgesHorzontal()
|
|
|
|
travelRouteView.layoutChain
|
|
.topToBottomOfView(headerView)
|
|
.edgesHorzontal()
|
|
|
|
bottomView.layoutChain
|
|
.edgesHorzontal()
|
|
.height(kSafeBottomMargin + 80)
|
|
.bottom()
|
|
|
|
tableView.layoutChain
|
|
.topToBottomOfView(travelRouteView, offset: 15)
|
|
.edgesHorzontal()
|
|
.bottomToTopOfView(bottomView, offset: 0)
|
|
}
|
|
|
|
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
|
|
}()
|
|
|
|
/// 谁在关注
|
|
lazy var headerView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .clear
|
|
|
|
let titleLab = UILabel()
|
|
titleLab.text = "谁在关注"
|
|
titleLab.font = .systemFont(ofSize: 16, weight: .medium)
|
|
titleLab.textColor = ThemeManager.shared.color.titleAuxColor
|
|
view.addSubview(titleLab)
|
|
titleLab.layoutChain
|
|
.top(15)
|
|
|
|
let dotView = UIView()
|
|
dotView.backgroundColor = UIColor(hexStr: "#16B3FF")
|
|
dotView.cornerRadius = 2
|
|
view.addSubview(dotView)
|
|
dotView.layoutChain
|
|
.left(15)
|
|
.centerY(titleLab)
|
|
.width(4)
|
|
.height(11)
|
|
|
|
titleLab.layoutChain.leftToRightOfView(dotView, offset: 5)
|
|
|
|
view.addSubview(collectionView)
|
|
collectionView.layoutChain
|
|
.topToBottomOfView(titleLab, offset: 15)
|
|
.edgesHorzontal()
|
|
.height(80)
|
|
.bottom(15)
|
|
|
|
view.addSubview(noDataLab)
|
|
noDataLab.layoutChain
|
|
.centerX().centerY()
|
|
|
|
return view
|
|
}()
|
|
|
|
lazy var collectionView: UICollectionView = {
|
|
let layout = UICollectionViewFlowLayout()
|
|
layout.scrollDirection = .horizontal
|
|
layout.itemSize = CGSize(width: 80, height: 80)
|
|
layout.minimumLineSpacing = 15
|
|
layout.sectionInset = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
|
|
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
|
cv.backgroundColor = .clear
|
|
cv.showsHorizontalScrollIndicator = false
|
|
cv.register(ViewedCell.self)
|
|
return cv
|
|
}()
|
|
|
|
lazy var noDataLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = " 暂无关注"
|
|
label.textColor = UIColor(hexStr: "#999999")
|
|
label.font = .systemFont(ofSize: 14, weight: .regular)
|
|
label.isHidden = true
|
|
return label
|
|
}()
|
|
|
|
/// 行程日期
|
|
lazy var travelRouteView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .clear
|
|
|
|
let titleLab = UILabel()
|
|
titleLab.text = "行程日期"
|
|
titleLab.font = .systemFont(ofSize: 16, weight: .medium)
|
|
titleLab.textColor = ThemeManager.shared.color.titleAuxColor
|
|
view.addSubview(titleLab)
|
|
titleLab.layoutChain
|
|
.top(5)
|
|
|
|
let dotView = UIView()
|
|
dotView.backgroundColor = UIColor(hexStr: "#16B3FF")
|
|
dotView.cornerRadius = 2
|
|
view.addSubview(dotView)
|
|
dotView.layoutChain
|
|
.left(15)
|
|
.centerY(titleLab)
|
|
.width(4)
|
|
.height(11)
|
|
|
|
titleLab.layoutChain.leftToRightOfView(dotView, offset: 5)
|
|
|
|
view.addSubview(dateLab)
|
|
dateLab.layoutChain
|
|
.centerY(titleLab)
|
|
.leftToRightOfView(titleLab, offset: 10)
|
|
|
|
view.addSubview(creatorIcon)
|
|
creatorIcon.layoutChain
|
|
.right(15)
|
|
.width(30)
|
|
.height(30)
|
|
.centerY(titleLab)
|
|
|
|
let creatorTitleLab = UILabel()
|
|
creatorTitleLab.text = "创建人"
|
|
creatorTitleLab.font = .systemFont(ofSize: 12, weight: .medium)
|
|
creatorTitleLab.textColor = ThemeManager.shared.color.titleAuxColor
|
|
view.addSubview(creatorTitleLab)
|
|
creatorTitleLab.layoutChain
|
|
.rightToLeftOfView(creatorIcon, offset: -5)
|
|
.centerY(titleLab)
|
|
|
|
view.addSubview(vipTipsLab)
|
|
vipTipsLab.layoutChain
|
|
.topToBottomOfView(titleLab, offset: 5)
|
|
.leftToView(titleLab)
|
|
.bottom()
|
|
|
|
return view
|
|
}()
|
|
|
|
lazy var dateLab: UILabel = {
|
|
let label = UILabel()
|
|
label.textColor = UIColor(hexStr: "#16B3FF")
|
|
label.font = .systemFont(ofSize: 14, weight: .medium)
|
|
return label
|
|
}()
|
|
|
|
lazy var creatorIcon: UIImageView = {
|
|
let view = UIImageView()
|
|
view.cornerRadius = 15
|
|
return view
|
|
}()
|
|
|
|
lazy var vipTipsLab: UILabel = {
|
|
let label = UILabel()
|
|
label.textColor = UIColor(hexStr: "#FF7D52")
|
|
label.font = .systemFont(ofSize: 10, weight: .regular)
|
|
return label
|
|
}()
|
|
|
|
lazy var tableView: UITableView = {
|
|
let tv = UITableView(frame: .zero, style: .plain)
|
|
tv.backgroundColor = .clear
|
|
tv.separatorStyle = .none
|
|
tv.estimatedRowHeight = 77
|
|
tv.showsVerticalScrollIndicator = false
|
|
tv.bounces = false
|
|
tv.register(SchedulePointDetailCell.self)
|
|
tv.register(SchedulePointEventCell.self)
|
|
tv.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 15, right: 0)
|
|
return tv
|
|
}()
|
|
|
|
lazy var bottomView: UIView = {
|
|
let v = UIView()
|
|
v.backgroundColor = .white
|
|
v.layer.cornerRadius = 16
|
|
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
|
|
|
|
forwardBtn.isHidden = true
|
|
v.addSubview(forwardBtn)
|
|
v.addSubview(operateBtn)
|
|
v.addSubview(routeBtn)
|
|
|
|
forwardBtn.layoutChain
|
|
.centerY()
|
|
.left(15)
|
|
.width(80)
|
|
|
|
routeBtn.layoutChain
|
|
.centerY()
|
|
.right(15)
|
|
.width(80)
|
|
|
|
operateBtn.layoutChain
|
|
.centerY()
|
|
.leftToRightOfView(forwardBtn, offset: 20)
|
|
.rightToLeftOfView(routeBtn, offset: -20)
|
|
.height(50)
|
|
|
|
return v
|
|
}()
|
|
|
|
lazy var forwardBtn: UIButton = makeVerticalButton(image: UIImage(named: "Schedule/forward"), title: "发送到圈子")
|
|
lazy var routeBtn: UIButton = makeVerticalButton(image: UIImage(named: "Schedule/route"), title: "查看路线")
|
|
|
|
/// 创建图片在上、文字在下的按钮
|
|
private func makeVerticalButton(image: UIImage?, title: String) -> UIButton {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setImage(image, for: .normal)
|
|
btn.setTitle(title, for: .normal)
|
|
btn.setTitleColor(UIColor(hexStr: "#333333"), for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 12, weight: .medium)
|
|
btn.titleLabel?.textAlignment = .center
|
|
btn.imageView?.contentMode = .scaleAspectFit
|
|
// 图片在上、文字在下
|
|
let width = btn.titleLabel?.intrinsicContentSize.width ?? 0
|
|
btn.imageEdgeInsets = UIEdgeInsets(top: -20, left: 0, bottom: 0, right: -width)
|
|
btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: -24, bottom: -24, right: 0)
|
|
btn.contentEdgeInsets = UIEdgeInsets(top: 24, left: 0, bottom: 24, right: 0)
|
|
return btn
|
|
}
|
|
|
|
lazy var operateBtn: UIButton = {
|
|
let btn = UIButton()
|
|
btn.setTitle("取消关注", for: .selected)
|
|
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
|
|
return btn
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: .zero)
|
|
backgroundColor = .white
|
|
setupUI()
|
|
setupRx()
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
// MARK: - SchedulePointDetailCell
|
|
class SchedulePointDetailCell: UITableViewCell {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
func configure(model: SchedulePointModel, index: Int, total: Int) {
|
|
indexLabel.text = "\(index + 1)"
|
|
locationLabel.text = model.street
|
|
remarkLab.text = model.remark.isEmpty ? "备注:无备注" : model.remark
|
|
timeLabel.text = getDateInterval2String(date: "\(model.expected_timestamp / 1000)", dateFormat: "HH:mm")
|
|
|
|
var indexName = ""
|
|
if index == 0 {
|
|
indexName = "起点:"
|
|
}
|
|
else if index == total - 1 {
|
|
indexName = "终点:"
|
|
}
|
|
else {
|
|
indexName = "途经点:"
|
|
}
|
|
indexNameLab.text = indexName
|
|
bottomDashView.isHidden = index == total - 1
|
|
}
|
|
|
|
// MARK: - Init
|
|
override init(style: CellStyle, reuseIdentifier: String?) {
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
selectionStyle = .none
|
|
backgroundColor = .clear
|
|
setupViews()
|
|
}
|
|
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
override func prepareForReuse() {
|
|
super.prepareForReuse()
|
|
disposeBag = DisposeBag()
|
|
}
|
|
|
|
private func setupViews() {
|
|
contentView.addSubview(pointIcon)
|
|
contentView.addSubview(bottomDashView)
|
|
contentView.addSubview(indexLabel)
|
|
contentView.addSubview(indexNameLab)
|
|
contentView.addSubview(locationLabel)
|
|
contentView.addSubview(timeLabel)
|
|
contentView.addSubview(remarkLab)
|
|
|
|
pointIcon.layoutChain
|
|
.top()
|
|
.left(15)
|
|
.width(18).height(18)
|
|
|
|
indexLabel.layoutChain
|
|
.top().leftToRightOfView(pointIcon, offset: 10)
|
|
.width(22).height(20)
|
|
|
|
indexNameLab.layoutChain
|
|
.leftToRightOfView(indexLabel, offset: 5)
|
|
.centerY(indexLabel)
|
|
|
|
locationLabel.layoutChain
|
|
.centerY(indexLabel)
|
|
.leftToRightOfView(indexNameLab, offset: 2)
|
|
.compressionHorizontal(.defaultLow)
|
|
|
|
timeLabel.layoutChain
|
|
.centerY(indexLabel)
|
|
.leftToRightOfView(locationLabel, offset: 20)
|
|
.right(10, relation: .greaterThanOrEqual)
|
|
.compressionHorizontal(.required)
|
|
|
|
remarkLab.layoutChain
|
|
.topToBottomOfView(indexLabel, offset: 5)
|
|
.leftToView(indexLabel)
|
|
.right(15)
|
|
.bottom(10)
|
|
.compressionVertical(.required)
|
|
|
|
bottomDashView.layoutChain
|
|
.topToBottomOfView(pointIcon, offset: 5)
|
|
.centerX(pointIcon)
|
|
.width(0.5)
|
|
.bottom(5)
|
|
}
|
|
|
|
// MARK: - Views
|
|
private let pointIcon: UIImageView = {
|
|
let iv = UIImageView(image: UIImage(named: "Schedule/point"))
|
|
iv.contentMode = .scaleAspectFit
|
|
return iv
|
|
}()
|
|
|
|
private let bottomDashView: DashLineView = {
|
|
let v = DashLineView()
|
|
v.backgroundColor = .clear
|
|
return v
|
|
}()
|
|
|
|
private let indexLabel: UILabel = {
|
|
let l = UILabel()
|
|
l.backgroundColor = UIColor(hexStr: "#DCF4FF")
|
|
l.textColor = UIColor(hexStr: "#176F9B")
|
|
l.font = .systemFont(ofSize: 12, weight: .medium)
|
|
l.textAlignment = .center
|
|
return l
|
|
}()
|
|
|
|
lazy var indexNameLab: UILabel = {
|
|
let l = UILabel()
|
|
l.font = .systemFont(ofSize: 14, weight: .medium)
|
|
l.textColor = UIColor(hexStr: "#16B3FF")
|
|
return l
|
|
}()
|
|
|
|
private let locationLabel: UILabel = {
|
|
let l = UILabel()
|
|
l.font = .systemFont(ofSize: 14, weight: .medium)
|
|
l.textColor = UIColor(hexStr: "#333333")
|
|
// l.numberOfLines = 0
|
|
return l
|
|
}()
|
|
|
|
private let timeLabel: UILabel = {
|
|
let l = UILabel()
|
|
l.font = .systemFont(ofSize: 12, weight: .medium)
|
|
l.textColor = UIColor(hexStr: "#333333")
|
|
l.isUserInteractionEnabled = true
|
|
l.textAlignment = .right
|
|
return l
|
|
}()
|
|
|
|
lazy var remarkLab: UILabel = {
|
|
let l = UILabel()
|
|
l.font = .systemFont(ofSize: 12, weight: .regular)
|
|
l.textColor = UIColor(hexStr: "#999999")
|
|
l.numberOfLines = 0
|
|
return l
|
|
}()
|
|
|
|
override func layoutSubviews() {
|
|
super.layoutSubviews()
|
|
contentView.layoutIfNeeded()
|
|
indexLabel.setCornerRadius(corners: [.bottomRight, .topLeft], withCornerRadii: CGSize(width: 10, height: 10))
|
|
}
|
|
}
|
|
|
|
// MARK: - SchedulePointEventCell
|
|
class SchedulePointEventCell: UITableViewCell {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
func configure(model: SchedulePointEventModel, index: Int, total: Int) {
|
|
var suffix = ""
|
|
if index == 0 {
|
|
suffix = " 起点"
|
|
} else if index == total - 1 {
|
|
suffix = " 终点"
|
|
} else {
|
|
suffix = " 途经点"
|
|
}
|
|
infoLab.text = model.text + "到达" + suffix
|
|
}
|
|
|
|
// MARK: - Init
|
|
override init(style: CellStyle, reuseIdentifier: String?) {
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
selectionStyle = .none
|
|
backgroundColor = .clear
|
|
setupViews()
|
|
}
|
|
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
override func prepareForReuse() {
|
|
super.prepareForReuse()
|
|
disposeBag = DisposeBag()
|
|
}
|
|
|
|
private func setupViews() {
|
|
contentView.addSubview(verticalDashLineView)
|
|
contentView.addSubview(horizontalDashLineView)
|
|
contentView.addSubview(dotView)
|
|
contentView.addSubview(infoView)
|
|
infoView.addSubview(infoLab)
|
|
|
|
verticalDashLineView.layoutChain
|
|
.left(24)
|
|
.edgesVertical()
|
|
.width(1)
|
|
|
|
dotView.layoutChain
|
|
.centerX(verticalDashLineView)
|
|
.centerY()
|
|
.width(8)
|
|
.height(8)
|
|
|
|
horizontalDashLineView.layoutChain
|
|
.leftToRightOfView(dotView)
|
|
.centerY(dotView)
|
|
.height(1)
|
|
.width(30)
|
|
|
|
infoView.layoutChain
|
|
.leftToRightOfView(horizontalDashLineView, offset: 5)
|
|
.edgesVertical(10)
|
|
.right(15)
|
|
|
|
infoLab.layoutChain
|
|
.edgesHorzontal(15)
|
|
.edgesVertical(15)
|
|
}
|
|
|
|
// MARK: - Views
|
|
lazy var verticalDashLineView: DashLineView = {
|
|
let v = DashLineView()
|
|
v.backgroundColor = .clear
|
|
return v
|
|
}()
|
|
|
|
lazy var horizontalDashLineView: HorizontalDashLineView = {
|
|
let v = HorizontalDashLineView()
|
|
v.backgroundColor = .clear
|
|
return v
|
|
}()
|
|
|
|
lazy var dotView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = UIColor(hexStr: "#16B3FF")
|
|
view.cornerRadius = 4
|
|
return view
|
|
}()
|
|
|
|
lazy var infoView: UIView = {
|
|
let v = UIView()
|
|
v.backgroundColor = .white
|
|
v.layer.cornerRadius = 10
|
|
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 infoLab: UILabel = {
|
|
let l = UILabel()
|
|
l.font = .systemFont(ofSize: 12, weight: .medium)
|
|
l.textColor = UIColor(hexStr: "#333333")
|
|
return l
|
|
}()
|
|
}
|