- started integration of google ads in iOS

- Fixed shop issue when showing ads. TC - 66
- TC 40 done.
- added test ads on games. Intestial ad for ludo and reward ads for carrom
- added error handling for karaoke listing
- added error handling for audio books listing
- fixed a bug where session expired message was show in dialog, and dialog was getting dismissed when clicked outside
This commit is contained in:
Bilal
2024-09-06 00:19:48 +05:30
parent 4c8e7d3ec0
commit 219105b314
15 changed files with 285 additions and 61 deletions

View File

@@ -22,6 +22,8 @@ class AlertCustomVC: UIViewController {
var yesBtnText: String?
var mainTitleText: String?
var outsideViewTapGestureEnabled = true
override func viewDidLoad() {
super.viewDidLoad()
@@ -29,8 +31,10 @@ class AlertCustomVC: UIViewController {
setBtnName()
// Dismiss the alert when tapping outside
outsideView.addTapGesture {
self.dismiss(animated: true)
if outsideViewTapGestureEnabled == true{
outsideView.addTapGesture {
self.dismiss(animated: true)
}
}
}

View File

@@ -26,6 +26,7 @@ class AudioBookHomeVC: UIViewController {
@IBOutlet weak var headerTitleLabel: UILabel!
@IBOutlet weak var listenView: ShimmerEffectView!
@IBOutlet weak var noDataView: UIView!
@IBOutlet weak var loadMoreBtn: LocalisedElementsButton!
@IBOutlet weak var loadMoreActivityIndicator: UIActivityIndicatorView!
@@ -125,6 +126,17 @@ class AudioBookHomeVC: UIViewController {
}
JWPlayerManager.shared.presentPlayer(from: self, playerItems: playerItems, startIndex: 0, contentType: .audioBooks, videoIDs: [postID])
}
@IBAction func retryBtnTapped(_ sender: LocalisedElementsButton) {
/*
make page 0 as its lazy loading, hide the no data stack as retry is tapped,
start the shimmer and reload tableview so that both header and table shimmer matches, get the karaoke listing
*/
vm.pageNo = 0
noDataView.isHidden = true
vm.startShimmer()
vm.getShowListing()
}
}
// MARK: - Delegate for reload
@@ -206,16 +218,22 @@ extension AudioBookHomeVC : TableViewSRC{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let data = vm.audioListData[indexPath.row]
/*
Updated the top header data
*/
vm.headerData = data
if let postID = data.id{
PersistentStorage.shared.addAudioCount(postID: postID)
}
vm.setHeaderData()
/*
MAke logic for ads
*/
if let adsData = AuthFunc.shareInstance.adsData, adsData.result?.filter({$0.forPage == AdsEnum.audioBooks.rawValue}).first != nil{
// check if ads data contains ad for webseries
}else{
/*
Updated the top header data
*/
vm.headerData = data
vm.setHeaderData()
}
let sb = UIStoryboard(name: K.StoryBoard.audioBooks, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.AudioBooks.audioBookDetailsVC) as! AudioBookDetailsVC
@@ -252,12 +270,23 @@ extension AudioBookHomeVC : CollectionViewSRC{
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let data = vm.continueWatchingData[indexPath.row]
vm.headerData = data
if let postID = data.id{
PersistentStorage.shared.addAudioCount(postID: postID)
}
vm.setHeaderData()
/*
MAke logic for ads
*/
if let adsData = AuthFunc.shareInstance.adsData, adsData.result?.filter({$0.forPage == AdsEnum.karaoke.rawValue}).first != nil{
// check if ads data contains ad for webseries
}else{
/*
Updated the top header data
*/
vm.headerData = data
vm.setHeaderData()
}
let sb = UIStoryboard(name: K.StoryBoard.audioBooks, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.AudioBooks.audioBookDetailsVC) as! AudioBookDetailsVC

View File

@@ -24,7 +24,6 @@ class AudioBookHomeVM{
vc.scrollView.indicatorStyle = .white // or .white
startShimmer()
setupCell()
getContinueWatching()
getShowListing()
//Set banner height
@@ -140,6 +139,7 @@ class AudioBookHomeVM{
vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
case 1:
Utilities.dismissProgressHUD()
getContinueWatching()
guard let dataCount = data.data?.totalRecords ,let data = data.data?.audioData else{return}
self.audioListData.append(contentsOf: data)
self.vc.audioListingTableView.reloadData()
@@ -190,12 +190,9 @@ class AudioBookHomeVM{
return
}
Utilities.dismissProgressHUD()
Utilities.alertWithBtnCompletion(title: "Error", msgBody: error.localizedDescription, okBtnStr: "Retry?", vc: self.vc) { isDone in
if isDone{
self.getShowListing()
}
}
// vc.toast(msg: error.localizedDescription , time: 2)
vc.toast(msg: error.localizedDescription , time: K.ConstantString.errorTime)
self.stopShimmer()
self.vc.noDataView.isHidden = false
}
}
}

View File

@@ -208,13 +208,60 @@
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</stackView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6Su-mo-dnw">
<rect key="frame" x="0.0" y="59" width="393" height="793"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="550-eW-Toj">
<rect key="frame" x="30" y="297.66666666666669" width="333" height="198"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="SupportGirlImage" translatesAutoresizingMaskIntoConstraints="NO" id="qdp-cY-CPw">
<rect key="frame" x="0.0" y="0.0" width="333" height="130"/>
<constraints>
<constraint firstAttribute="height" constant="130" id="wA8-n5-rWF"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Something went wrong." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P0O-o4-myF" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="135" width="333" height="24"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="44M-6j-k3r" customClass="LocalisedElementsButton" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="163.99999999999994" width="333" height="34"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<inset key="titleEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Retry?"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="25"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="retryBtnTapped:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="w7G-Ow-WTi"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="550-eW-Toj" firstAttribute="centerY" secondItem="6Su-mo-dnw" secondAttribute="centerY" id="Fy1-Vk-nBP"/>
<constraint firstItem="550-eW-Toj" firstAttribute="leading" secondItem="6Su-mo-dnw" secondAttribute="leading" constant="30" id="h08-FX-JXi"/>
<constraint firstAttribute="trailing" secondItem="550-eW-Toj" secondAttribute="trailing" constant="30" id="jgU-kX-Z4v"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="eex-XU-cbl" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" id="2ga-A4-vd5"/>
<constraint firstItem="Y14-44-gYV" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="5sV-10-GLu"/>
<constraint firstAttribute="trailing" secondItem="6Su-mo-dnw" secondAttribute="trailing" id="E7b-iv-bbs"/>
<constraint firstItem="6Su-mo-dnw" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" id="JIo-XL-Wac"/>
<constraint firstItem="Y14-44-gYV" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" id="Kpt-XT-bJJ"/>
<constraint firstItem="6Su-mo-dnw" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="LDb-pS-rqY"/>
<constraint firstAttribute="bottom" secondItem="6Su-mo-dnw" secondAttribute="bottom" id="WvV-Kd-QFd"/>
<constraint firstAttribute="bottom" secondItem="eex-XU-cbl" secondAttribute="bottom" id="XjZ-zL-h5N"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="eex-XU-cbl" secondAttribute="trailing" id="jin-5o-F7U"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="Y14-44-gYV" secondAttribute="trailing" id="kq0-mc-gp5"/>
@@ -235,6 +282,7 @@
<outlet property="listenView" destination="U8f-iQ-dPK" id="viY-Sn-3SO"/>
<outlet property="loadMoreActivityIndicator" destination="SC3-M4-kXo" id="WiT-SC-pYV"/>
<outlet property="loadMoreBtn" destination="r2H-eP-JnE" id="6rt-ro-60V"/>
<outlet property="noDataView" destination="6Su-mo-dnw" id="cRp-AO-QlG"/>
<outlet property="scrollView" destination="QFQ-dJ-08w" id="iQT-YH-vSA"/>
<outlet property="tableHeight" destination="B9K-xl-IPt" id="DoT-oS-DrI"/>
<outlet property="topLabel" destination="gVU-VB-fhU" id="z72-4N-T9u"/>
@@ -571,6 +619,7 @@
<image name="CloseIconEmpty" width="30" height="30"/>
<image name="PlayButtonSmall" width="28.333333969116211" height="28.333333969116211"/>
<image name="ShareImage" width="18" height="18"/>
<image name="SupportGirlImage" width="166" height="166"/>
<image name="WebSeriesSeasonsBackground" width="142.66667175292969" height="187.33332824707031"/>
<image name="hand.thumbsup" catalog="system" width="123" height="128"/>
<image name="hand.thumbsup.fill" catalog="system" width="128" height="121"/>

View File

@@ -95,11 +95,7 @@ class CartListVM{
Utilities.dismissProgressHUD()
self.refreshControl.endRefreshing()
self.checkCount()
Utilities.alertWithBtnCompletion(title: "Error", msgBody: error.localizedDescription, okBtnStr: "Retry?", vc: self.vc) { isDone in
if isDone{
self.getCartList()
}
}
vc.toast(msg: error.localizedDescription , time: K.ConstantString.errorTime)
}
}
}

View File

@@ -42,5 +42,7 @@ extension K{
static let rupeeSign = ""
static let sync = "Syncing..."
static let errorTime: Double = 1.6
}
}

