//
//  PQStuckPointMaterialHeadView.swift
//  PQSpeed
//
//  Created by SanW on 2021/5/16.
//  Copyright © 2021 BytesFlow. All rights reserved.
//

import BFCommonKit
import BFUIKit
import SnapKit
import UIKit

class PQStuckPointMaterialHeadView: UIView {
    lazy var iconImageView: UIImageView = {
        let iconImageView = UIImageView(image: UIImage.moduleImage(named: "videomk_netMaterial_selected", moduleName: "BFStuckPointKit", isAssets: false))
        return iconImageView
    }()

    lazy var titleLab: UILabel = {
        let titleLab = UILabel()
        titleLab.font = UIFont.systemFont(ofSize: 14, weight: .semibold)
        titleLab.textColor = UIColor.white
        let attString = NSMutableAttributedString(string: "选择的视频总时长 ≥20 秒，效果会更佳哦~")
        attString.addAttributes([.foregroundColor: UIColor.hexColor(hexadecimal: "#FBCC37")], range: NSRange(location: 10, length: 3))
        titleLab.attributedText = attString
        return titleLab
    }()

    lazy var desLab: UILabel = {
        let desLab = UILabel()
        desLab.font = UIFont.systemFont(ofSize: 14)
        desLab.textColor = UIColor.white
        desLab.text = "可同时选视频与图片"
        return desLab
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.hexColor(hexadecimal: "#333333")
        addSubview(iconImageView)
        addSubview(titleLab)
        addSubview(desLab)
    }

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

    override func layoutSubviews() {
        super.layoutSubviews()
        iconImageView.snp.makeConstraints { make in
            make.width.height.equalTo(40)
            make.left.equalToSuperview().offset(cDefaultMargin * 2)
            make.centerY.equalToSuperview()
        }
        titleLab.snp.makeConstraints { make in
            make.left.equalTo(iconImageView.snp.right).offset(cDefaultMargin)
            make.right.equalToSuperview().offset(-cDefaultMargin)
            make.top.equalTo(iconImageView)
        }
        desLab.snp.makeConstraints { make in
            make.left.right.equalTo(titleLab)
            make.bottom.equalTo(iconImageView)
        }
        addCorner(roundingCorners: [.topLeft, .topRight], corner: 6)
    }
}
