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

import UIKit
import Kingfisher
///收藏单曲实例ViewModel
class MPPositive_CollectionSongViewModel: NSObject {
    ///封面
    var coverURL:URL!
    ///标题
    var title:String?
    ///副标题
    var subtitle:String?
    ///收藏列表实体
    var collectionSong:MPPositive_CollectionSongModel
    
    init(_ song:MPPositive_CollectionSongModel) {
        collectionSong = song
        super.init()
        configure()
    }
    //配置数据
    private func configure() {
        if collectionSong.coverImage != nil {
            coverURL = collectionSong.coverImage
        }
        title = collectionSong.title
        subtitle = collectionSong.subtitle
    }
    //设置预览图
    func setImage(_ imageView:UIImageView) {
        if coverURL != nil {
            imageView.kf.setImage(with: coverURL, placeholder: placeholderImage)
        }
    }
}