View File

@@ -21,6 +21,7 @@ class GamesListVC: UIViewController {
@IBOutlet weak var headerTitleLabel: UILabel!
@IBOutlet weak var gamesLoadingView: ShimmerEffectView!
@IBOutlet weak var noDataView: UIView!
@IBOutlet weak var loadMoreBtn: LocalisedElementsButton!
@IBOutlet weak var loadMoreActivityIndicator: UIActivityIndicatorView!
@@ -47,8 +48,6 @@ class GamesListVC: UIViewController {
rewardedAd = try await GADRewardedAd.load(
withAdUnitID: "ca-app-pub-3940256099942544/1712485313", request: GADRequest())
rewardedAd?.fullScreenContentDelegate = self
} catch {
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
}
@@ -134,6 +133,17 @@ class GamesListVC: UIViewController {
loadMoreActivityIndicator.startAnimating()
vm.getGamesListing(isBtnClick: true)
}
@IBAction func retryBtnTapped(_ sender: LocalisedElementsButton) {
/*
make page 0 as its lazy loading, hide the no data stack as retry is tapped,
start the shimmer and reload tableview so that both header and table shimmer matches, get the karaoke listing
*/
vm.pageNo = 0
noDataView.isHidden = true
vm.startShimmer()
vm.getGamesListing()
}
}
// MARK: - TableView DataSource , Delegates
@@ -163,11 +173,16 @@ extension GamesListVC : TableViewSRC{
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
/*
Updated the top header data
*/
vm.indexToLoad = indexPath.row
vm.setHeaderData()
/*
MAke logic for ads
*/
if let adsData = AuthFunc.shareInstance.adsData, adsData.result?.filter({$0.forPage == AdsEnum.games.rawValue}).first != nil{
// check if ads data contains ad for webseries
}else{
vm.setHeaderData()
}
let data = vm.gameData[indexPath.row]
@@ -179,22 +194,32 @@ extension GamesListVC : TableViewSRC{
This is only for test
*/
if data.title == "WOKA Ludo"{
// guard let interstitial = interstitial else {
// return print("Ad wasn't ready.")
// }
//
// // The UIViewController parameter is an optional.
// interstitial.present(fromRootViewController: nil)
// guard let interstitial = interstitial else {
// return print("Ad wasn't ready.")
// }
//
// // The UIViewController parameter is an optional.
// interstitial.present(fromRootViewController: nil)
guard let rewardedAd = rewardedAd else {
return print("Ad wasn't ready.")
}
// The UIViewController parameter is an optional.
}
// The UIViewController parameter is an optional.
rewardedAd.present(fromRootViewController: nil) {
let reward = rewardedAd.adReward
print("Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)")
// TODO: Reward the user.
}
}
return
}
if data.title == "WOKA Carrom"{
guard let interstitial = interstitial else {
return print("Ad wasn't ready.")
}
// The UIViewController parameter is an optional.
interstitial.present(fromRootViewController: nil)
return
}
@@ -287,13 +312,13 @@ extension GamesListVC : GADFullScreenContentDelegate{
/// Tells the delegate that the ad dismissed full screen content.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
print("Ad did dismiss full screen content.")
let data = vm.gameData.first
let data = vm.gameData[vm.indexToLoad]
let sb = UIStoryboard(name: K.StoryBoard.Games, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Games.gamesDetailVC) as! GamesDetailVC
vcPush.modalPresentationStyle = .overCurrentContext
vcPush.modalTransitionStyle = .crossDissolve
vcPush.gameIndex = 0
vcPush.gameIndex = vm.indexToLoad
vcPush.gameData = data
vcPush.delegate = self
self.present(vcPush, animated: true)

View File

@@ -176,16 +176,63 @@
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</stackView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ROs-m4-xEv">
<rect key="frame" x="10" y="51" width="404" height="845"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="OW3-HV-8mP">
<rect key="frame" x="30" y="323.5" width="344" height="198"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="SupportGirlImage" translatesAutoresizingMaskIntoConstraints="NO" id="qsF-Qj-0Kb">
<rect key="frame" x="0.0" y="0.0" width="344" height="130"/>
<constraints>
<constraint firstAttribute="height" constant="130" id="BPd-9m-vEW"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Something went wrong." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eLt-zc-JAm" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="135" width="344" height="24"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vbZ-dG-AoZ" customClass="LocalisedElementsButton" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="164" width="344" height="34"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<inset key="titleEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Retry?"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="25"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="retryBtnTapped:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="Y5n-MU-qF9"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="OW3-HV-8mP" secondAttribute="trailing" constant="30" id="0UN-2B-8gU"/>
<constraint firstItem="OW3-HV-8mP" firstAttribute="centerY" secondItem="ROs-m4-xEv" secondAttribute="centerY" id="DKX-Jr-G4C"/>
<constraint firstItem="OW3-HV-8mP" firstAttribute="leading" secondItem="ROs-m4-xEv" secondAttribute="leading" constant="30" id="V2k-pQ-kTu"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="nc1-t0-Kr8" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="3QH-ow-RBF"/>
<constraint firstAttribute="bottom" secondItem="ROs-m4-xEv" secondAttribute="bottom" id="5wW-or-L0W"/>
<constraint firstAttribute="trailing" secondItem="nc1-t0-Kr8" secondAttribute="trailing" id="Eur-bw-kP5"/>
<constraint firstItem="nc1-t0-Kr8" firstAttribute="top" secondItem="mer-q0-6Vp" secondAttribute="bottom" id="Lp8-6C-voY"/>
<constraint firstItem="ROs-m4-xEv" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="10" id="Rtr-Oq-368"/>
<constraint firstAttribute="bottom" secondItem="nc1-t0-Kr8" secondAttribute="bottom" id="YKZ-3i-Hqw"/>
<constraint firstItem="ROs-m4-xEv" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="3" id="aS8-Md-HMb"/>
<constraint firstAttribute="trailing" secondItem="mer-q0-6Vp" secondAttribute="trailing" id="b60-eV-Kvu"/>
<constraint firstItem="mer-q0-6Vp" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="fmt-HI-56n"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="ROs-m4-xEv" secondAttribute="trailing" id="uwe-h9-gtg"/>
<constraint firstItem="mer-q0-6Vp" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="yZC-cV-C7l"/>
</constraints>
</view>
@@ -200,6 +247,7 @@
<outlet property="headerView" destination="mer-q0-6Vp" id="Ni3-qe-8Ud"/>
<outlet property="loadMoreActivityIndicator" destination="ulX-KY-9er" id="jGf-y1-HQw"/>
<outlet property="loadMoreBtn" destination="84a-EX-VYD" id="xRs-D4-3hc"/>
<outlet property="noDataView" destination="ROs-m4-xEv" id="JWN-AK-IfB"/>
<outlet property="scrollView" destination="Jyq-DW-OZz" id="1eX-0n-4I1"/>
<outlet property="tableHeight" destination="DJl-l2-EKl" id="5Fi-db-TJJ"/>
</connections>
@@ -605,6 +653,7 @@
<image name="LikeRemove" width="42.5" height="42.5"/>
<image name="PlayButtonSmall" width="28.333333969116211" height="28.333333969116211"/>
<image name="ShareImage" width="18" height="18"/>
<image name="SupportGirlImage" width="166" height="166"/>
<image name="WebSeriesSeasonsBackground" width="142.66667175292969" height="187.33332824707031"/>
<image name="hand.thumbsup.fill" catalog="system" width="128" height="121"/>
<namedColor name="ImageDarkBlue">

View File

@@ -153,11 +153,9 @@ class GamesListVM{
return
}
Utilities.dismissProgressHUD()
Utilities.alertWithBtnCompletion(title: "Error", msgBody: error.localizedDescription, okBtnStr: "Retry?", vc: self.vc) { isDone in
if isDone{
self.getGamesListing()
}
}
self.stopShimmer()
self.vc.noDataView.isHidden = false
vc.toast(msg: error.localizedDescription, time: K.ConstantString.errorTime)
}
}
}

