diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index 96cf345..8b2c3c3 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -138,6 +138,10 @@ 52C8B0712BDA7512003B51D0 /* PassingCloud.json in Resources */ = {isa = PBXBuildFile; fileRef = 52C8B0702BDA7512003B51D0 /* PassingCloud.json */; }; 52C8B0742BDA7626003B51D0 /* OnBoardVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C8B0732BDA7626003B51D0 /* OnBoardVC.swift */; }; 52C8D8D42C2D9F3400CA72A6 /* LikeFavCommonFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C8D8D32C2D9F3400CA72A6 /* LikeFavCommonFunc.swift */; }; + 52C8EC7A2C353653002DC35C /* ContinueAudioListDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C8EC792C353653002DC35C /* ContinueAudioListDM.swift */; }; + 52C8EC7D2C3536E5002DC35C /* ContinueAudioCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C8EC7B2C3536E5002DC35C /* ContinueAudioCell.swift */; }; + 52C8EC7E2C3536E5002DC35C /* ContinueAudioCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52C8EC7C2C3536E5002DC35C /* ContinueAudioCell.xib */; }; + 52C8EC802C358E75002DC35C /* AudioBookDetailsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C8EC7F2C358E75002DC35C /* AudioBookDetailsVC.swift */; }; 52CA28FA2BE119F500708B49 /* UserIntrestVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52CA28F92BE119F500708B49 /* UserIntrestVC.swift */; }; 52CA28FC2BE11A0400708B49 /* UserIntrestVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52CA28FB2BE11A0400708B49 /* UserIntrestVM.swift */; }; 52CC38C32BDF812F00B74C3E /* LocalisedElements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52CC38C22BDF812F00B74C3E /* LocalisedElements.swift */; }; @@ -400,6 +404,10 @@ 52C8B0702BDA7512003B51D0 /* PassingCloud.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PassingCloud.json; sourceTree = ""; }; 52C8B0732BDA7626003B51D0 /* OnBoardVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnBoardVC.swift; sourceTree = ""; }; 52C8D8D32C2D9F3400CA72A6 /* LikeFavCommonFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikeFavCommonFunc.swift; sourceTree = ""; }; + 52C8EC792C353653002DC35C /* ContinueAudioListDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContinueAudioListDM.swift; sourceTree = ""; }; + 52C8EC7B2C3536E5002DC35C /* ContinueAudioCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContinueAudioCell.swift; sourceTree = ""; }; + 52C8EC7C2C3536E5002DC35C /* ContinueAudioCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ContinueAudioCell.xib; sourceTree = ""; }; + 52C8EC7F2C358E75002DC35C /* AudioBookDetailsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioBookDetailsVC.swift; sourceTree = ""; }; 52CA28F92BE119F500708B49 /* UserIntrestVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIntrestVC.swift; sourceTree = ""; }; 52CA28FB2BE11A0400708B49 /* UserIntrestVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIntrestVM.swift; sourceTree = ""; }; 52CC38C22BDF812F00B74C3E /* LocalisedElements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalisedElements.swift; sourceTree = ""; }; @@ -893,6 +901,7 @@ isa = PBXGroup; children = ( 52BFB5322C33DAD700BAAE15 /* AudioBookHomeVC.swift */, + 52C8EC7F2C358E75002DC35C /* AudioBookDetailsVC.swift */, ); name = Controller; sourceTree = ""; @@ -908,6 +917,8 @@ 52BFB5302C33DAB100BAAE15 /* View */ = { isa = PBXGroup; children = ( + 52C8EC7B2C3536E5002DC35C /* ContinueAudioCell.swift */, + 52C8EC7C2C3536E5002DC35C /* ContinueAudioCell.xib */, ); name = View; sourceTree = ""; @@ -916,6 +927,7 @@ isa = PBXGroup; children = ( 52BFB5342C33DF8A00BAAE15 /* ListenAudioListingDM.swift */, + 52C8EC792C353653002DC35C /* ContinueAudioListDM.swift */, ); name = Model; sourceTree = ""; @@ -1477,6 +1489,7 @@ 523ED2652BDA2BC700CFED02 /* Base in Resources */, 52D6A2572C22C1E300145908 /* WebSeriesShowListingCell.xib in Resources */, 52BC3BE62C0E0326002FACA6 /* FaqCell.xib in Resources */, + 52C8EC7E2C3536E5002DC35C /* ContinueAudioCell.xib in Resources */, 52C6E01C2BE383C000E22D59 /* YourIntrestCell.xib in Resources */, 9C834ED32C1C1F9200B29A9C /* Exo2-SemiBold.ttf in Resources */, 9C834ED42C1C1F9200B29A9C /* Exo2-Medium.ttf in Resources */, @@ -1581,6 +1594,7 @@ 5259545C2BEBB80400191286 /* AvatarDM.swift in Sources */, 52C8B06C2BDA6E87003B51D0 /* LocalizedString.swift in Sources */, 525953D42BE8B2DF00191286 /* UIApplication.swift in Sources */, + 52C8EC802C358E75002DC35C /* AudioBookDetailsVC.swift in Sources */, 52CC38C32BDF812F00B74C3E /* LocalisedElements.swift in Sources */, 5259545E2BEBBA1A00191286 /* LoadingIndicatorImageView.swift in Sources */, 52B8D4DC2C04A25E00ED65F3 /* Delegate.swift in Sources */, @@ -1591,6 +1605,7 @@ 52D6A24C2C21B43300145908 /* WebSeriesCell.swift in Sources */, 5242FE5B2C24317A0086A86D /* WebSeriesSeasonVM.swift in Sources */, 524C422B2C04781B0016A11C /* ThemeTwoVM.swift in Sources */, + 52C8EC7A2C353653002DC35C /* ContinueAudioListDM.swift in Sources */, 52B8D4DF2C04A25E00ED65F3 /* StatusBar.swift in Sources */, 5259541D2BE8D94400191286 /* QueueHelper.swift in Sources */, 525954232BE8F00400191286 /* BaseResponseModel.swift in Sources */, @@ -1672,6 +1687,7 @@ 522D655E2C1ACCF40021E505 /* UserNotificationDM.swift in Sources */, 9C1C69FC2C106C240035B2C7 /* ContactSupportVM.swift in Sources */, 52A3F6AF2BECC0690000BB0B /* LinkedChildVM.swift in Sources */, + 52C8EC7D2C3536E5002DC35C /* ContinueAudioCell.swift in Sources */, 525954252BE8F01600191286 /* ValueWrapper.swift in Sources */, 52A3F6A82BECBF2A0000BB0B /* LinkedChildCell.swift in Sources */, 52BC3BEE2C16FBDB002FACA6 /* MoreVC.swift in Sources */, diff --git a/WOKA/Audio Books/AudioBookDetailsVC.swift b/WOKA/Audio Books/AudioBookDetailsVC.swift new file mode 100644 index 0000000..05d8231 --- /dev/null +++ b/WOKA/Audio Books/AudioBookDetailsVC.swift @@ -0,0 +1,79 @@ +// +// AudioBookDetailsVC.swift +// WOKA +// +// Created by MacBook Pro on 03/07/24. +// + +import UIKit + +class AudioBookDetailsVC : UIViewController{ + + @IBOutlet weak var watchingImage: UIImageView! + @IBOutlet weak var watchingTitle: UILabel! + @IBOutlet weak var watchingDesc: UITextView! + + // Completion block to be executed when the alert is dismissed + var onDoneBlock: (() -> Void)? + + var audioData : ListenAudioListingDM.AudioDatum? + + var continueAudioData : ContinueAudioListDM.ResultData? + + override func viewDidLoad() { + super.viewDidLoad() + + if let audioData{ + if let url = audioData.thumbnailPath{ + watchingImage.imageURL(url, color: .white) + } + + if AuthFunc.shareInstance.getDefaultLanguage() == .english{ + if let englishData = audioData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first{ + watchingTitle.text = englishData.title + if let desc = englishData.description?.replacingOccurrences(of: "
", 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{ + if let hindiData = audioData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first{ + watchingTitle.text = hindiData.title + if let desc = hindiData.description?.replacingOccurrences(of: "
", 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 + } + } + } + } + + if let continueAudioData{ + if let url = continueAudioData.thumbnailPath{ + watchingImage.imageURL(url, color: .white) + } + + if AuthFunc.shareInstance.getDefaultLanguage() == .english{ + if let englishData = continueAudioData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first{ + watchingTitle.text = englishData.title + } + }else{ + if let hindiData = continueAudioData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first{ + watchingTitle.text = hindiData.title + } + } + } + + } + + @IBAction func watchBtnTapped(_ sender: LocalisedElementsButton) { + + } + + @IBAction func closeBtnTapped(_ sender: LocalisedElementsButton) { + self.dismiss(animated: true) { + + } + } +} diff --git a/WOKA/Audio Books/AudioBookHomeVC.swift b/WOKA/Audio Books/AudioBookHomeVC.swift index af8cfe4..db71526 100644 --- a/WOKA/Audio Books/AudioBookHomeVC.swift +++ b/WOKA/Audio Books/AudioBookHomeVC.swift @@ -30,8 +30,8 @@ class AudioBookHomeVC: UIViewController { self.title = "AUDIO BOOKS" vm.initView() scrollView.delegate = self - let color1 = #colorLiteral(red: 0, green: 0.7529411765, blue: 0.7529411765, alpha: 1) - let color2 = #colorLiteral(red: 0, green: 0.4784313725, blue: 0.7529411765, alpha: 1) + let color1 = #colorLiteral(red: 0, green: 0.4784313725, blue: 0.7529411765, alpha: 1) + let color2 = #colorLiteral(red: 0, green: 0.7529411765, blue: 0.7529411765, alpha: 1) self.navigationController?.navigationBar.setGradientBackground(colors: [color1, color2], startPoint: .left, endPoint: .right) @@ -83,7 +83,7 @@ extension AudioBookHomeVC : TableViewSRC{ } cell.btnTapped = { [self] (type) -> Void in - updateFavLikes(type: type, index: indexPath.row) + vm.updateFavLikes(type: type, index: indexPath.row, id: vm.audioListData[indexPath.row].id ?? 0) } return cell @@ -140,6 +140,20 @@ extension AudioBookHomeVC : TableViewSRC{ } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + /* + Updated the top header data + */ + vm.indexToLoad = indexPath.row + vm.setInitialData() + + let data = vm.audioListData[indexPath.row] + + let sb = UIStoryboard(name: K.StoryBoard.audioBooks, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.AudioBooks.audioBookDetailsVC) as! AudioBookDetailsVC + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + vcPush.audioData = data + self.present(vcPush, animated: true) // if vm.showData.count == 0 {return} // let showData = vm.showData[indexPath.row] // @@ -165,13 +179,25 @@ extension AudioBookHomeVC : CollectionViewSRC{ } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.WebSeries.webSeriesCell, for: indexPath) as! WebSeriesCell + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.AudioBooks.continueAudioCell, for: indexPath) as! ContinueAudioCell let data = vm.continueWatchingData[indexPath.row] - cell.setData(data: data) + cell.setAudioData(data: data) + + cell.btnTapped = { [self] (type) -> Void in + vm.updateFavLikes(type: type, index: indexPath.row, id: vm.continueWatchingData[indexPath.row].id ?? 0) + } return cell } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let data = vm.continueWatchingData[indexPath.row] + + let sb = UIStoryboard(name: K.StoryBoard.audioBooks, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.AudioBooks.audioBookDetailsVC) as! AudioBookDetailsVC + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + vcPush.continueAudioData = data + self.present(vcPush, animated: true) // let data = vm.continueWatchingData[indexPath.row] // // let sb = UIStoryboard(name: K.StoryBoard.webSeries, bundle: nil) diff --git a/WOKA/Audio Books/AudioBookHomeVM.swift b/WOKA/Audio Books/AudioBookHomeVM.swift index b93f6d0..e43ec22 100644 --- a/WOKA/Audio Books/AudioBookHomeVM.swift +++ b/WOKA/Audio Books/AudioBookHomeVM.swift @@ -11,7 +11,7 @@ import Alamofire class AudioBookHomeVM{ weak var vc : AudioBookHomeVC! - var continueWatchingData = [ContinueWatchingDM.ResultData]() + var continueWatchingData = [ContinueAudioListDM.ResultData]() var audioListData = [ListenAudioListingDM.AudioDatum]() var indexToLoad = 0 @@ -53,22 +53,22 @@ class AudioBookHomeVM{ } func setupCell(){ - vc.continueWatchingCV.register(UINib(nibName: K.CellIdentifier.WebSeries.webSeriesCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.WebSeries.webSeriesCell) + vc.continueWatchingCV.register(UINib(nibName: K.CellIdentifier.AudioBooks.continueAudioCell, bundle: nil), forCellWithReuseIdentifier: K.CellIdentifier.AudioBooks.continueAudioCell) vc.continueWatchingCV.delegate = vc.self vc.continueWatchingCV.dataSource = vc.self - + vc.audioListingTableView.register(UINib(nibName: K.CellIdentifier.WebSeries.webSeriesShowListingCell, bundle: nil), forCellReuseIdentifier: K.CellIdentifier.WebSeries.webSeriesShowListingCell) vc.audioListingTableView.delegate = vc.self vc.audioListingTableView.dataSource = vc.self } // MARK: - Api Calls - + func getContinueWatching(){ -// Utilities.startProgressHUD() + // Utilities.startProgressHUD() let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()] - let params : Parameters = ["post_type" : 7] // 3- audio - NetworkManager.shareInstance.apiRequest(url: APIEndPoints.WebSeries.continue_watching, method: .post,parameters: params,headers : headers) { [weak self](result : Result, NetworkManager.APIError>) in + let params : Parameters = ["post_type" : 7] // 7 - audio + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.WebSeries.continue_watching, method: .post,parameters: params,headers : headers) { [weak self](result : Result, NetworkManager.APIError>) in switch result{ case .success(let data): guard let self else{ @@ -81,7 +81,7 @@ class AudioBookHomeVM{ Error */ Utilities.dismissProgressHUD() -// vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + // vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) self.vc.continueWatchingStack.isHidden = true case 1: Utilities.dismissProgressHUD() @@ -109,7 +109,7 @@ class AudioBookHomeVM{ } func getShowListing(){ -// Utilities.startProgressHUD() + // Utilities.startProgressHUD() let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()] NetworkManager.shareInstance.apiRequest(url: APIEndPoints.AudioBooks.listen_audio_listing, method: .post,headers: headers) { [weak self](result : Result, NetworkManager.APIError>) in switch result{ @@ -154,7 +154,90 @@ class AudioBookHomeVM{ func stopShimmer(){ self.vc.headerView.stopShimmer() vc.listenView.stopShimmer() -// self.vc.masilaTrailerView.stopShimmer() -// self.vc.videoLanguageView.stopShimmer() + // self.vc.masilaTrailerView.stopShimmer() + // self.vc.videoLanguageView.stopShimmer() + } + + // MARK: - Update Fav Likes + + func updateFavLikes(type : FavCellCLick, index : Int, id : Int){ + guard let data = audioListData.filter({$0.id == id}).first, let audioListIndex = audioListData.firstIndex(where: {$0.id == id}) else{return} + switch type { + case .favourite: + guard let isFav = data.markAsFavourite ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return} + if isFav == true { + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + if isDone{ + audioListData[audioListIndex].markAsFavourite = false + vc.audioListingTableView.reloadRows(at: [IndexPath(row: audioListIndex, section: 0)],with: .none) + K.GVar.reloadMyList = true + + /* + Check if the data is in continue watching + */ + if let continueWatchingIndex = continueWatchingData.firstIndex(where: { $0.id == id }){ + continueWatchingData[continueWatchingIndex].markAsFavourite = false + vc.continueWatchingCV.reloadItems(at: [IndexPath(row: continueWatchingIndex, section: 0)]) + } + } + } + }else{ + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + if isDone{ + audioListData[audioListIndex].markAsFavourite = true + vc.audioListingTableView.reloadRows(at: [IndexPath(row: audioListIndex, section: 0)],with: .none) + K.GVar.reloadMyList = true + + /* + Check if the data is in continue watching + */ + if let continueWatchingIndex = continueWatchingData.firstIndex(where: { $0.id == id }){ + continueWatchingData[continueWatchingIndex].markAsFavourite = true + vc.continueWatchingCV.reloadItems(at: [IndexPath(row: continueWatchingIndex, section: 0)]) + } + } + } + } + return + case .liked: + guard let isLiked = data.isLiked ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return} + if isLiked{ + LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in + if isDone{ + audioListData[audioListIndex].isLiked = false + audioListData[audioListIndex].likesCount! -= 1 + vc.audioListingTableView.reloadRows(at: [IndexPath(row: audioListIndex, section: 0)],with: .none) + K.GVar.reloadMyList = true + + /* + Check if the data is in continue watching + */ + if let continueWatchingIndex = continueWatchingData.firstIndex(where: { $0.id == id }){ + continueWatchingData[continueWatchingIndex].isLiked = false + continueWatchingData[continueWatchingIndex].likesCount! -= 1 + vc.continueWatchingCV.reloadItems(at: [IndexPath(row: continueWatchingIndex, section: 0)]) + } + } + } + }else{ + LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in + if isDone{ + audioListData[audioListIndex].isLiked = true + audioListData[audioListIndex].likesCount! += 1 + vc.audioListingTableView.reloadRows(at: [IndexPath(row: audioListIndex, section: 0)],with: .none) + K.GVar.reloadMyList = true + + /* + Check if the data is in continue watching + */ + if let continueWatchingIndex = continueWatchingData.firstIndex(where: { $0.id == id }){ + continueWatchingData[continueWatchingIndex].isLiked = true + continueWatchingData[continueWatchingIndex].likesCount! += 1 + vc.continueWatchingCV.reloadItems(at: [IndexPath(row: continueWatchingIndex, section: 0)]) + } + } + } + } + } } } diff --git a/WOKA/Audio Books/AudioBooks.storyboard b/WOKA/Audio Books/AudioBooks.storyboard index 67c6d0f..7562d4d 100644 --- a/WOKA/Audio Books/AudioBooks.storyboard +++ b/WOKA/Audio Books/AudioBooks.storyboard @@ -4,7 +4,9 @@ + + @@ -190,5 +192,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WOKA/Audio Books/ContinueAudioCell.swift b/WOKA/Audio Books/ContinueAudioCell.swift new file mode 100644 index 0000000..81f5e88 --- /dev/null +++ b/WOKA/Audio Books/ContinueAudioCell.swift @@ -0,0 +1,80 @@ +// +// ContinueAudioCell.swift +// WOKA +// +// Created by MacBook Pro on 03/07/24. +// + +import UIKit + +class ContinueAudioCell: UICollectionViewCell { + + @IBOutlet weak var audioBookThumbnail: UIImageView! + @IBOutlet weak var audioBookTitle: UILabel! + @IBOutlet weak var totalLikes: UILabel! + @IBOutlet weak var likeBtn: UIButton! + @IBOutlet weak var favBtn: UIButton! + @IBOutlet weak var shimmerView: ShimmerEffectView! + + typealias btnTappedBlock = ( _ from : FavCellCLick) -> Void // 0 - plus 1 - minus + var btnTapped : btnTappedBlock! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + func showShimmer(){ + shimmerView.startShimmer() + } + + func stopShimmer(){ + shimmerView.stopShimmer() + } + + func setAudioData(data: ContinueAudioListDM.ResultData){ + //heart.fill , heart , hand.thumbsup.fill , hand.thumbsup + if AuthFunc.shareInstance.getDefaultLanguage() == .english{ + audioBookTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 1}).first?.title + }else{ + audioBookTitle.text = data.contentMoreDetails?.filter({$0.languageMasterID == 2}).first?.title + } + totalLikes.text = data.likesCount?.toString() ?? "0" + + if let url = data.thumbnailPath{ + audioBookThumbnail.imageURL(url) + } + + if let like = data.isLiked{ + switch like{ + case true: + likeBtn.setImage(UIImage(named: "LikeAdd"), for: .normal) + case false: + likeBtn.setImage(UIImage(named: "LikeRemove"), for: .normal) + } + } + + if let favourite = data.markAsFavourite{ + if favourite == true{ + favBtn.setImage(UIImage(named: "FavouriteAdd"), for: .normal) + }else{ + favBtn.setImage(UIImage(named: "FavouriteRemove"), for: .normal) + } + } + } + + @IBAction func btnTapped(_ sender: UIButton) { + switch sender{ + case likeBtn: + if btnTapped != nil { + btnTapped( .liked) + } + case favBtn: + if btnTapped != nil { + btnTapped( .favourite) + } + default: + break + } + } +} diff --git a/WOKA/Audio Books/ContinueAudioCell.xib b/WOKA/Audio Books/ContinueAudioCell.xib new file mode 100644 index 0000000..540fd24 --- /dev/null +++ b/WOKA/Audio Books/ContinueAudioCell.xib @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + Exo2-Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WOKA/Audio Books/ContinueAudioListDM.swift b/WOKA/Audio Books/ContinueAudioListDM.swift new file mode 100644 index 0000000..e2e38f3 --- /dev/null +++ b/WOKA/Audio Books/ContinueAudioListDM.swift @@ -0,0 +1,92 @@ +// +// File.swift +// WOKA +// +// Created by MacBook Pro on 03/07/24. +// + +import Foundation + +// MARK: - ContinueAudioListDM +struct ContinueAudioListDM: Codable { + let result: [ResultData]? + let totalRecords: Int? + + enum CodingKeys: String, CodingKey { + case result + case totalRecords = "total_records" + } + + // MARK: - ResultData + struct ResultData: Codable { + let id: Int? + let title, description: String? + let thumbnailPath: String? + let audioURL: String? + let categoryMasterID, ageRangeMasterID, tagsKeyword, releaseDate: String? + let languageMasterID: Int? + let genderMasterID, audioDuration, mediaID: String? + let contentMoreDetails: [ContentMoreDetail]? + let userVideoView: [UserVideoView]? + let showDataCount: Int? + var markAsFavourite, isLiked: Bool? + var viewsCount, likesCount, bookmarkCount: Int? + + enum CodingKeys: String, CodingKey { + case id, title, description + case thumbnailPath = "thumbnail_path" + case audioURL = "audio_url" + case categoryMasterID = "category_master_id" + case ageRangeMasterID = "age_range_master_id" + case tagsKeyword = "tags_keyword" + case releaseDate = "release_date" + case languageMasterID = "language_master_id" + case genderMasterID = "gender_master_id" + case audioDuration = "audio_duration" + case mediaID = "media_id" + case contentMoreDetails = "content_more_details" + case userVideoView = "user_video_view" + case showDataCount = "show_data_count" + case markAsFavourite = "mark_as_favourite" + case isLiked = "is_liked" + case viewsCount = "views_count" + case likesCount = "likes_count" + case bookmarkCount = "bookmark_count" + } + } + + // MARK: - ContentMoreDetail + struct ContentMoreDetail: Codable { + let id, contentID, postType, languageMasterID: Int? + let title, description: String? + let url: String? + let tagsKeywords: String? + + enum CodingKeys: String, CodingKey { + case id + case contentID = "content_id" + case postType = "post_type" + case languageMasterID = "language_master_id" + case title, description, url + case tagsKeywords = "tags_keywords" + } + } + + // MARK: - UserVideoView + struct UserVideoView: Codable { + let id, userID, postID, postType: Int? + let totalWatchedDuration, lastWatchedLeft: String? + let categoryID: Int? + + enum CodingKeys: String, CodingKey { + case id + case userID = "user_id" + case postID = "post_id" + case postType = "post_type" + case totalWatchedDuration = "total_watched_duration" + case lastWatchedLeft = "last_watched_left" + case categoryID = "category_id" + } + } +} + diff --git a/WOKA/Audio Books/ListenAudioListingDM.swift b/WOKA/Audio Books/ListenAudioListingDM.swift index a22c2d1..ecf1adc 100644 --- a/WOKA/Audio Books/ListenAudioListingDM.swift +++ b/WOKA/Audio Books/ListenAudioListingDM.swift @@ -31,8 +31,8 @@ struct ListenAudioListingDM: Codable { // let userVideoView: [JSONAny]? let categoryData: [CategoryDatum]? // let ageRangeData, genderData: [JSONAny]? - let markAsFavourite, isLiked: Bool? - let viewsCount, likesCount, bookmarkCount: Int? + var markAsFavourite, isLiked: Bool? + var viewsCount, likesCount, bookmarkCount: Int? enum CodingKeys: String, CodingKey { case id, title, description diff --git a/WOKA/Constants K/CellIdentifier.swift b/WOKA/Constants K/CellIdentifier.swift index a46b3d6..56349db 100644 --- a/WOKA/Constants K/CellIdentifier.swift +++ b/WOKA/Constants K/CellIdentifier.swift @@ -44,5 +44,9 @@ extension K{ static let seasonCategoryCell = "SeasonCategoryCell" static let webSeriesEpisodeCell = "WebSeriesEpisodeCell" } + + struct AudioBooks{ + static let continueAudioCell = "ContinueAudioCell" + } } } diff --git a/WOKA/Constants K/StoryBoardID.swift b/WOKA/Constants K/StoryBoardID.swift index a9fda95..3976422 100644 --- a/WOKA/Constants K/StoryBoardID.swift +++ b/WOKA/Constants K/StoryBoardID.swift @@ -70,6 +70,7 @@ extension K{ struct AudioBooks{ static let audioBookHomeVC = "AudioBookHomeVC" + static let audioBookDetailsVC = "AudioBookDetailsVC" } } diff --git a/WOKA/WebSeries/ViewModel/WebSeriesVM.swift b/WOKA/WebSeries/ViewModel/WebSeriesVM.swift index 7835bc3..fa766b8 100644 --- a/WOKA/WebSeries/ViewModel/WebSeriesVM.swift +++ b/WOKA/WebSeries/ViewModel/WebSeriesVM.swift @@ -237,6 +237,5 @@ class WebSeriesVM{ } } } - - + }