宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
//  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)
        }
    }
    
}