View File

@@ -16,6 +16,7 @@ class KaraokeListingVC: UIViewController {
@IBOutlet weak var headerViewLabelHeight: NSLayoutConstraint!
@IBOutlet weak var headerImage: UIImageView!
@IBOutlet weak var headerTitleLabel: UILabel!
@IBOutlet weak var noDataStack: UIView!
@IBOutlet weak var scrollView: UIScrollView!
@@ -120,6 +121,17 @@ class KaraokeListingVC: UIViewController {
vcPush.delegate = self
self.present(vcPush, animated: true)
}
@IBAction func retryBtnTapped(_ sender: LocalisedElementsButton) {
/*
make page 0 as its lazy loading, hide the no data stack as retry is tapped,
start the shimmer and reload tableview so that both header and table shimmer matches, get the karaoke listing
*/
vm.pageNo = 0
noDataStack.isHidden = true
vm.startShimmer()
vm.getKaraokeListing()
}
}
// MARK: - CollectionView Delegate and Data Source
@@ -154,10 +166,17 @@ extension KaraokeListingVC : CollectionViewSRC{
}
/*
Updated the top header data
MAke logic for ads
*/
vm.headerData = data
vm.setHeaderData()
if let adsData = AuthFunc.shareInstance.adsData, adsData.result?.filter({$0.forPage == AdsEnum.karaoke.rawValue}).first != nil{
// check if ads data contains ad for webseries
}else{
/*
Updated the top header data
*/
vm.headerData = data
vm.setHeaderData()
}
let sb = UIStoryboard(name: K.StoryBoard.Karaoke, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Karaoke.karaokeDetailsVC) as! KaraokeDetailsVC
@@ -208,9 +227,9 @@ extension KaraokeListingVC : TableViewSRC{
if vm.karaokeListData.count == 0{
cell.showShimmer()
}else{
cell.stopShimmer()
let data = vm.karaokeListData[indexPath.row]
cell.setKaraokeData(data: data)
cell.stopShimmer()
}
cell.btnTapped = { [weak self] (type) -> Void in
@@ -235,11 +254,19 @@ extension KaraokeListingVC : TableViewSRC{
if let id = data.id{
PersistentStorage.shared.addKaraokeCount(postID: id)
}
/*
Updated the top header data
MAke logic for ads
*/
vm.headerData = data
vm.setHeaderData()
if let adsData = AuthFunc.shareInstance.adsData, adsData.result?.filter({$0.forPage == AdsEnum.karaoke.rawValue}).first != nil{
// check if ads data contains ad for webseries
}else{
/*
Updated the top header data
*/
vm.headerData = data
vm.setHeaderData()
}
let sb = UIStoryboard(name: K.StoryBoard.Karaoke, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Karaoke.karaokeDetailsVC) as! KaraokeDetailsVC

View File

@@ -217,6 +217,49 @@
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</stackView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mxw-ad-FKZ">
<rect key="frame" x="0.0" y="48" width="414" height="848"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="c6T-wn-PYG">
<rect key="frame" x="30" y="325" width="354" height="198"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="SupportGirlImage" translatesAutoresizingMaskIntoConstraints="NO" id="SWC-3x-FEt">
<rect key="frame" x="0.0" y="0.0" width="354" height="130"/>
<constraints>
<constraint firstAttribute="height" constant="130" id="Qn2-JH-I0F"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Something went wrong." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0bF-Jg-Rfg" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="135" width="354" height="24"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qcg-Oh-AJv" customClass="LocalisedElementsButton" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="164" width="354" height="34"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="18"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<inset key="titleEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Retry?"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="25"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="retryBtnTapped:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="15A-BY-qMn"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="0.019607843140000001" green="0.0" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="c6T-wn-PYG" firstAttribute="centerY" secondItem="mxw-ad-FKZ" secondAttribute="centerY" id="2Iq-W8-vcC"/>
<constraint firstItem="c6T-wn-PYG" firstAttribute="leading" secondItem="mxw-ad-FKZ" secondAttribute="leading" constant="30" id="NJN-po-vqH"/>
<constraint firstAttribute="trailing" secondItem="c6T-wn-PYG" secondAttribute="trailing" constant="30" id="Xnt-RX-tCI"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
@@ -225,9 +268,13 @@
<constraint firstItem="Bmz-QF-ndz" firstAttribute="top" secondItem="V10-F3-AfA" secondAttribute="bottom" id="8Cn-al-lcF"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="Bmz-QF-ndz" secondAttribute="trailing" id="CSf-km-OSA"/>
<constraint firstItem="V10-F3-AfA" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" id="E9a-Th-8Ln"/>
<constraint firstAttribute="bottom" secondItem="mxw-ad-FKZ" secondAttribute="bottom" id="P0w-iC-J1Z"/>
<constraint firstItem="Bmz-QF-ndz" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="VKC-SK-X0W"/>
<constraint firstItem="mxw-ad-FKZ" firstAttribute="leading" secondItem="5EZ-qb-Rvc" secondAttribute="leading" id="ab7-Ol-cqt"/>
<constraint firstAttribute="bottom" secondItem="Bmz-QF-ndz" secondAttribute="bottom" id="dHE-iN-hq9"/>
<constraint firstItem="V10-F3-AfA" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="dS9-NE-Ap0"/>
<constraint firstAttribute="trailing" secondItem="mxw-ad-FKZ" secondAttribute="trailing" id="v9l-7x-bNO"/>
<constraint firstItem="mxw-ad-FKZ" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="wzu-wH-Yuz"/>
</constraints>
</view>
<connections>
@@ -242,6 +289,7 @@
<outlet property="karaokeListingTableView" destination="haV-Gw-hD2" id="1En-mN-yVg"/>
<outlet property="loadMoreActivityIndicator" destination="OhD-ec-2sW" id="yfU-R6-UbS"/>
<outlet property="loadMoreBtn" destination="ims-Sc-C3R" id="WEX-0M-lBp"/>
<outlet property="noDataStack" destination="mxw-ad-FKZ" id="HNo-RJ-uiw"/>
<outlet property="scrollView" destination="5mW-wO-b1Z" id="vX8-Dp-fHu"/>
<outlet property="selectedShowView" destination="JKB-7I-uN7" id="1hm-Jj-hg2"/>
<outlet property="tableHeight" destination="X5Z-qL-DJr" id="4j9-E7-nL6"/>
@@ -752,6 +800,7 @@
<image name="PlayButtonSmall" width="28.333333969116211" height="28.333333969116211"/>
<image name="Reload" width="42.5" height="42.5"/>
<image name="ShareImage" width="18" height="18"/>
<image name="SupportGirlImage" width="166" height="166"/>
<image name="WebSeriesSeasonsBackground" width="142.66667175292969" height="187.33332824707031"/>
<image name="hand.thumbsup.fill" catalog="system" width="128" height="121"/>
<image name="icloud.and.arrow.down.fill" catalog="system" width="128" height="111"/>

View File

@@ -27,7 +27,7 @@ class KaraokeListingVM{
vc.title = "KARAOKE".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
vc.view.applyGradient(colors: [color2, color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0))
startShimmer()
getContinueWatching()
getKaraokeListing()
//Set banner height
@@ -108,7 +108,7 @@ class KaraokeListingVM{
}
Utilities.dismissProgressHUD()
self.vc.continueWatchingStack.isHidden = true
vc.toast(msg: error.localizedDescription , time: 2)
vc.toast(msg: error.localizedDescription , time: K.ConstantString.errorTime)
}
}
}
@@ -122,7 +122,6 @@ class KaraokeListingVM{
switch result{
case .success(let data):
guard let self else{
Utilities.dismissProgressHUD()
return
}
switch data.success{
@@ -130,13 +129,12 @@ class KaraokeListingVM{
/*
Error
*/
Utilities.dismissProgressHUD()
self.vc.loadMoreBtn.isHidden = true
self.vc.loadMoreActivityIndicator.stopAnimating()
self.vc.loadMoreActivityIndicator.hidesWhenStopped = true
// vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
case 1:
Utilities.dismissProgressHUD()
getContinueWatching()
guard let dataCount = data.data?.totalRecords, let data = data.data?.karaokeData else{return}
self.karaokeListData.append(contentsOf: data)
self.vc.karaokeListingTableView.reloadData()
@@ -184,11 +182,11 @@ class KaraokeListingVM{
}
case .failure(let error):
guard let self else{
Utilities.dismissProgressHUD()
return
}
Utilities.dismissProgressHUD()
self.stopShimmer()
vc.toast(msg: error.localizedDescription , time: 2)
vc.noDataStack.isHidden = false
}
}
}

View File

@@ -87,6 +87,7 @@ class NetworkManager{
vcPush.contentLabel = "Please Login Again"
vcPush.mainTitleText = "Session Expired."
vcPush.yesBtnText = "Login"
vcPush.outsideViewTapGestureEnabled = false
vcPush.onDoneBlock = { isDone in
AuthFunc.shareInstance.logout()
UIApplication.setRootView(LoginNavVC.instantiate(from: .AuthenticationSB))

View File

@@ -169,10 +169,10 @@ extension WebSeriesVC : TableViewSRC{
if vm.showData.count == 0{
cell.showShimmer()
}else{
cell.stopShimmer()
let data = vm.showData[indexPath.row]
let categoryID = vm.categoryListingData[vm.dropDownModule.indexForSelectedRow ?? 0].id ?? 0
cell.setData(data: data,selectedCategory: categoryID)
cell.stopShimmer()
}
cell.btnTapped = { [self] (type) -> Void in

View File

@@ -250,7 +250,7 @@ class WebSeriesVM{
return
}
Utilities.dismissProgressHUD()
vc.toast(msg: error.localizedDescription , time: 2)
vc.toast(msg: error.localizedDescription , time: K.ConstantString.errorTime)
}
}
}