//
//  YHPersonalCenterCell.swift
//  galaxy
//
//  Created by edy on 2023/12/20.
//

import UIKit
import SnapKit

class YHPersonalCenterCell: UITableViewCell {
    
    static let cellReuseIdentifier = "YHPersonalCenterCell"

    lazy var iconImgView:UIImageView = {
//        let icon = UIImageView()
        let icon = UIImageView(image: UIImage(named: "photo_1"))
        icon.backgroundColor = UIColor.systemPink
        return icon
    }()
    
    lazy var titleLabel:UILabel = {
        let label = UILabel()
        label.textColor = UIColor.red
        label.textAlignment = NSTextAlignment.left
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = "曾经沧海难为水，除却巫山不是云"
        return label
    }()
    
    lazy var arrowImgView:UIImageView = {
        let arrowImgView = UIImageView(image: UIImage(named: "photo_1"))
        arrowImgView.backgroundColor = UIColor.purple
        return arrowImgView
    }()

    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    func updateItem(item : PersonalModuleItem) {
//        iconImgView.image = UIImage(named: item.icon)
        titleLabel.text = item.title;
    }

    func setupUI() {
        
        contentView.addSubview(iconImgView)
        contentView.addSubview(titleLabel)
        contentView.addSubview(arrowImgView)
        
        iconImgView.snp.makeConstraints { make in
            make.left.equalTo(contentView.snp.left).offset(20)
            make.centerY.equalTo(contentView)
            make.width.height.equalTo(8)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(contentView)
            make.left.equalTo(iconImgView.snp.right).offset(10)
            make.right.equalTo(arrowImgView.snp.left).offset(-20)
        }
        
        arrowImgView.snp.makeConstraints { make in
            make.width.equalTo(5)
            make.height.equalTo(10)
            make.centerY.equalTo(contentView)
            make.right.equalTo(contentView).offset(-20)
        }
    }

}
