- Added the tint view dismiss, also fixed the issue of dismiss when not clicked on tint view - Now sending the live tv url as media content
180 lines
7.4 KiB
Swift
180 lines
7.4 KiB
Swift
//
|
|
// GamesDetailVC.swift
|
|
// WOKA
|
|
//
|
|
// Created by MacBook Pro on 04/07/24.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class GamesDetailVC: UIViewController {
|
|
|
|
@IBOutlet weak var watchingImage: UIImageView!
|
|
@IBOutlet weak var watchingTitle: UILabel!
|
|
@IBOutlet weak var watchingDesc: UITextView!
|
|
|
|
@IBOutlet weak var addIcon: UIImageView!
|
|
@IBOutlet weak var addLabel: UILabel!
|
|
@IBOutlet weak var likeIcon: UIImageView!
|
|
@IBOutlet weak var likeLabel: UILabel!
|
|
@IBOutlet weak var totalLikes: UILabel!
|
|
|
|
@IBOutlet weak var addView: UIView!
|
|
@IBOutlet weak var shareView: UIView!
|
|
@IBOutlet weak var likeView: UIView!
|
|
|
|
@IBOutlet weak var outerView: UIView!
|
|
@IBOutlet weak var contentView: UIView!
|
|
|
|
var gameData : GamesListDM.GameDatum?
|
|
var delegate : ReloadSeriesFavLike?
|
|
var gameIndex = 0
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
initView()
|
|
tapHandler()
|
|
|
|
}
|
|
|
|
@objc func handleTap(_ gesture: UITapGestureRecognizer) {
|
|
let location = gesture.location(in: outerView)
|
|
if !contentView.frame.contains(location) {
|
|
self.dismiss(animated: true)
|
|
}
|
|
}
|
|
|
|
func initView(){
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
|
|
outerView.addGestureRecognizer(tapGesture)
|
|
|
|
if let gameData{
|
|
if let url = gameData.thumbnailPath{
|
|
watchingImage.imageURL(url, color: .white)
|
|
}
|
|
|
|
totalLikes.text = gameData.likesCount?.toString() ?? "0"
|
|
if let like = gameData.isLiked{
|
|
switch like{
|
|
case true:
|
|
likeIcon.image = UIImage(systemName: "hand.thumbsup.fill")
|
|
likeLabel.text = "LIKED".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
|
case false:
|
|
likeIcon.image = UIImage(systemName: "hand.thumbsup")
|
|
likeLabel.text = "LIKE".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
|
}
|
|
}
|
|
|
|
if let favourite = gameData.markAsFavourite{
|
|
if favourite == true{
|
|
addIcon.image = UIImage(systemName: "heart.fill")
|
|
addLabel.text = "ADDED".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
|
}else{
|
|
addIcon.image = UIImage(systemName: "heart")
|
|
addLabel.text = "ADD".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
|
}
|
|
}
|
|
|
|
if AuthFunc.shareInstance.getDefaultLanguage() == .english{
|
|
if let englishData = gameData.contentMoreDetails?.filter({$0.languageMasterID == 1}).first{
|
|
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{
|
|
if let hindiData = gameData.contentMoreDetails?.filter({$0.languageMasterID == 2}).first{
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func tapHandler(){
|
|
|
|
self.view.addTapGesture {
|
|
self.dismiss(animated: true)
|
|
}
|
|
|
|
addView.addTapGesture { [weak self] in
|
|
guard let self else{return}
|
|
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
|
|
|
if let gameData{
|
|
guard let showID = gameData.id, let isFav = gameData.markAsFavourite, let postType = gameData.contentMoreDetails?.first?.postType else{return}
|
|
|
|
if isFav {
|
|
LikeFavCommonFunc.shareInstance.removeFavourite(postID: showID, postType: postType, categoryID: 0, vc: self) { isDone in
|
|
self.gameData?.markAsFavourite = false
|
|
K.GVar.reloadMyList = true
|
|
self.delegate?.updateRows(index: self.gameIndex, type: .favourite, isFav: false, isLike: nil)
|
|
self.initView()
|
|
}
|
|
}else{
|
|
LikeFavCommonFunc.shareInstance.addFavourite(postID: showID, postType: postType, categoryID: 0, vc: self) { isDone in
|
|
self.gameData?.markAsFavourite = true
|
|
K.GVar.reloadMyList = true
|
|
self.delegate?.updateRows(index: self.gameIndex, type: .favourite, isFav: true, isLike: nil)
|
|
self.initView()
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
likeView.addTapGesture { [weak self] in
|
|
guard let self else{return}
|
|
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
|
|
|
if let gameData{
|
|
guard let showID = gameData.id, let isLiked = gameData.isLiked, let postType = gameData.contentMoreDetails?.first?.postType else{return}
|
|
|
|
if isLiked{
|
|
LikeFavCommonFunc.shareInstance.unlikePost(postID: showID, postType: postType, vc: self) { isDone in
|
|
self.gameData?.isLiked = false
|
|
K.GVar.reloadMyList = true
|
|
self.delegate?.updateRows(index: self.gameIndex, type: .liked, isFav: nil, isLike: false)
|
|
self.initView()
|
|
}
|
|
}else{
|
|
LikeFavCommonFunc.shareInstance.likePost(postID: showID, postType: postType, vc: self) { isDone in
|
|
self.gameData?.isLiked = true
|
|
K.GVar.reloadMyList = true
|
|
self.delegate?.updateRows(index: self.gameIndex, type: .liked, isFav: nil, isLike: true)
|
|
self.initView()
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
shareView.addTapGesture {
|
|
print("share")
|
|
}
|
|
}
|
|
|
|
@IBAction func playNowBtnTapped(_ sender: LocalisedElementsButton) {
|
|
let sb = UIStoryboard(name: K.StoryBoard.Games, bundle: nil)
|
|
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Games.gamesWebViewVC) as! GamesWebViewVC
|
|
//https://wokastaging.in/wokagames/Games/html/WokaLudo/index.php
|
|
vcPush.url = self.gameData?.gameURL
|
|
vcPush.orientation = self.gameData?.screenOrientation
|
|
vcPush.modalTransitionStyle = .crossDissolve
|
|
vcPush.modalPresentationStyle = .fullScreen
|
|
self.present(vcPush, animated: true)
|
|
}
|
|
|
|
@IBAction func closeBtnTapped(_ sender: UIButton) {
|
|
self.dismiss(animated: true) {
|
|
|
|
}
|
|
}
|
|
}
|