//
//  MPPositive_SearchSuggestionListTableViewCell.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/12.
//

import UIKit
import Kingfisher
class MPPositive_SearchSuggestionListTableViewCell: UITableViewCell {
    //搜索Icon
    private lazy var reviewImageView:UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFill
        return imageView
    }()
    private lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .white, textAlignment: .left)
    private lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#FFFFFF", alpha: 0.6), textAlignment: .left)
    var item:MPPositive_SearchSuggestionItemModel!{
        didSet{
            reviewImageView.kf.setImage(with: URL(string: item.reviewUrls?.last ?? ""), placeholder: placeholderImage)
            titleLabel.text = item.title ?? ""
            subtitleLabel.text = item.subtitle ?? ""
        }
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        configure()
    }
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    private func configure() {
        contentView.addSubview(reviewImageView)
        reviewImageView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(12*width)
            make.width.height.equalTo(30*width)
            make.centerY.equalToSuperview()
        }
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(reviewImageView.snp.top)
            make.left.equalTo(reviewImageView.snp.right).offset(10*width)
            make.right.equalToSuperview().offset(-12*width)
        }
        contentView.addSubview(subtitleLabel)
        subtitleLabel.snp.makeConstraints { make in
            make.bottom.equalTo(reviewImageView.snp.bottom)
            make.left.equalTo(titleLabel.snp.left)
            make.right.equalTo(titleLabel.snp.right)
        }
    }
}
