//
//  WebSeriesEpisodeCell.swift
//  WOKA
//
//  Created by Bilal on 21/06/2024.
//

import UIKit

class WebSeriesEpisodeCell: UITableViewCell {

    @IBOutlet weak var seasonImage: UIImageView!
    @IBOutlet weak var seasonTitle: UILabel!
    @IBOutlet weak var seasonTime: UILabel!
    @IBOutlet weak var playBtn: UIButton!
    
    typealias btnTappedBlock = () -> Void  // 0 - plus 1 - minus
    var btnTapped : btnTappedBlock!
    
    override func awakeFromNib() {
        super.awakeFromNib()

        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func setData(data : EpisodeListingDM.ResultData){
        if let url = data.thumbnailPath{
            self.seasonImage.imageURL(url, color: UIColor.appColor(.TextDarkBlue)!)
        }
        
        self.seasonTime.text = data.episodeDuration ?? "0:00:00"
        
        if AuthFunc.shareInstance.getDefaultLanguage() == .english{
            seasonTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 1}).first?.title
        }else{
            seasonTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 2}).first?.title
        }
    }
    
    func setTeaserData(data : TeaserDM.ResultData){
        if let url = data.thumbnailPath{
            self.seasonImage.imageURL(url, color: .black)
        }
        
        self.seasonTime.text = data.teaserDuration ?? "0:00:00"

        if AuthFunc.shareInstance.getDefaultLanguage() == .english{
            seasonTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 1}).first?.title
        }else{
            seasonTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 2}).first?.title
        }
    }
    
    @IBAction func playBtnTapped(_ sender: UIButton) {
        if btnTapped != nil {
            btnTapped()
        }
    }
}
