152 lines
5.9 KiB
Swift
152 lines
5.9 KiB
Swift
//
|
|
// ThemeTwoVC.swift
|
|
// WOKA
|
|
//
|
|
// Created by Bilal on 24/05/2024.
|
|
//
|
|
|
|
import UIKit
|
|
import AVFAudio
|
|
|
|
class ThemeTwoVC: UIViewController {
|
|
|
|
weak var delegate: ChildViewControllerDelegate?
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
|
@IBOutlet weak var liveTvView: UIView!
|
|
@IBOutlet weak var nameLabel: UILabel!
|
|
@IBOutlet weak var avatarImage: UIImageView!
|
|
@IBOutlet weak var notificationBtn: UIButton!
|
|
|
|
var vm = ThemeTwoVM()
|
|
|
|
deinit{
|
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeTwoPush), object: nil)
|
|
}
|
|
|
|
override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
.lightContent
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
vm.vc = self
|
|
vm.initView()
|
|
|
|
if MyListDataTemp.shareInstance.favListingData?.showData == nil {
|
|
MyListDataTemp.shareInstance.favListingData = FavouriteListingDM.ResultData(totalRecords: nil, showData: FavouriteListingDM.ResultData.ShowData(hindi: [],english: []),videoData: [],gameData: [],singKaraokeData: [],audioData: [])
|
|
}
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
setNeedsStatusBarAppearanceUpdate()
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
K.GVar.topView = .theme2
|
|
if let player = vm.avPlayer{
|
|
player.play()
|
|
}
|
|
}
|
|
|
|
override func viewDidLayoutSubviews() {
|
|
super.viewDidLayoutSubviews()
|
|
vm.setData()
|
|
vm.playerLayer.frame = liveTvView.bounds
|
|
}
|
|
|
|
@IBAction func sideBarBtnTapped(_ sender: UIButton) {
|
|
self.sideMenuController?.revealMenu()
|
|
}
|
|
|
|
@IBAction func notificationBtnTapped(_ sender: UIButton) {
|
|
// CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in
|
|
// if isDone{
|
|
// let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
|
|
// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC
|
|
// self.navigationController?.pushViewController(vcPush, animated: true)
|
|
// }
|
|
// }
|
|
let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
|
|
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC
|
|
self.navigationController?.pushViewController(vcPush, animated: true)
|
|
}
|
|
|
|
@IBAction func playTrailer(_ sender: LocalisedElementsButton) {
|
|
PersistentStorage.shared.addOthersCount()
|
|
let item = JwPlayerItemCreate(url: APIEndPoints.StaticURLs.masilaUrl, poster: nil, titles: "Masila")
|
|
JWPlayerManager.shared.presentPlayer(from: self, playerItems: [item], contentType: .trailer, videoIDs: [0])
|
|
}
|
|
}
|
|
|
|
// MARK: - CollectionView DataSource Delegate
|
|
|
|
extension ThemeTwoVC : CollectionViewSRC{
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
vm.cellData.count
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: K.CellIdentifier.Theme.homeExploreCell, for: indexPath) as! HomeExploreCell
|
|
cell.setData(data : vm.cellData[indexPath.row])
|
|
return cell
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
switch indexPath.row{
|
|
case 0:
|
|
PersistentStorage.shared.addRadioCount()
|
|
vm.checkType(action: .radio)
|
|
case 1:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .liveTV)
|
|
case 2:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .webseries)
|
|
case 3:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .games)
|
|
case 4:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .audioBooks)
|
|
case 5:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .karaoke)
|
|
case 6:
|
|
PersistentStorage.shared.addOthersCount()
|
|
vm.checkType(action: .shop)
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Collection Flow Layout
|
|
|
|
extension ThemeTwoVC : UICollectionViewDelegateFlowLayout{
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
|
return 5
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
|
return 5
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
|
|
return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
let itemsPerRow: CGFloat = 3
|
|
let paddingSpace = 5 * (itemsPerRow + 1)
|
|
let availableWidth = collectionView.frame.width - paddingSpace
|
|
let widthPerItem = availableWidth / itemsPerRow
|
|
return CGSize(width: widthPerItem, height: widthPerItem + (widthPerItem / 6))
|
|
}
|
|
|
|
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
|
|
// return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
|
// }
|
|
}
|