Files
Woka_Native_iOS/WOKA/SideBarNav/Controller/MyOrdersVC.swift
2024-08-08 18:47:13 +05:30

66 lines
2.1 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)
}
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)
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)
}
}