From 7efcbb2d24aca1ce69e607b973ace28e5fca0c56 Mon Sep 17 00:00:00 2001 From: BilalKhanWDI Date: Tue, 1 Oct 2024 19:57:04 +0530 Subject: [PATCH] - Worked on my list and notification bottom Banner - Tc - 69 fixed - Tc - 70 fixed - TC 71 fixed - Added local ads to fm and more section - Added local ads to mylist - Fixed a bug for sync * Fixed the crashing by temporary updating the wokastaging with raw data --- WOKA.xcodeproj/project.pbxproj | 4 +- WOKA/Audio Books/AudioBookHomeVM.swift | 16 +- WOKA/Constants K/GoogleAdIDs.swift | 2 + .../PersistentStorage.swift | 8 +- WOKA/Games/ViewModel/GamesListVM.swift | 12 +- WOKA/Home/Controller/MyListVC.swift | 12 +- WOKA/Home/Home.storyboard | 612 +++++++++--------- WOKA/Home/ViewModel/MyListVM.swift | 66 +- WOKA/Karaoke/ViewModel/KaraokeListingVM.swift | 12 +- WOKA/Main/AuthFunc/AuthFunc.swift | 1 + WOKA/Shop/Shop.storyboard | 22 +- .../Controller/SideMenuVC.swift | 2 +- .../Controller/TabBarVC.swift | 6 +- WOKA/Theme/Base.lproj/Theme.storyboard | 70 +- WOKA/Theme/Controller/BlogsVC.swift | 77 +++ WOKA/Theme/Controller/MoreVC.swift | 5 +- .../Theme/Controller/UserNotificationVC.swift | 48 +- WOKA/Theme/ViewModel/MoreVM.swift | 46 +- WOKA/Theme/ViewModel/ThemeOneVM.swift | 2 +- WOKA/Theme/ViewModel/UserNotificationVM.swift | 58 +- WOKA/WOKAFM/Controller/WokaFMVC.swift | 15 +- WOKA/WOKAFM/ViewModel/WokaFMVM.swift | 49 +- WOKA/WOKAFM/WokaFM.storyboard | 10 +- WOKA/WebSeries/Controller/WebSeriesVC.swift | 12 +- 24 files changed, 749 insertions(+), 418 deletions(-) diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index 38d0635..4f33547 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -2895,7 +2895,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 4S9A74ZB6H; ENABLE_USER_SCRIPT_SANDBOXING = NO; @@ -2939,7 +2939,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = 4S9A74ZB6H; ENABLE_USER_SCRIPT_SANDBOXING = NO; GENERATE_INFOPLIST_FILE = YES; diff --git a/WOKA/Audio Books/AudioBookHomeVM.swift b/WOKA/Audio Books/AudioBookHomeVM.swift index 1709957..39a6880 100644 --- a/WOKA/Audio Books/AudioBookHomeVM.swift +++ b/WOKA/Audio Books/AudioBookHomeVM.swift @@ -37,7 +37,8 @@ class AudioBookHomeVM{ startShimmer() setupCell() getShowListing() - + checkAds() + } func checkAds(){ @@ -135,7 +136,6 @@ class AudioBookHomeVM{ self.vc.continueWatchingStack.isHidden = true case 1: Utilities.dismissProgressHUD() - checkAds() guard let data = data.data?.result else{return} if data.count == 0{ @@ -264,7 +264,8 @@ class AudioBookHomeVM{ guard let isFav else{return} if isFav == true { // if is fav then remove it - LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){ audioListData[showListIndex].markAsFavourite = false @@ -298,8 +299,9 @@ class AudioBookHomeVM{ } } }else{ - LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in if isDone{ + guard let self else{return} if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){ audioListData[showListIndex].markAsFavourite = true vc.audioListingTableView.reloadRows(at: [IndexPath(row: showListIndex, section: 0)],with: .none) @@ -337,7 +339,8 @@ class AudioBookHomeVM{ guard let isLiked else{return} if isLiked{ // Unlike - LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){ audioListData[showListIndex].isLiked = false @@ -367,7 +370,8 @@ class AudioBookHomeVM{ } }else{ //Like - LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in + LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){ audioListData[showListIndex].isLiked = true diff --git a/WOKA/Constants K/GoogleAdIDs.swift b/WOKA/Constants K/GoogleAdIDs.swift index 63fead9..215cdef 100644 --- a/WOKA/Constants K/GoogleAdIDs.swift +++ b/WOKA/Constants K/GoogleAdIDs.swift @@ -27,6 +27,8 @@ extension K{ static let myListNotifications = "ca-app-pub-5699008063638916/8922510426" + static let blogs = "ca-app-pub-5699008063638916/8441860789" + // // // diff --git a/WOKA/DataSync&AdsManage/PersistentStorage.swift b/WOKA/DataSync&AdsManage/PersistentStorage.swift index 6810a30..c5c9e8b 100644 --- a/WOKA/DataSync&AdsManage/PersistentStorage.swift +++ b/WOKA/DataSync&AdsManage/PersistentStorage.swift @@ -286,7 +286,9 @@ final class PersistentStorage return } else{ // send data again to server - sendDataToServer() + if result.count != 0{ + sendDataToServer(isLogout: isLogout) + } print("Data sent Again.") } @@ -424,7 +426,9 @@ extension PersistentStorage{ return }else{ // send ads data again to server - sendAdsData() + if result.count != 0{ + sendAdsData() + } print("Ads Data sent Again.") } diff --git a/WOKA/Games/ViewModel/GamesListVM.swift b/WOKA/Games/ViewModel/GamesListVM.swift index af51779..d43d8ac 100644 --- a/WOKA/Games/ViewModel/GamesListVM.swift +++ b/WOKA/Games/ViewModel/GamesListVM.swift @@ -213,7 +213,8 @@ class GamesListVM{ 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 + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ gameData[index].markAsFavourite = false vc.gamesListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) @@ -228,7 +229,8 @@ class GamesListVM{ } } }else{ - LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ gameData[index].markAsFavourite = true vc.gamesListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none) @@ -246,7 +248,8 @@ class GamesListVM{ 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 + LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ gameData[index].isLiked = false gameData[index].likesCount! -= 1 @@ -264,7 +267,8 @@ class GamesListVM{ } } }else{ - LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in + LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in + guard let self else{return} if isDone{ gameData[index].isLiked = true gameData[index].likesCount! += 1 diff --git a/WOKA/Home/Controller/MyListVC.swift b/WOKA/Home/Controller/MyListVC.swift index fea5d0b..1ae7b29 100644 --- a/WOKA/Home/Controller/MyListVC.swift +++ b/WOKA/Home/Controller/MyListVC.swift @@ -41,6 +41,7 @@ class MyListVC: UIViewController{ @IBOutlet weak var shimmerStack: UIStackView! @IBOutlet var shimmerView: [ShimmerEffectView]! @IBOutlet weak var adView: UIView! + @IBOutlet weak var adHeight: NSLayoutConstraint! var vm = MyListVM() @@ -61,7 +62,8 @@ class MyListVC: UIViewController{ } @objc func refresh(_ sender: AnyObject) { - Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { [unowned self] _ in + Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { [weak self] _ in + guard let self else{return} vm.getFavouriteListing() } } @@ -807,10 +809,9 @@ extension MyListVC : UICollectionViewDelegateFlowLayout{ // MARK: - Google Ad Banner Delegate extension MyListVC : GADBannerViewDelegate{ + func bannerViewDidReceiveAd(_ bannerView: GADBannerView) { - adView.isHidden = false bannerView.alpha = 0 - bannerView.backgroundColor = #colorLiteral(red: 0.01960784314, green: 0, blue: 0.2196078431, alpha: 1) UIView.animate(withDuration: 0.2, animations: { bannerView.alpha = 1 }) @@ -818,6 +819,11 @@ extension MyListVC : GADBannerViewDelegate{ } func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) { + UIView.animate(withDuration: 0.2, animations: { [weak self] in + guard let self else{return} + bannerView.alpha = 0 + adHeight.constant = 0 + }) print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)") } diff --git a/WOKA/Home/Home.storyboard b/WOKA/Home/Home.storyboard index 65d18cb..6b8b92e 100644 --- a/WOKA/Home/Home.storyboard +++ b/WOKA/Home/Home.storyboard @@ -1071,312 +1071,307 @@ - - + + - - + + - - + + - - + + - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + - - + + - + - - - @@ -1490,11 +1482,8 @@ - + - - - @@ -1502,11 +1491,8 @@ - + - - - @@ -1523,10 +1509,9 @@ - - - + + @@ -1534,24 +1519,29 @@ - + + + + - + + + @@ -1667,10 +1657,10 @@ - + - + diff --git a/WOKA/Home/ViewModel/MyListVM.swift b/WOKA/Home/ViewModel/MyListVM.swift index 8321c29..3f9f18c 100644 --- a/WOKA/Home/ViewModel/MyListVM.swift +++ b/WOKA/Home/ViewModel/MyListVM.swift @@ -37,6 +37,59 @@ class MyListVM{ startShimmer(load: false) return } + + /* + First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads. + */ + if let adsData = AuthFunc.shareInstance.adsData, let myListAd = adsData.result?.filter({$0.slug == AdsEnum.myList.rawValue}).first{ + + // check if ads data contains LocalAD for webseries + if let advertisement = myListAd.advertisement,let bannerImage = advertisement.bannerImage{ +// vc.imageAdView.imageURL(bannerImage, color: .white) +// vc.imageAdView.alpha = 0 + let height = UIScreen.main.bounds.width * 0.192 + vc.adHeight.constant = height + + let imageView = UIImageView() + + // Set the image you want to display + imageView.imageURL(bannerImage, color: .white) + + // Enable auto-layout + imageView.translatesAutoresizingMaskIntoConstraints = false + + // Add the UIImageView to the view + vc.adView.addSubview(imageView) + + // Set UIImageView to match the size of the parent UIView + NSLayoutConstraint.activate([ + imageView.leadingAnchor.constraint(equalTo: vc.adView.leadingAnchor), + imageView.trailingAnchor.constraint(equalTo: vc.adView.trailingAnchor), + imageView.topAnchor.constraint(equalTo: vc.adView.topAnchor), + imageView.bottomAnchor.constraint(equalTo: vc.adView.bottomAnchor) + ]) + imageView.contentMode = .scaleAspectFit + UIView.animate(withDuration: 0.2, animations: { [weak self] in + guard let self else{return} + vc.adView.alpha = 1 + }) + + vc.adView.addTapGesture { + if let adID = myListAd.id{ + PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1) + } + if let adLink = myListAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url) + } + } + }else if myListAd.googleAd != nil{ + //setup google banner ads. + vc.adHeight.constant = 90 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { + AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBanner, in: self.vc.adView, adUnitID: K.GoogleAdIDs.myListNotifications, viewController: self.vc, height: 6,width: 0) + }) + } + } setupCell() startShimmer(load: true) @@ -59,18 +112,7 @@ class MyListVM{ shimmer.startShimmer() }else{ shimmer.stopShimmer() - /* - If ads found then only load it or else directly append the data and reload - */ - if let adsData = AuthFunc.shareInstance.adsData{ - // check if ads data contains ad for webseries - if let myListAd = adsData.result?.filter({$0.slug == AdsEnum.myList.rawValue}).first, myListAd.googleAd != nil{ - //setup google banner ads. - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { - AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBanner, in: self.vc.adView, adUnitID: K.GoogleAdIDs.myListNotifications, viewController: self.vc, height: 6,width: 0) - }) - } - } + } } } diff --git a/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift b/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift index 0344c83..781c49b 100644 --- a/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift +++ b/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift @@ -243,7 +243,8 @@ class KaraokeListingVM{ case .favourite: guard let isFav else{return} if isFav == true { - LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){ karaokeListData[showListIndex].markAsFavourite = false @@ -278,7 +279,8 @@ class KaraokeListingVM{ } } }else{ - LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){ karaokeListData[showListIndex].markAsFavourite = true @@ -318,7 +320,8 @@ class KaraokeListingVM{ case .liked: guard let isLiked else{return} if isLiked{ - LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in + LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){ karaokeListData[showListIndex].isLiked = false @@ -348,7 +351,8 @@ class KaraokeListingVM{ } } }else{ - LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in + LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in + guard let self else{return} if isDone{ if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){ karaokeListData[showListIndex].isLiked = true diff --git a/WOKA/Main/AuthFunc/AuthFunc.swift b/WOKA/Main/AuthFunc/AuthFunc.swift index 6d0e46f..67fb4a8 100644 --- a/WOKA/Main/AuthFunc/AuthFunc.swift +++ b/WOKA/Main/AuthFunc/AuthFunc.swift @@ -32,6 +32,7 @@ enum AdsEnum : String{ case webSeriesVideoAd = "web-series-video-ad" case more = "more" case myList = "my-list" + case shopListing = "shop-listing" } class AuthFunc{ diff --git a/WOKA/Shop/Shop.storyboard b/WOKA/Shop/Shop.storyboard index 2a5cea0..fe1f2ce 100644 --- a/WOKA/Shop/Shop.storyboard +++ b/WOKA/Shop/Shop.storyboard @@ -122,17 +122,17 @@ - + - + - +