Files
Woka_Native_iOS/WOKA/SideBarNav/Controller/MyOrdersVC.swift
BilalKhanWDI d17fe416ae - My list Audio books on add remove fav, only calling audiobooks api and reloading in background
- My list Games on add remove fav, only calling Games api and reloading in background
- My list Karaoke on add remove fav, only calling Karaoke api and reloading in background
-Finalised clicks count for every module
2024-08-12 19:58:58 +05:30

80 lines
2.8 KiB
Swift

//
// MyOrdersVC.swift
// WOKA
//
// Created by MacBook Pro on 10/06/24.
//
import UIKit
class MyOrdersVC: UIViewController {
var vm = MyOrdersVM()
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
vm.vc = self
vm.initView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setColor(color: .black)
navigationController?.setNavigationBarHidden(false, animated: animated)
// Update the badge label with the current cart data
if let button = vm.cartButton.customView as? UIButton {
BadgeBarBtn.shared.updateBadge(for: button, with: CartDataCache.cartListData.count.toString())
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
if self.isMovingFromParent {
// Back button was pressed
PersistentStorage.shared.addOthersCount()
}
}
override func viewDidDisappear(_ animated: Bool) {
self.navigationController?.setColor(color: .black)
}
}
// MARK: - TableView DataSource , Delegates
extension MyOrdersVC : TableViewSRC{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return vm.orderData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.SideBarNav.myOrderCell) as! MyOrderCell
let data = vm.orderData[indexPath.row]
cell.setData(data: data)
cell.btnTapped = { [weak self] in
guard let self else{return}
PersistentStorage.shared.addShopCount(postID: 0)
let sb = UIStoryboard(name: K.StoryBoard.sideBarNav, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.SideBarNav.myOrderDetailsVC) as! MyOrderDetailsVC
let orderID = vm.orderData[indexPath.row].orderID
vcPush.orderID = orderID
self.navigationController?.present(vcPush, animated: true)
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// let sb = UIStoryboard(name: K.StoryBoard.sideBarNav, bundle: nil)
// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.SideBarNav.myOrderDetailsVC) as! MyOrderDetailsVC
// let orderID = vm.orderData[indexPath.row].orderID
// vcPush.orderID = orderID
// self.navigationController?.present(vcPush, animated: true)
}
}