//
//  MPPositive_ListHeaderViewModel.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/4/28.
//

import UIKit
///歌单头部内容交互模型
class MPPositive_ListHeaderViewModel: NSObject {
    ///图片路径
    var coverUrl:URL?
    ///主标题
    var title:String!
    ///说明/介绍
    var _description: String!
    ///头部模块实体
    var header:MPPositive_ListHeaderModel!
    init(_ header:MPPositive_ListHeaderModel) {
        super.init()
        self.header = header
        confirgue(header)
    }
    //数据配置
    private func confirgue (_ header:MPPositive_ListHeaderModel) {
        //封面
        if let url = URL(string: header.coverUrl ?? "") {
            self.coverUrl = url
        }else {
            print("No Cover")
        }
        //标题处理
        title = header.maintitle
        
        //说明/介绍处理
        if header.forDescription != nil {
            _description = header.forDescription
        }
    }
    ///将路径转为图片
    func setUrltoImage(_ imageView:UIImageView) {
        if coverUrl != nil {
            imageView.kf.setImage(with: coverUrl, placeholder: placeholderImage)
        }else {
            imageView.image = placeholderImage
        }
    }
}
