Files
Woka_Native_iOS/WOKA/WebSeries/Controller/ContinueWatchingVC.swift
BilalKhanWDI d17fe416ae - My list Audio books on add remove fav, only calling audiobooks api and reloading in background
- My list Games on add remove fav, only calling Games api and reloading in background
- My list Karaoke on add remove fav, only calling Karaoke api and reloading in background
-Finalised clicks count for every module
2024-08-12 19:58:58 +05:30

100 lines
4.1 KiB
Swift

//
// ContinueWatchingVC.swift
// WOKA
//
// Created by MacBook Pro on 26/06/24.
//
import UIKit
class ContinueWatchingVC: UIViewController {
@IBOutlet weak var watchingImage: UIImageView!
@IBOutlet weak var watchingTitle: UILabel!
@IBOutlet weak var watchingDesc: UITextView!
@IBOutlet weak var outerView: UIView!
@IBOutlet weak var contentView: UIView!
var watchData : ContinueWatchingDM.ResultData?
// This ID is from webseries main screen, where user selectes
var categoryID : Int?
override func viewDidLoad() {
super.viewDidLoad()
if watchData != nil{
setData()
}
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
outerView.addGestureRecognizer(tapGesture)
}
@objc func handleTap(_ gesture: UITapGestureRecognizer) {
let location = gesture.location(in: outerView)
if !contentView.frame.contains(location) {
PersistentStorage.shared.addOthersCount()
self.dismiss(animated: true)
}
}
func setData(){
guard let watchData else{return}
if let url = watchData.thumbnailPath{
self.watchingImage.imageURL(url, color: .black)
}
if AuthFunc.shareInstance.getDefaultLanguage() == .english{
guard let englishData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first else{return}
watchingTitle.text = englishData.title
if let desc = englishData.description?.replacingOccurrences(of: "<br>", with: "").htmlToAttributedString{
let sizeText = NSMutableAttributedString(attributedString: desc)
sizeText.setFontFace(font: FontCustom.shareInstance.customFont(fontName: .Exo2_Regular, size: 15),color: UIColor.appColor(.TextDarkBlue)!)
self.watchingDesc.attributedText = sizeText
}
}else{
guard let hindiData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first else{return}
watchingTitle.text = hindiData.title
if let desc = hindiData.description?.replacingOccurrences(of: "<br>", with: "").htmlToAttributedString{
let sizeText = NSMutableAttributedString(attributedString: desc)
sizeText.setFontFace(font: FontCustom.shareInstance.customFont(fontName: .Exo2_Regular, size: 15),color: UIColor.appColor(.TextDarkBlue)!)
self.watchingDesc.attributedText = sizeText
}
}
}
@IBAction func watchBtnTapped(_ sender: LocalisedElementsButton) {
guard let watchData else{return}
if let showID = watchData.id, let catID = self.categoryID{
PersistentStorage.shared.addWebSeries(catID: catID, postID: showID, postType: .episode)
}
var playerItem = JwPlayerItemCreate(url: "", poster: "", titles: "")
playerItem.poster = watchData.thumbnailPath
if AuthFunc.shareInstance.getDefaultLanguage() == .english{
guard let englishData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first else{return}
playerItem.titles = englishData.title
}else{
guard let hindiData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first else{return}
playerItem.titles = hindiData.title
}
if categoryID == 1{
guard let englishData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first, let url = englishData.contentHDURL else{return}
playerItem.url = url
}else if categoryID == 18{
guard let hindiData = watchData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first, let url = hindiData.contentHDURL else{return}
playerItem.url = url
}
JWPlayerManager.shared.presentPlayer(from: self, playerItems: [playerItem], startIndex: 0, contentType: .continueWatching)
}
@IBAction func closeBtnTapped(_ sender: LocalisedElementsButton) {
PersistentStorage.shared.addOthersCount()
self.dismiss(animated: true)
}
}