123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // MVMineProductCell.swift
- // MusicVideoPlus
- //
- // Created by SanW on 2021/6/22.
- //
- import BFFramework
- import UIKit
- class MVMineProductCell: UICollectionViewCell {
- var btnClickHandle: ((_ sender: UIButton, _ videoData: PQVideoListModel?) -> Void)?
- lazy var coverImageView: UIImageView = {
- let coverImageView = UIImageView()
- // coverImageView.contentMode = .scaleAspectFill
- // coverImageView.clipsToBounds = true
- coverImageView.isUserInteractionEnabled = false
- // coverImageView.tag = cCellTag
- coverImageView.backgroundColor = UIColor.white
- coverImageView.addCorner(corner: 6)
- return coverImageView
- }()
- lazy var marksView: UIImageView = {
- let marksView = UIImageView(image: UIImage(named: "home_marks"))
- // marksView.contentMode = .scaleAspectFill
- // marksView.clipsToBounds = true
- marksView.isUserInteractionEnabled = false
- return marksView
- }()
- lazy var moreBtn: UIButton = {
- let moreBtn = UIButton(type: .custom)
- let image: UIImage = UIImage(named: "icon_video_point")!
- moreBtn.setImage(UIImage(cgImage: image.cgImage!, scale: image.scale, orientation: .left), for: .normal)
- moreBtn.tag = 1
- moreBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
- return moreBtn
- }()
- lazy var titleLabel: UILabel = {
- let titleLabel = UILabel()
- titleLabel.textAlignment = .left
- titleLabel.textColor = .white
- titleLabel.numberOfLines = 1
- titleLabel.font = UIFont.systemFont(ofSize: 16, weight: .bold)
- return titleLabel
- }()
- lazy var statusBtn: UIButton = {
- let statusBtn = UIButton(type: .custom)
- statusBtn.backgroundColor = cShadowColor
- statusBtn.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .medium)
- statusBtn.setTitleColor(UIColor.white, for: .normal)
- statusBtn.tag = 2
- statusBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
- return statusBtn
- }()
- override init(frame: CGRect) {
- super.init(frame: frame)
- contentView.addSubview(coverImageView)
- coverImageView.addSubview(marksView)
- contentView.addSubview(statusBtn)
- contentView.addSubview(moreBtn)
- contentView.addSubview(titleLabel)
- }
- required init?(coder _: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- @objc class func productCell(collectionView: UICollectionView, indexPath: IndexPath) -> MVMineProductCell {
- let cell: MVMineProductCell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: MVMineProductCell.self), for: indexPath) as! MVMineProductCell
- return cell
- }
- var videoData: PQVideoListModel? {
- didSet {
- addData()
- addLayout()
- }
- }
- func addData() {
- let coverImg = (videoData?.videoCoverSnapshotPath != nil && (videoData?.videoCoverSnapshotPath?.count ?? 0) > 0) ? videoData?.videoCoverSnapshotPath ?? "" : videoData?.coverImg?["coverImgPath"] as! String
- coverImageView.setNetImage(url: coverImg)
- titleLabel.text = videoData?.title ?? ""
- statusBtn.isHidden = (videoData?.auditStatus == 5 && videoData?.transcodeStatus == 3 && (videoData?.transcodeStatus == 1 || videoData?.transcodeStatus == 3))
- if videoData?.transcodeStatus == 2 {
- statusBtn.setTitle("转码中", for: .normal)
- } else {
- statusBtn.setTitle("制作中", for: .normal)
- }
- }
- func addLayout() {
- let margin: CGFloat = 12
- let moreH: CGFloat = 30
- coverImageView.snp.remakeConstraints { make in
- make.size.equalToSuperview()
- }
- statusBtn.snp.makeConstraints { make in
- make.size.equalToSuperview()
- }
- marksView.snp.remakeConstraints { make in
- make.width.left.bottom.equalToSuperview()
- }
- moreBtn.snp.remakeConstraints { make in
- make.width.height.equalTo(moreH)
- make.right.equalToSuperview()
- make.bottom.equalToSuperview().offset(-cDefaultMargin)
- }
- titleLabel.snp.remakeConstraints { make in
- make.centerY.equalTo(moreBtn)
- make.left.equalToSuperview().offset(margin)
- make.right.equalTo(moreBtn.snp_left).offset(cDefaultMargin / 2)
- }
- }
- @objc func btnClick(sender: UIButton) {
- if btnClickHandle != nil {
- btnClickHandle!(sender, videoData)
- }
- }
- }
|