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

// 消息

parent e9da6f13
......@@ -81,8 +81,8 @@ class YHSearchInfoHistoryView: UIView {
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 strSize
var strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height)
}
}
......@@ -99,8 +99,8 @@ extension YHSearchInfoHistoryView: UICollectionViewDelegate, UICollectionViewDat
let size = self.getwith(font: UIFont.systemFont(ofSize: 12), height: 24, string: historyItems[indexPath.item])
var width = size.width + gap*2.0
if width > collectionView.width {
width = collectionView.width
if width > 226.0 {
width = 226.0
}
return CGSize(width: width, height: cellHeight)
}
......
......@@ -40,7 +40,7 @@ class YHInformationFillVC: YHBaseViewController {
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.sectionHeaderHeight = 46.0
tableView.estimatedSectionHeaderHeight = 1.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
......@@ -95,13 +95,9 @@ class YHInformationFillVC: YHBaseViewController {
}
extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return msgArr.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
return msgArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -119,7 +115,7 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 46.0
return 1.0
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
......@@ -132,18 +128,8 @@ extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = 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
return UIView()
}
}
......
......@@ -176,7 +176,7 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
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 vc = YHInformationFillVC()
vc.type = msgItem.type
......
......@@ -20,6 +20,7 @@ class YHInformationFillCell: UITableViewCell {
var unreadPointView:UIView!
var bottomBtn:UIButton!
var lineView:UIView!
var timeLabel:UILabel!
required init?(coder: NSCoder) {
super.init(coder: coder)
......@@ -30,10 +31,49 @@ class YHInformationFillCell: UITableViewCell {
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() {
self.selectionStyle = .none
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.backgroundColor = .white
......@@ -71,10 +111,16 @@ class YHInformationFillCell: UITableViewCell {
bottomBtn.addTarget(self, action: #selector(didBottomBtnClicked), for: .touchUpInside)
whiteView.addSubview(bottomBtn)
timeLabel.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(46.0)
}
whiteView.snp.makeConstraints { make in
make.left.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
......
......@@ -21,34 +21,34 @@ class YHMsgViewModel: NSObject {
var dic = json.data
var json = json
json.code = 200
dic = [
"information": [
"unread_count": 0,
"last_message": "阿法守法所发生的法师打发",
"last_message_time": 1586507545,
"type": 0
],
"certificate": [
"unread_count": 3,
"last_message": "发生发顺丰大声道发生大发萨法沙发沙发沙发沙发阿斯顿发生发顺丰阿凡达放大第三方",
"last_message_time": 1586507545,
"type": 0
],
"draft": [
"unread_count": 100,
"last_message": "发生发顺丰大声道发生大发",
"last_message_time": 1712737945,
"type": 0
],
"signature": [
"unread_count": 87,
"last_message": "发生发",
"last_message_time": 1713236425,
"type": 0
]
]
// var json = json
// json.code = 200
// dic = [
// "information": [
// "unread_count": 0,
// "last_message": "阿法守法所发生的法师打发",
// "last_message_time": 1586507545,
// "type": 0
// ],
// "certificate": [
// "unread_count": 3,
// "last_message": "发生发顺丰大声道发生大发萨法沙发沙发沙发沙发阿斯顿发生发顺丰阿凡达放大第三方",
// "last_message_time": 1586507545,
// "type": 0
// ],
// "draft": [
// "unread_count": 100,
// "last_message": "发生发顺丰大声道发生大发",
// "last_message_time": 1712737945,
// "type": 0
// ],
// "signature": [
// "unread_count": 87,
// "last_message": "发生发",
// "last_message_time": 1713236425,
// "type": 0
// ]
// ]
printLog("model 是 ==> \(json)")
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