//
|
// MineLeaveMessageRecordCell.swift
|
// OKProject
|
//
|
// Created by alvin_y on 2020/6/17.
|
// Copyright © 2020 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
class MineLeaveMessageRecordCell: UITableViewCell {
|
|
|
/// 容器
|
private var view_container: UIView = {
|
let view = UIView()
|
view.backgroundColor = UIColor.color(light: UIColor.color(hexString: "#FFFFFF"), dark: UIColor.color(hexString: "#FFFFFF"))
|
view.layer.cornerRadius = 4
|
return view
|
}()
|
|
/// 时间
|
private var label_date: UILabel = {
|
let label = UILabel()
|
label.textColor = UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666"))
|
label.font = Medium(font: 14)
|
return label
|
}()
|
|
/// 内容
|
private var label_content: UILabel = {
|
let label = UILabel()
|
label.textColor = UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666"))
|
label.font = Medium(font: 14)
|
label.numberOfLines = 0
|
return label
|
}()
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
setupViews()
|
defineLayouts()
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
|
func configure(model: MineLeaveMessageRecordModel){
|
label_date.text = model.insertTime
|
var attributedString = AttributedStringbuilder.build()
|
.add(string: "我:", withFont: Medium(font: 14), withColor: UIColor.color(light: UIColor.color(hexString: "#333333"), dark: UIColor.color(hexString: "#333333")))
|
.add(string: "\(model.content)", withFont: Medium(font: 14), withColor: UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666")))
|
if model.answer != ""{
|
attributedString = attributedString
|
.add(string: "\n客服:", withFont: Medium(font: 14), withColor: UIColor.color(light: UIColor.color(hexString: "#333333"), dark: UIColor.color(hexString: "#333333")))
|
.add(string: "\(model.answer)", withFont: Medium(font: 14), withColor: UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666")))
|
}
|
label_content.attributedText = attributedString.mutableAttributedString
|
|
}
|
|
func setupViews() {
|
contentView.backgroundColor = UIColor.color(light: UIColor.color(hexString: "#F3F4F5"), dark: UIColor.color(hexString: "#F3F4F5"))
|
contentView.addSubview(view_container)
|
view_container.addSubview(label_date)
|
view_container.addSubview(label_content)
|
}
|
|
//MARK: - Layouts
|
func defineLayouts() {
|
view_container.snp.makeConstraints { (make) in
|
make.edges.equalToSuperview().inset(UIEdgeInsets(top: 8, left: 12, bottom: 0, right: 12))
|
}
|
label_date.snp.makeConstraints { (make) in
|
make.top.equalToSuperview().offset(11)
|
make.left.equalToSuperview().offset(12)
|
}
|
label_content.snp.makeConstraints { (make) in
|
make.top.equalTo(label_date.snp.bottom).offset(6)
|
make.left.equalToSuperview().offset(12)
|
make.right.equalToSuperview().offset(-12)
|
make.bottom.equalToSuperview().offset(-15)
|
}
|
}
|
|
}
|