Commit c8cd1043 authored by Steven杜宇's avatar Steven杜宇

// 预约

parent d65c5eca
This diff is collapsed.
......@@ -12,7 +12,7 @@ import SwifterSwift
class YHResignAppointTimeViewController: YHBaseViewController {
var familyArr: [String] = ["", "", "", ""]
var familyArr: [String] = ["", "", "", "", ""]
lazy var tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style:.grouped)
......@@ -27,6 +27,10 @@ class YHResignAppointTimeViewController: YHBaseViewController {
tableView.separatorStyle = .none
tableView.bounces = false
tableView.register(YHResignAppointTimeCell.self, forCellReuseIdentifier: YHResignAppointTimeCell.cellReuseIdentifier)
tableView.register(YHResignAppointOptionCell.self, forCellReuseIdentifier: YHResignAppointOptionCell.cellReuseIdentifier)
tableView.register(YHResignAppointApplicantInfoCell.self, forCellReuseIdentifier: YHResignAppointApplicantInfoCell.cellReuseIdentifier)
tableView.register(YHResignAppointOptionResultCell.self, forCellReuseIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier)
tableView.register(YHResignHaveAppointedInfoCell.self, forCellReuseIdentifier: YHResignHaveAppointedInfoCell.cellReuseIdentifier)
tableView.delegate = self
tableView.dataSource = self
return tableView
......@@ -106,12 +110,31 @@ extension YHResignAppointTimeViewController: UITableViewDelegate, UITableViewDat
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeCell
let cell2 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointTimeCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointTimeCell
if 0 <= indexPath.row && indexPath.row < familyArr.count {
if indexPath.row == 0 {
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionResultCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionResultCell
return cell1
}
if indexPath.row == 1 {
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointOptionCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointOptionCell
return cell1
}
if indexPath.row == 2 {
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignAppointApplicantInfoCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointApplicantInfoCell
return cell1
}
if indexPath.row == 3 {
let cell1 = tableView.dequeueReusableCell(withIdentifier: YHResignHaveAppointedInfoCell.cellReuseIdentifier, for: indexPath) as! YHResignHaveAppointedInfoCell
return cell1
}
}
return cell
return cell2
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......
//
// YHResignAppointApplicantInfoCell.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHResignAppointApplicantInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointApplicantInfoCell"
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = .mainTextColor
label.text = "第一批赴港递交信息"
return label
}()
lazy var applicantTitleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 14)
label.textColor = .mainTextColor
label.text = "赴港递交申请人"
return label
}()
lazy var applicantContentView: UIView = {
let view = UIView()
view.backgroundColor = .init(hex: 0xF8F9FB)
return view
}()
lazy var applicantNamesLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = .mainTextColor
label.text = "成员:侯林、张曼玉、刘德华"
return label
}()
lazy var submitTimeView: YHResignAppointShowTimeItemView = {
let view = YHResignAppointShowTimeItemView()
view.title = "预约在港递交时间"
view.detail = "2024-03-14 15:00"
return view
}()
lazy var leaveHKTimeView: YHResignAppointShowTimeItemView = {
let view = YHResignAppointShowTimeItemView()
view.title = "预计离港时间"
view.detail = "2024-03-14 21:00"
return view
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(applicantTitleLabel)
whiteContentView.addSubview(applicantContentView)
applicantContentView.addSubview(applicantNamesLabel)
whiteContentView.addSubview(submitTimeView)
whiteContentView.addSubview(leaveHKTimeView)
whiteContentView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(18)
make.height.equalTo(24)
}
lineView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.height.equalTo(0.5)
}
applicantTitleLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(lineView.snp.bottom).offset(16)
make.height.equalTo(20)
}
applicantContentView.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(applicantTitleLabel.snp.bottom).offset(12)
}
applicantNamesLabel.snp.makeConstraints { make in
make.left.equalTo(14)
make.right.equalTo(-14)
make.top.equalTo(12)
make.bottom.equalTo(-12)
}
submitTimeView.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(applicantContentView.snp.bottom).offset(16)
}
leaveHKTimeView.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeView.snp.bottom).offset(0)
make.bottom.equalTo(0)
}
}
}
//
// YHResignAppointOptionCell.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import AttributedString
class YHResignAppointOptionCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointOptionCell"
// 选择是否赴港
var isSelectGoHK:Bool? {
didSet {
var selectIndex = -1 // 是否都未选择
if let isGoHK = isSelectGoHK {
selectIndex = isGoHK ? 0 : 1
}
optionsView.selectIndex = selectIndex
}
}
var selectBlock:((Int)->())?
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
let a: ASAttributedString = .init("*", .font(UIFont.PFSC_M(ofSize: 17)),.foreground(UIColor.failColor))
let b: ASAttributedString = .init("在港递交", .font(UIFont.PFSC_M(ofSize: 17)),.foreground(UIColor.mainTextColor))
label.attributed.text = a+b
return label
}()
lazy var detailLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
let a: ASAttributedString = .init("备注:若有可重合递交时间,非特殊情况,建议一起在港递交!", .font(UIFont.PFSC_R(ofSize: 13)),.foreground(UIColor.init(hex: 0x94A3B8)))
label.attributed.text = a
return label
}()
lazy var optionsView: YHInfoItemOptionView = {
let view = YHInfoItemOptionView(frame: .zero)
view.title = "申请人是否一起在港递交"
view.options = ["是", "否"]
view.selectIndex = -1
view.selectBlock = {
[weak self] index in
guard let self = self else { return }
}
return view
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(detailLabel)
whiteContentView.addSubview(optionsView)
whiteContentView.snp.makeConstraints { make in
make.top.equalTo(0)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(18)
make.right.equalTo(-18)
}
lineView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
}
detailLabel.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(16)
make.left.equalTo(18)
make.right.equalTo(-18)
}
optionsView.snp.makeConstraints { make in
make.top.equalTo(detailLabel.snp.bottom).offset(10)
make.left.equalTo(18)
make.right.equalTo(-18)
make.bottom.equalTo(-8)
}
}
}
//
// YHResignAppointOptionResultCell.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignAppointOptionResultCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignAppointOptionResultCell"
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = .mainTextColor
label.text = "在港递交"
return label
}()
lazy var detailLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 14)
label.textColor = .mainTextColor(alpha: 0.5)
label.text = "申请人是否一起在港递交"
return label
}()
lazy var optionLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 14)
label.textColor = .mainTextColor
label.textAlignment = .right
label.text = "否"
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(lineView)
whiteContentView.addSubview(detailLabel)
whiteContentView.addSubview(optionLabel)
whiteContentView.snp.makeConstraints { make in
make.top.equalTo(0)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(18)
make.right.equalTo(-18)
}
lineView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.left.right.equalToSuperview()
make.height.equalTo(0.5)
}
detailLabel.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(16)
make.left.equalTo(18)
make.right.equalTo(optionLabel.snp.left).offset(-18)
make.bottom.equalTo(-18)
}
optionLabel.snp.makeConstraints { make in
make.top.equalTo(detailLabel)
make.right.equalTo(-18)
make.width.equalTo(15)
make.height.equalTo(20)
}
}
}
//
// YHResignAppointShowTimeItemView.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignAppointShowTimeItemView: UIView {
var title: String = "" {
didSet {
titleLabel.text = title
}
}
var detail: String = "" {
didSet {
detailLabel.text = detail
}
}
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_R(ofSize: 14)
label.textColor = .mainTextColor(alpha: 0.5)
return label
}()
private lazy var detailLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = .mainTextColor
label.textAlignment = .right
label.text = "0000-00-00 00:00"
return label
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func createUI() {
self.addSubview(titleLabel)
self.addSubview(detailLabel)
self.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
make.top.equalTo(0)
make.height.equalTo(0.5)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(0)
make.top.equalTo(16)
make.width.equalTo(112)
}
detailLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(titleLabel.snp.right).offset(18.0)
make.right.equalTo(0)
make.bottom.equalTo(-16)
}
}
}
......@@ -29,8 +29,8 @@ class YHResignAppointTimeCell: UITableViewCell {
return titleLabel
}()
lazy var submitTimeItemView: YHResignAppointTimeItemView = {
let view = YHResignAppointTimeItemView(frame: .zero)
lazy var submitTimeItemView: YHResignAppointSelectTimeItemView = {
let view = YHResignAppointSelectTimeItemView(frame: .zero)
view.title = "预约在港递交时间"
view.placeHolder = "请选择"
view.isNeedShowErrorTips = false
......@@ -44,8 +44,8 @@ class YHResignAppointTimeCell: UITableViewCell {
return view
}()
lazy var leaveTimeItemView: YHResignAppointTimeItemView = {
let view = YHResignAppointTimeItemView(frame: .zero)
lazy var leaveTimeItemView: YHResignAppointSelectTimeItemView = {
let view = YHResignAppointSelectTimeItemView(frame: .zero)
view.title = "预计离港时间"
view.placeHolder = "请选择"
view.errorTips = "请选择离港时间"
......
//
// YHResignAppointedScheduleItemView.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignAppointedScheduleItemView: UIView {
lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .separatorColor
return view
}()
lazy var markView:UIView = {
let view = UIView()
view.backgroundColor = .brandMainColor
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 15)
label.textColor = .mainTextColor
label.text = "第X批"
return label
}()
lazy var confirmInHKLabel: UILabel = {
let label = UILabel()
label.text = "已确认在港"
label.font = UIFont.PFSC_M(ofSize: 13)
label.textColor = .init(hex: 0x3CC694)
return label
}()
lazy var confirmInHKBtn: UIButton = {
let btn = UIButton()
btn.layer.cornerRadius = 2.0
btn.backgroundColor = .brandMainColor
btn.setTitleColor(.white, for: .normal)
btn.setTitle("确认在港", for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 11)
return btn
}()
lazy var applicantNamesLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = .mainTextColor
label.text = "申请人:"
return label
}()
lazy var submitTimeLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = .mainTextColor(alpha: 0.5)
label.text = "预约递交时间: 0000-00-00 00:00"
return label
}()
lazy var confirmHKTimeLabel: UILabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = .mainTextColor(alpha: 0.5)
label.text = "确认在港时间: 0000-00-00 00:00"
return label
}()
lazy var scheduleView: YHResignAppointedScheduleLineView = {
let view = YHResignAppointedScheduleLineView(frame: .zero)
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func createUI() {
self.addSubview(lineView)
self.addSubview(markView)
self.addSubview(titleLabel)
self.addSubview(confirmInHKBtn)
self.addSubview(confirmHKTimeLabel)
self.addSubview(applicantNamesLabel)
self.addSubview(submitTimeLabel)
self.addSubview(confirmHKTimeLabel)
self.addSubview(scheduleView)
lineView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(0.5)
}
markView.snp.makeConstraints { make in
make.width.equalTo(3)
make.height.equalTo(12)
make.left.equalTo(18)
make.centerY.equalTo(titleLabel)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(markView.snp.right).offset(8)
make.height.equalTo(22)
make.top.equalTo(18)
}
confirmInHKBtn.snp.makeConstraints { make in
make.right.equalTo(-18)
make.width.equalTo(68)
make.height.equalTo(28)
make.centerY.equalTo(titleLabel)
}
applicantNamesLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(titleLabel.snp.bottom).offset(16)
}
submitTimeLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(applicantNamesLabel.snp.bottom).offset(8)
}
confirmHKTimeLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(submitTimeLabel.snp.bottom).offset(8)
}
scheduleView.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(-18)
make.top.equalTo(confirmHKTimeLabel.snp.bottom).offset(18)
make.height.equalTo(84.0)
make.bottom.equalTo(-18)
}
}
}
//
// YHResignAppointedScheduleLineCell.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignAppointedScheduleLineCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHResignAppointedScheduleLineCell"
lazy var numLabel: UILabel = {
var label = UILabel()
label.font = UIFont(name: "DINAlternate-Bold", size: 11)!
label.textAlignment = .center
label.textColor = UIColor.mainTextColor(alpha: 0.7)
label.backgroundColor = .white
label.layer.cornerRadius = 17.0/2.0
label.clipsToBounds = true
return label
}()
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor
return label
}()
lazy var timeLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor
return label
}()
lazy var leftDotView: UIView = {
let view = UIView()
return view
}()
lazy var rightDotView: UIView = {
let view = UIView()
return view
}()
lazy var leftDotLayer: CAShapeLayer = {
let layer = self.createDotLine(frame: leftDotView.bounds)
return layer
}()
lazy var rightDotLayer: CAShapeLayer = {
let layer = self.createDotLine(frame: leftDotView.bounds)
return layer
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
func setupUI() {
contentView.addSubview(numLabel)
contentView.addSubview(titleLabel)
contentView.addSubview(timeLabel)
contentView.addSubview(leftDotView)
contentView.addSubview(rightDotView)
numLabel.snp.makeConstraints { make in
make.width.height.equalTo(17)
make.top.equalTo(16)
make.centerX.equalToSuperview()
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(numLabel.snp.bottom).offset(6)
make.centerX.equalToSuperview()
make.height.equalTo(15)
}
timeLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(1)
make.height.equalTo(15)
make.centerX.equalToSuperview()
}
leftDotView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(numLabel.snp.left).offset(-8)
make.centerY.equalTo(numLabel)
make.height.equalTo(0.8)
}
rightDotView.snp.makeConstraints { make in
make.right.equalTo(0)
make.left.equalTo(numLabel.snp.right).offset(8)
make.centerY.equalTo(numLabel)
make.height.equalTo(0.8)
}
}
func updateModel(_ model: YHScheduleLineStepModel) {
numLabel.text = "\(model.index)"
titleLabel.text = model.title
timeLabel.text = model.time
leftDotLayer.removeFromSuperlayer()
rightDotLayer.removeFromSuperlayer()
leftDotLayer = createDotLine(frame: leftDotView.bounds)
rightDotLayer = createDotLine(frame: rightDotView.bounds)
leftDotView.layer.addSublayer(leftDotLayer)
rightDotView.layer.addSublayer(rightDotLayer)
}
func createDotLine(frame:CGRect) -> CAShapeLayer {
let borderLayer = CAShapeLayer()
borderLayer.path = UIBezierPath(roundedRect: frame, cornerRadius: 0.0).cgPath
borderLayer.lineWidth = 0.8
//[数组第一个数字表示单个虚线长度,第二个数字表示间隔]
borderLayer.lineDashPattern = [3,3] as [NSNumber]?
//前边是虚线的长度,后边是虚线之间空隙的长度
borderLayer.lineDashPhase = 0.1
//实线边框
borderLayer.fillColor = UIColor.clear.cgColor
borderLayer.strokeColor = UIColor.init(hex: 0x121A26, alpha: 0.12).cgColor
return borderLayer
}
}
//
// YHResignAppointedScheduleLineView.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHScheduleLineStepModel {
var index: Int = 0
var title: String = ""
var time: String = ""
init(title: String, time: String) {
self.title = title
self.time = time
}
}
class YHResignAppointedScheduleLineView: UIView {
var steps:[YHScheduleLineStepModel] = {
let model1 = YHScheduleLineStepModel(title: "入境香港准备", time: "")
let model2 = YHScheduleLineStepModel(title: "已确认在港", time: "2024-03-14")
let model3 = YHScheduleLineStepModel(title: "银河递交续签资料", time: "2024-03-14")
let model4 = YHScheduleLineStepModel(title: "查看递交回执", time: "2024-03-14")
let model5 = YHScheduleLineStepModel(title: "在港等待获批/离港", time: "")
let model6 = YHScheduleLineStepModel(title: "在港等缴费领取新签证", time: "")
let model7 = YHScheduleLineStepModel(title: "更新续签旅行证件", time: "")
return [model1, model2, model3, model4, model5, model6, model7]
}()
lazy var collectView: UICollectionView = {
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.scrollDirection = .horizontal
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .init(hex: 0xF8F9FB)
collectinoView.register(YHResignAppointedScheduleLineCell.self, forCellWithReuseIdentifier:YHResignAppointedScheduleLineCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.bounces = false
collectinoView.showsHorizontalScrollIndicator = false
return collectinoView
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
func createUI() {
self.addSubview(collectView)
collectView.reloadData()
collectView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}
extension YHResignAppointedScheduleLineView: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return steps.count
}
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if 0 <= indexPath.item && indexPath.item < steps.count {
let model = steps[indexPath.item]
let size = self.getwith(font: UIFont.PFSC_R(ofSize: 11), height: 15, string: model.title)
var width = ceil(Double(size.width))
if width < 65.0 {
width = 65.0
}
width += 9.0*2
return CGSize(width: width, height: 84.0)
}
return .zero
}
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHResignAppointedScheduleLineCell.cellReuseIdentifier, for: indexPath) as! YHResignAppointedScheduleLineCell
if 0 <= indexPath.item && indexPath.item < steps.count {
let model = steps[indexPath.item]
model.index = indexPath.item+1
cell.updateModel(model)
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < steps.count {
let model = steps[indexPath.item]
}
}
// 计算文字宽度大小
func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height)
}
}
//
// YHResignHaveAppointedInfoCellTableViewCell.swift
// galaxy
//
// Created by edy on 2024/10/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResignHaveAppointedInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHResignHaveAppointedInfoCell"
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = .mainTextColor
label.text = "赴港递交已预约"
return label
}()
lazy var modifyBtn: UIButton = {
let btn = UIButton()
btn.setTitle("修改", for: .normal)
btn.setTitleColor(.brandMainColor, for: .normal)
btn.titleLabel?.font = .PFSC_M(ofSize: 14)
return btn
}()
lazy var batchView: UIView = {
let view = UIView()
return view
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
contentView.addSubview(whiteContentView)
whiteContentView.addSubview(titleLabel)
whiteContentView.addSubview(modifyBtn)
whiteContentView.addSubview(batchView)
whiteContentView.snp.makeConstraints { make in
make.top.equalTo(0)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.equalTo(18)
make.right.equalTo(-18)
make.height.equalTo(24)
}
modifyBtn.snp.makeConstraints { make in
make.width.equalTo(28)
make.height.equalTo(24)
make.right.equalTo(-18)
make.centerY.equalTo(titleLabel)
}
batchView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(0)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
}
updateUI()
}
func updateUI() {
let arr = ["", ""]
batchView.removeSubviews()
var lastView: YHResignAppointedScheduleItemView? = nil
for (index, model) in arr.enumerated() {
let itemView = YHResignAppointedScheduleItemView(frame: .zero)
batchView.addSubview(itemView)
itemView.snp.makeConstraints { make in
make.left.equalTo(0)
make.right.equalTo(0)
if index == 0 {
make.top.equalTo(0)
} else {
if let lastView = lastView {
make.top.equalTo(lastView.snp.bottom)
}
}
if index == arr.count - 1 {
make.bottom.equalTo(0)
}
lastView = itemView
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment