//
//  TipWarningView.swift

//
//  Created by Leon on 2025/8/4.
//

import UIKit

class TipWarningView: UIView {
    var icon: UIImageView!
    var contentLabel: LineSpaceLabel!

    var contentStr: String? {
        didSet {
            contentLabel.text = contentStr
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupViews()
        setupData()
        setupEvent()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setupViews() {
        backgroundColor = .c.csnn
        layer.cornerRadius = 16
        layer.masksToBounds = true
        layer.borderWidth = 1
        layer.borderColor = UIColor.c.cevn.cgColor

        icon = {
            let v = UIImageView()
            v.image = UIImage(named: "warning_blue")
            addSubview(v)
            v.snp.makeConstraints { make in
                make.leading.equalToSuperview().offset(16)
                make.top.equalToSuperview().offset(14)
//                make.width.equalTo(16)
//                make.height.equalTo(16)
            }
            return v
        }()

        contentLabel = {
            let v = LineSpaceLabel()
            let typo = CLSystemToken.typography(token: .tbm)
            v.config(typo)
            v.textColor = .c.ctpn
            v.textAlignment = .left
            addSubview(v)
            v.snp.makeConstraints { make in
                make.leading.equalTo(icon.snp.trailing).offset(8)
                make.trailing.equalToSuperview().offset(-16)
                make.top.equalToSuperview().offset(12)
                make.bottom.equalToSuperview().offset(-12)
            }
            return v
        }()
    }

    private func setupData() {
    }

    private func setupEvent() {
    }
}
