- Updated my list for handling the comma separated language. - Added shimmer to manila , language , list table - Added action for dropdown, if user clicks outside the dropdown it ill dismiss and change the arrow direction - Handled shimmer with api call, removed the progress hud - Updated Lingual file for webSeries VC
103 lines
4.0 KiB
Swift
103 lines
4.0 KiB
Swift
//
|
|
// WebSeriesSeasonVM.swift
|
|
// WOKA
|
|
//
|
|
// Created by MacBook Pro on 20/06/24.
|
|
//
|
|
|
|
import Foundation
|
|
import Alamofire
|
|
|
|
class WebSeriesSeasonVM{
|
|
|
|
weak var vc : WebSeriesSeasonVC!
|
|
|
|
var watchShowID : Int?
|
|
var categoryID : Int?
|
|
|
|
var selectedCateogory = 0
|
|
|
|
var seasonListingData = [SeasonListingDM.Result]()
|
|
|
|
func initView(){
|
|
getSeasonListing()
|
|
setupCell()
|
|
}
|
|
|
|
func setupCell(){
|
|
vc.categoryCV.register(UINib(nibName: K.CellIdentifier.WebSeries.seasonCategoryCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.WebSeries.seasonCategoryCell)
|
|
vc.categoryCV.delegate = vc.self
|
|
vc.categoryCV.dataSource = vc.self
|
|
}
|
|
|
|
// MARK: - Api Calls
|
|
|
|
func getSeasonListing(){
|
|
Utilities.startProgressHUD()
|
|
guard let watchShowID, let categoryID else{return}
|
|
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
|
|
let params : Parameters = ["watch_show_id" : watchShowID,
|
|
"category_id" : categoryID]
|
|
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.WebSeries.season_listing, method: .post,parameters: params,headers : headers) { [weak self](result : Result<BaseResponseModel<SeasonListingDM>, NetworkManager.APIError>) in
|
|
switch result{
|
|
case .success(let data):
|
|
guard let self else{
|
|
Utilities.dismissProgressHUD()
|
|
return
|
|
}
|
|
switch data.success{
|
|
case 0:
|
|
/*
|
|
Error
|
|
*/
|
|
Utilities.dismissProgressHUD()
|
|
vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
|
|
case 1:
|
|
Utilities.dismissProgressHUD()
|
|
guard let data = data.data?.result else{return}
|
|
self.seasonListingData = data
|
|
setSeasonData()
|
|
self.vc.categoryCV.reloadData()
|
|
default:
|
|
break
|
|
}
|
|
case .failure(let error):
|
|
guard let self else{
|
|
Utilities.dismissProgressHUD()
|
|
return
|
|
}
|
|
Utilities.dismissProgressHUD()
|
|
vc.toast(msg: error.localizedDescription , time: 2)
|
|
}
|
|
}
|
|
}
|
|
|
|
func setSeasonData(){
|
|
guard let data = seasonListingData.first else{return}
|
|
vc.seasonImage.imageURL(data.thumbnailPath!, color: UIColor.appColor(.TextDarkBlue)!)
|
|
|
|
if AuthFunc.shareInstance.getDefaultLanguage() == .english{
|
|
let englishData = data.seasonMoreDetails?.filter({$0.languageMasterID == 1}).first
|
|
vc.seasonTitle.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.vc.seasonDesc.attributedText = sizeText
|
|
}
|
|
}else{
|
|
let hindiData = data.seasonMoreDetails?.filter({$0.languageMasterID == 2}).first
|
|
vc.seasonTitle.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.vc.seasonDesc.attributedText = sizeText
|
|
}
|
|
}
|
|
|
|
vc.seasonDate.text = data.releaseYear?.toString()
|
|
vc.seasonEpisodes.text = data.noOfEpisodes?.toString()
|
|
vc.seasonMediaType.text = data.mediaType
|
|
}
|
|
}
|