2024-05-24 19:26:54 +05:30
|
|
|
//
|
|
|
|
|
// ThemeTwoVC.swift
|
|
|
|
|
// WOKA
|
|
|
|
|
//
|
|
|
|
|
// Created by Bilal on 24/05/2024.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
class ThemeTwoVC: UIViewController {
|
|
|
|
|
|
|
|
|
|
weak var delegate: ChildViewControllerDelegate?
|
|
|
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
|
|
|
|
@IBOutlet weak var liveTvView: UIView!
|
2024-05-29 19:40:46 +05:30
|
|
|
@IBOutlet weak var nameLabel: UILabel!
|
|
|
|
|
@IBOutlet weak var avatarImage: UIImageView!
|
2024-05-24 19:26:54 +05:30
|
|
|
|
2024-05-27 19:42:56 +05:30
|
|
|
var vm = ThemeTwoVM()
|
|
|
|
|
|
|
|
|
|
deinit{
|
|
|
|
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-24 19:26:54 +05:30
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
2024-05-27 19:42:56 +05:30
|
|
|
vm.vc = self
|
|
|
|
|
vm.initView()
|
2024-05-24 19:26:54 +05:30
|
|
|
liveTvView.addTapGesture { [weak self] in
|
|
|
|
|
guard let self else{return}
|
|
|
|
|
delegate?.didPressSwitchButton(from: self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@IBAction func sideBarBtnTapped(_ sender: UIButton) {
|
|
|
|
|
self.sideMenuController?.revealMenu()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 19:42:56 +05:30
|
|
|
// 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
|
2024-05-29 19:40:46 +05:30
|
|
|
cell.setData(data : vm.cellData[indexPath.row])
|
2024-05-27 19:42:56 +05:30
|
|
|
return cell
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
|
|
print(indexPath.row)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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)
|
2024-05-24 19:26:54 +05:30
|
|
|
// }
|
2024-05-27 19:42:56 +05:30
|
|
|
}
|