//
//  MPPositive_DownloadViewModel.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/28.
//

import UIKit
import Kingfisher
///下载实例ViewModel
class MPPositive_DownloadViewModel: NSObject {
    ///预览图片
    var reviewURL:URL?
    ///标题
    var title:String?
    ///副标题
    var subtitle:String?
    ///下载单曲实体
    var loadItem:MPPositive_DownloadItemModel
    init(_ loadItem:MPPositive_DownloadItemModel) {
        self.loadItem = loadItem
        super.init()
        configure()
    }
    //配置数据
    private func configure() {
        if let url = URL(string: loadItem.reviewImage) {
            reviewURL = url
        }
        title = loadItem.title
        subtitle = loadItem.shortBylineText
    }
    //设置预览图
    func setImage(_ imageView:UIImageView) {
        if reviewURL != nil {
            imageView.kf.setImage(with: reviewURL, placeholder: placeholderImage)
        }
    }
}
