//
//  YHDavidTestCollectionViewCell.swift
//  galaxy
//
//  Created by davidhuangA on 2024/1/10.
//  Copyright © 2024 www.davidhuang.com. All rights reserved.
//

import UIKit

class YHDavidTestCollectionViewCell: UICollectionViewCell {
    static let cellReuseIdentifier = "YHDavidTestCollectionViewCell"
    
    lazy var titleImageView:UIImageView = {
        let imageV = UIImageView(image: UIImage(named: "home_title_image"))
        imageV.contentMode = .scaleAspectFill
        imageV.roundCorners(UIRectCorner.topLeft, radius: 8)
        imageV.roundCorners(UIRectCorner.topRight, radius: 8)
        return imageV
    }()
    
    
    lazy var descripeLable:UILabel = {
        let label = UILabel()
        label.text = "赴港攻略，当日往返无忧，这个季节风景..赴港攻略，当日往返无忧，这个季节风景"
        label.textColor = UIColor(hexString:"#333333")
        label.font = UIFont.systemFont(ofSize: 10)
        label.numberOfLines = 2
        label.lineBreakMode = .byTruncatingTail
        return label
    }()
    
    
    lazy var headImageView:UIImageView = {
        let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
        imageV.contentMode = .scaleAspectFill
        return imageV
    }()
    
    
    lazy var nameLable:UILabel = {
        let label = UILabel()
        label.text = "Fiona"
        label.textColor = UIColor(hexString:"#333333")
        label.font = UIFont.systemFont(ofSize: 10)
        return label
    }()
    
    
    lazy var dateLable:UILabel = {
        let label = UILabel()
        label.text = "12-12"
        label.textColor = UIColor(hexString:"#333333")
        label.font = UIFont.systemFont(ofSize: 10)
        return label
    }()
    
    
    lazy var heartImageView:UIImageView = {
        let imageV = UIImageView(image: UIImage(named: "home_red_heart"))
        imageV.contentMode = .scaleAspectFill
        return imageV
    }()
    
    lazy var numLable:UILabel = {
        let label = UILabel()
        label.text = "2000"
        label.textColor = UIColor(hexString:"#333333")
        label.font = UIFont.systemFont(ofSize: 14)
        return label
    }()
    
    
    
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    
    
    
    private func setupUI() {
        
        contentView.backgroundColor = UIColor(hexString: "#F8F9FB")
        contentView.roundCorners([.topLeft,.topRight], radius: 4)
        contentView.clipsToBounds = true
        
        contentView.addSubview(titleImageView)
        titleImageView.snp.makeConstraints { make in
            make.left.right.top.equalToSuperview()
            make.height.equalTo(210)
        }
        
        let subHoldView = UIView()
        subHoldView.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
        subHoldView.layer.borderWidth = 0.5
        subHoldView.layer.borderColor = UIColor(red: 0.798, green: 0.798, blue: 0.798, alpha: 1).cgColor
        contentView.addSubview(subHoldView)
        subHoldView.snp.makeConstraints { make in
            make.top.equalTo(titleImageView.snp.bottom).offset(4)
            make.left.right.equalToSuperview()
            make.height.equalTo(87)
        }
        
        subHoldView.addSubview(descripeLable)
        descripeLable.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(8)
            make.left.equalToSuperview().offset(8)
            make.right.equalToSuperview().offset(-8)
            make.height.equalTo(30)
        }
        
        subHoldView.addSubview(headImageView)
        headImageView.snp.makeConstraints { make in
            make.top.equalTo(descripeLable.snp.bottom).offset(10)
            make.left.equalTo(descripeLable.snp.left)
            make.height.width.equalTo(25)
        }
        
        subHoldView.addSubview(nameLable)
        nameLable.snp.makeConstraints { make in
            make.top.equalTo(headImageView.snp.top)
            make.left.equalTo(headImageView.snp.right).offset(5)
            make.height.equalTo(12)
            make.width.equalTo(50)
        }
        
        subHoldView.addSubview(dateLable)
        dateLable.snp.makeConstraints { make in
            make.top.equalTo(nameLable.snp.bottom).offset(2)
            make.left.equalTo(nameLable.snp.left)
            make.height.equalTo(12)
            make.right.equalTo(nameLable.snp.right)
        }
        
        subHoldView.addSubview(numLable)
        numLable.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-8)
            make.height.equalTo(12)
            make.centerY.equalTo(headImageView.snp.centerY)
        }
        
        subHoldView.addSubview(heartImageView)
        heartImageView.snp.makeConstraints { make in
            make.right.equalTo(numLable.snp.left).offset(-6)
            make.height.width.equalTo(12)
            make.centerY.equalTo(headImageView.snp.centerY)
        }
    }
}
