Files
Woka_Native_iOS/WOKA/SideBarNav/ViewModel/MyOrdersVM.swift
BilalKhanWDI 4c69628a94 - Updated get user data response for avatar image
- updated cart icon in whole shop module , myoders
- Finalsied the payment gateway response
2024-07-31 19:42:51 +05:30

41 lines
1.3 KiB
Swift

//
// MyOrdersVM.swift
// WOKA
//
// Created by MacBook Pro on 30/07/24.
//
import UIKit
class MyOrdersVM{
weak var vc : MyOrdersVC!
var cartButton: UIBarButtonItem!
func initView(){
vc.title = "MY ORDERS".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
cartButton = BadgeBarBtn.shared.setupCartButton(target: self, action: #selector(self.cartButtonTapped))
self.vc.navigationItem.rightBarButtonItem = cartButton
//check if cart is not fetched
if !CartDataCache.isFetched{
CartDataCache.shareInstance.getCartList(vc: self.vc) { [weak self] isDone in
guard let self else{return}
if isDone{
if let button = cartButton.customView as? UIButton {
BadgeBarBtn.shared.updateBadge(for: button, with: CartDataCache.cartListData.count.toString())
}
}
}
}
}
@objc func cartButtonTapped(){
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
self.vc.navigationController?.pushViewController(vcPush, animated: true)
}
}