Commit 63fb027d authored by Steven杜宇's avatar Steven杜宇

// 消息

parent e9da6f13
...@@ -81,8 +81,8 @@ class YHSearchInfoHistoryView: UIView { ...@@ -81,8 +81,8 @@ class YHSearchInfoHistoryView: UIView {
func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize { func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height) let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2 let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size var strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return strSize return CGSizeMake(ceil(strSize.width), strSize.height)
} }
} }
...@@ -99,8 +99,8 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat ...@@ -99,8 +99,8 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat
let size = self.getwith(font: UIFont.systemFont(ofSize: 12), height: 24, string: historyItems[indexPath.item]) let size = self.getwith(font: UIFont.systemFont(ofSize: 12), height: 24, string: historyItems[indexPath.item])
var width = size.width + gap*2.0 var width = size.width + gap*2.0
if width > collectionView.width { if width > 226.0 {
width = collectionView.width width = 226.0
} }
return CGSize(width: width, height: cellHeight) return CGSize(width: width, height: cellHeight)
} }
......
...@@ -40,7 +40,7 @@ class YHInformationFillVC: YHBaseViewController { ...@@ -40,7 +40,7 @@ class YHInformationFillVC: YHBaseViewController {
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
tableView.sectionHeaderHeight = 46.0 tableView.estimatedSectionHeaderHeight = 1.0
tableView.estimatedSectionFooterHeight = 1.0 tableView.estimatedSectionFooterHeight = 1.0
tableView.showsVerticalScrollIndicator = false tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none tableView.separatorStyle = .none
...@@ -95,13 +95,9 @@ class YHInformationFillVC: YHBaseViewController { ...@@ -95,13 +95,9 @@ class YHInformationFillVC: YHBaseViewController {
} }
extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource { extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return msgArr.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1 return msgArr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...@@ -119,7 +115,7 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource { ...@@ -119,7 +115,7 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 46.0 return 1.0
} }
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
...@@ -132,18 +128,8 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource { ...@@ -132,18 +128,8 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
} }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView() return UIView()
let label = UILabel()
label.textColor = UIColor(hex: 0x121A26, alpha: 0.3)
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "2023-09-13"
view.addSubview(label)
label.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
return view
} }
} }
......
...@@ -176,7 +176,7 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -176,7 +176,7 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 < indexPath.row && indexPath.row < msgArr.count { if 0 <= indexPath.row && indexPath.row < msgArr.count {
let msgItem = msgArr[indexPath.row] let msgItem = msgArr[indexPath.row]
let vc = YHInformationFillVC() let vc = YHInformationFillVC()
vc.type = msgItem.type vc.type = msgItem.type
......
...@@ -20,6 +20,7 @@ class YHInformationFillCell: UITableViewCell { ...@@ -20,6 +20,7 @@ class YHInformationFillCell: UITableViewCell {
var unreadPointView:UIView! var unreadPointView:UIView!
var bottomBtn:UIButton! var bottomBtn:UIButton!
var lineView:UIView! var lineView:UIView!
var timeLabel:UILabel!
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
...@@ -30,10 +31,49 @@ class YHInformationFillCell: UITableViewCell { ...@@ -30,10 +31,49 @@ class YHInformationFillCell: UITableViewCell {
setupUI() setupUI()
} }
func updateModel(_ model: YHDetailMessageModel) {
titleLabel.text = model.title
detailLabel.text = model.content
unreadPointView.isHidden = model.isRead
timeLabel.text = formatTimestamp(Double(model.time))
}
func formatTimestamp(_ timestamp: TimeInterval) -> String {
let currentDate = Date()
let calendar = Calendar.current
let currentYear = calendar.component(.year, from: currentDate)
let currentDay = calendar.component(.day, from: currentDate)
let date = Date(timeIntervalSince1970: timestamp)
let year = calendar.component(.year, from: date)
let day = calendar.component(.day, from: date)
let dateFormatter = DateFormatter()
if year == currentYear {
if day == currentDay {
dateFormatter.dateFormat = "HH:mm"
} else {
dateFormatter.dateFormat = "MM-dd"
}
} else {
dateFormatter.dateFormat = "yyyy-MM-dd"
}
return dateFormatter.string(from: date)
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
contentView.backgroundColor = UIColor(hex:0xF8F8F8) contentView.backgroundColor = UIColor(hex:0xF8F8F8)
timeLabel = UILabel()
timeLabel.textColor = UIColor(hex: 0x121A26, alpha: 0.3)
timeLabel.textAlignment = .center
timeLabel.font = UIFont.PFSC_R(ofSize:12)
timeLabel.text = "2023-09-13"
contentView.addSubview(timeLabel)
whiteView = UIView() whiteView = UIView()
whiteView.backgroundColor = .white whiteView.backgroundColor = .white
...@@ -71,10 +111,16 @@ class YHInformationFillCell: UITableViewCell { ...@@ -71,10 +111,16 @@ class YHInformationFillCell: UITableViewCell {
bottomBtn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside) bottomBtn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside)
whiteView.addSubview(bottomBtn) whiteView.addSubview(bottomBtn)
timeLabel.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(46.0)
}
whiteView.snp.makeConstraints { make in whiteView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16) make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16) make.right.equalToSuperview().offset(-16)
make.top.bottom.equalToSuperview() make.top.equalTo(timeLabel.snp.bottom)
make.bottom.equalToSuperview()
} }
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
......
...@@ -21,34 +21,34 @@ class YHMsgViewModel: NSObject { ...@@ -21,34 +21,34 @@ class YHMsgViewModel: NSObject {
var dic = json.data var dic = json.data
var json = json // var json = json
json.code = 200 // json.code = 200
dic = [ // dic = [
"information": [ // "information": [
"unread_count": 0, // "unread_count": 0,
"last_message": "阿法守法所发生的法师打发", // "last_message": "阿法守法所发生的法师打发",
"last_message_time": 1586507545, // "last_message_time": 1586507545,
"type": 0 // "type": 0
], // ],
"certificate": [ // "certificate": [
"unread_count": 3, // "unread_count": 3,
"last_message": "发生发顺丰大声道发生大发萨法沙发沙发沙发沙发阿斯顿发生发顺丰阿凡达放大第三方", // "last_message": "发生发顺丰大声道发生大发萨法沙发沙发沙发沙发阿斯顿发生发顺丰阿凡达放大第三方",
"last_message_time": 1586507545, // "last_message_time": 1586507545,
"type": 0 // "type": 0
], // ],
"draft": [ // "draft": [
"unread_count": 100, // "unread_count": 100,
"last_message": "发生发顺丰大声道发生大发", // "last_message": "发生发顺丰大声道发生大发",
"last_message_time": 1712737945, // "last_message_time": 1712737945,
"type": 0 // "type": 0
], // ],
"signature": [ // "signature": [
"unread_count": 87, // "unread_count": 87,
"last_message": "发生发", // "last_message": "发生发",
"last_message_time": 1713236425, // "last_message_time": 1713236425,
"type": 0 // "type": 0
] // ]
] // ]
printLog("model 是 ==> \(json)") printLog("model 是 ==> \(json)")
if json.code == 200 { if json.code == 200 {
......
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