Commit 2faa53e5 authored by Alex朱枝文's avatar Alex朱枝文

在港记录列表UI优化

parent b3a44665
......@@ -22,12 +22,12 @@ class YHHKRecordsSummaryVC: YHBaseViewController {
let firstSection = YHHKRecordSectionType.header("在港逗留情况")
let summaryItems1: [YHHKRecordItemDetailType] = [.detailHeader("逗留共300天(2次)"), .lastStay("上次逗留:2024-10-04"), .summaryItem("2024年 270天(2次)"), .summaryItem("2024年 30天(2次)")]
let periodItems1: [YHHKRecordItemDetailType] = [.detailHeader("超90天未在港"), .duration("2023-10-04", "2023-12-04", "60天"), .duration("2024-12-04", "2023-01-04", "60天")]
let expandedSec1 = ExpandedSection(title: "章一刀", type: .over90, summaryItems: summaryItems1, periodItems: periodItems1)
let expandedSec1 = YHHKRecordsExpandedSection(title: "章一刀", type: .over90, summaryItems: summaryItems1, periodItems: periodItems1)
let secondSection = YHHKRecordSectionType.expandedItem(expandedSec1)
let summaryItems2: [YHHKRecordItemDetailType] = [.detailHeader("逗留共300天(5次)"), .lastStay("上次逗留:2024-10-04"), .summaryItem("2024年 270天(2次)"), .summaryItem("2024年 30天(3次)")]
let periodItems2: [YHHKRecordItemDetailType] = [.detailHeader("超200天未在港"), .duration("2023-10-04", "2023-12-04", "60天"), .duration("2024-12-04", "2023-01-04", "30天")]
let expandedSec2 = ExpandedSection(title: "李晓梅", type: .over180, summaryItems: summaryItems2, periodItems: periodItems2)
let expandedSec2 = YHHKRecordsExpandedSection(title: "李晓梅", type: .over180, summaryItems: summaryItems2, periodItems: periodItems2)
let thirdSection = YHHKRecordSectionType.expandedItem(expandedSec2)
return [firstSection, secondSection, thirdSection]
......@@ -69,15 +69,15 @@ extension YHHKRecordsSummaryVC {
view.backgroundColor = UIColor.contentBkgColor
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(kMargin)
make.right.equalToSuperview().offset(-kMargin)
make.left.equalToSuperview().offset(kMargin).priority(.high)
make.right.equalToSuperview().offset(-kMargin).priority(.high)
make.top.bottom.equalToSuperview()
}
tableView.tableHeaderView = UIView(frame: CGRect.init(x: 0, y: 0, width: KScreenWidth, height: kMargin))
tableView.tableFooterView = UIView(frame: CGRect.init(x: 0, y: 0, width: KScreenWidth, height: kMargin))
}
private func getSubCellType(model: ExpandedSection, indexPath: IndexPath, subType: YHHKRecordItemDetailType) -> YHResignRoundCellType {
private func getSubCellType(model: YHHKRecordsExpandedSection, indexPath: IndexPath, subType: YHHKRecordItemDetailType) -> YHResignRoundCellType {
var cellType: YHResignRoundCellType = .top
switch subType {
case .lastStay, .summaryItem:
......@@ -130,7 +130,8 @@ extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource {
}
case let .expandedItem(model):
if indexPath.row == 0, let cell = tableView.dequeueReusableCell(withIdentifier: YHHKRecordsExpandedCell.cellReuseIdentifier) as? YHHKRecordsExpandedCell {
cell.setupCellInfo(title: model.title, status: model.type, isExpanded: model.isExpanded)
let isShowBottomLine = !model.isExpanded && (indexPath.section != datas.count - 1)
cell.setupCellInfo(title: model.title, status: model.type, isExpanded: model.isExpanded, isShowBottomLine: isShowBottomLine)
return cell
}
if model.isExpanded, model.subItems.count > indexPath.row - 1, indexPath.row - 1 >= 0 {
......@@ -161,7 +162,7 @@ extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource {
}
case .occupyingSpace:
if let cell = tableView.dequeueReusableCell(withIdentifier: YHHKRecordsOccupyingSpaceCell.cellReuseIdentifier) as? YHHKRecordsOccupyingSpaceCell {
let isShow = indexPath.row == model.subItems.count
let isShow = indexPath.row == model.subItems.count && (indexPath.section != datas.count - 1)
cell.setupCellInfo(isShow)
return cell
}
......@@ -207,13 +208,11 @@ extension YHHKRecordsSummaryVC: UITableViewDelegate, UITableViewDataSource {
model.isExpanded.toggle()
secType = .expandedItem(model)
datas[indexPath.section] = secType
tableView.reloadData()
// tableView.performBatchUpdates { [weak tableView] in
// tableView?.reloadSections(IndexSet(integer: indexPath.section), with: .automatic)
// }
tableView.performBatchUpdates { [weak tableView] in
tableView?.reloadSections(IndexSet(integer: indexPath.section), with: .automatic)
}
}
tableView.deselectRow(at: indexPath, animated: true)
}
}
......
......@@ -22,21 +22,13 @@ enum YHHKNonPresenceRecordType {
}
}
class ExpandedSection {
struct YHHKRecordsExpandedSection {
let title: String
let type: YHHKNonPresenceRecordType
var isExpanded: Bool = true
let summaryItems: [YHHKRecordItemDetailType]
let periodItems: [YHHKRecordItemDetailType]
init(title: String, type: YHHKNonPresenceRecordType, isExpanded: Bool = true, summaryItems: [YHHKRecordItemDetailType], periodItems: [YHHKRecordItemDetailType]) {
self.title = title
self.type = type
self.isExpanded = isExpanded
self.summaryItems = summaryItems
self.periodItems = periodItems
}
var subItems: [YHHKRecordItemDetailType] {
var retItems = [YHHKRecordItemDetailType]()
retItems.append(contentsOf: summaryItems)
......@@ -53,7 +45,7 @@ class ExpandedSection {
enum YHHKRecordSectionType {
case header(_ title: String)
case expandedItem(_ model: ExpandedSection)
case expandedItem(_ model: YHHKRecordsExpandedSection)
}
enum YHHKRecordItemDetailType {
......
......@@ -34,6 +34,7 @@ class YHHKRecordsExpandedCell: UITableViewCell {
private lazy var statusLabel: YHPaddedLabel = {
let label = YHPaddedLabel(padding: UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 6))
label.font = .PFSC_M(ofSize: 12)
label.layer.cornerRadius = 2
return label
}()
......@@ -43,6 +44,13 @@ class YHHKRecordsExpandedCell: UITableViewCell {
label.font = .PFSC_R(ofSize: 14)
return label
}()
private lazy var bottomLineView: UIView = {
let view = UIView()
view.isHidden = true
view.backgroundColor = .separatorColor
return view
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
......@@ -53,12 +61,13 @@ class YHHKRecordsExpandedCell: UITableViewCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String?, status: YHHKNonPresenceRecordType, isExpanded: Bool) {
func setupCellInfo(title: String?, status: YHHKNonPresenceRecordType, isExpanded: Bool, isShowBottomLine: Bool = false) {
infoTitleLabel.text = title
statusLabel.text = status.title
statusLabel.textColor = status.titleColor
statusLabel.backgroundColor = status.bgColor
self.isExpanded = isExpanded
bottomLineView.isHidden = !isShowBottomLine
}
}
......@@ -72,10 +81,17 @@ extension YHHKRecordsExpandedCell {
contentView.addSubview(infoTitleLabel)
contentView.addSubview(statusLabel)
contentView.addSubview(infoDetailLabel)
contentView.addSubview(bottomLineView)
tagView.setContentCompressionResistancePriority(.required, for: .horizontal)
infoTitleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
statusLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
infoDetailLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
bottomLineView.snp.makeConstraints { make in
make.bottom.equalToSuperview()
make.left.equalToSuperview().offset(18)
make.right.equalToSuperview().offset(-18)
make.height.equalTo(1)
}
tagView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(18)
......
......@@ -32,7 +32,7 @@ class YHHKRecordsSummaryItemCell: YHHKRecordsSectionItemBaseCell {
infoTitleLabel.text = title
updateCellCorner(cellType)
if cellType == .bottom {
infoTitleLabel.snp.makeConstraints { make in
infoTitleLabel.snp.remakeConstraints { make in
make.left.equalToSuperview().offset(18)
make.right.lessThanOrEqualToSuperview().offset(-18)
make.top.equalToSuperview().offset(8)
......
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