- Updated get user data response for avatar image

- updated cart icon in whole shop module , myoders
- Finalsied the payment gateway response
This commit is contained in:
2024-07-31 19:42:51 +05:30
parent 0456c5f30d
commit 4c69628a94
24 changed files with 446 additions and 351 deletions

View File

@@ -20,6 +20,8 @@ class PaymentWebViewVC: UIViewController {
let request = URLRequest(url: link)
webView.load(request)
}
//Observer to check the url changes
webView.addObserver(self, forKeyPath: "URL", options: .new, context: nil)
}

View File

@@ -18,6 +18,7 @@ struct UserDataDM: Codable {
// let gender: Gender?
let birthdate, email: String?
let avtar: String?
let avtarURL : String?
var userType: String?
let languageMasterID: Int?
let lastLogin, rememberToken: String?
@@ -27,6 +28,7 @@ struct UserDataDM: Codable {
let isDeactive : Bool?
enum CodingKeys: String, CodingKey {
case id, username, fullname, birthdate, email, avtar
case avtarURL = "avtar_url"
// case gender
case userType = "user_type"
case languageMasterID = "language_master_id"

View File

@@ -194,7 +194,7 @@ class LoginVM{
Utilities.dismissProgressHUD()
guard let dataUser = data.data else{return}
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) {
let userDataConverted = UserDataDM.ResultData(id: nil, username: dataUser.username, fullname: dataUser.fullname, birthdate: nil, email: nil, avtar: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
let userDataConverted = UserDataDM.ResultData(id: nil, username: dataUser.username, fullname: dataUser.fullname, birthdate: nil, email: nil, avtar: nil, avtarURL: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
AuthFunc.shareInstance.loginDefaults(data: userDataConverted)
}
default:

View File

@@ -12,15 +12,11 @@ class CartDataCache{
static var cartListData = [CartListingDM.ResultData](){
didSet{
if cartListData.count == 0{
cartBadgeLabel.text = "0"
cartBadgeLabel.isHidden = true
}else{
cartBadgeLabel.text = cartListData.count.toString()
cartBadgeLabel.isHidden = false
}
}
}
static var isFetched = false
// static var cartCount = 0 {
// didSet{
@@ -33,11 +29,12 @@ class CartDataCache{
// }
// }
// }
static var addressData = [AddressListDM]()
static let cartBadgeLabel = UILabel()
static let shareInstance = CartDataCache()
func getCartList(vc : UIViewController){
func getCartList(vc : UIViewController, onCompletion : @escaping (Bool) -> Void){
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Cart.cart_listing, method: .get,headers: headers, queue : QueueHelper.background) { (result : Result<BaseResponseModel<CartListingDM>, NetworkManager.APIError>) in
@@ -49,68 +46,77 @@ class CartDataCache{
Error
*/
Utilities.dismissProgressHUD()
onCompletion(false)
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data?.result else{return}
CartDataCache.cartListData = data
CartDataCache.isFetched = true
CartDataCache.cartBadgeLabel.text = data.count.toString()
onCompletion(true)
default:
Utilities.dismissProgressHUD()
onCompletion(false)
break
}
case .failure(let error):
Utilities.dismissProgressHUD()
Utilities.alert(title: "Error", message: error.localizedDescription, viewController: vc)
onCompletion(false)
}
}
}
}
class BadgeBarBtn{
class BadgeBarBtn {
static let shared = BadgeBarBtn()
private init() {} // Prevents others from using the default '()' initializer
public var tapAction: (() -> Void)?
func setupBadge(for button: UIButton, with text: String) {
let badgeLabel = CartDataCache.cartBadgeLabel
var badgeLabel = CartDataCache.cartBadgeLabel
if let existingLabel = button.viewWithTag(999) as? UILabel {
badgeLabel = existingLabel
} else {
badgeLabel = UILabel()
badgeLabel.tag = 999
button.addSubview(badgeLabel)
}
badgeLabel.frame = CGRect(x: 30, y: 0, width: 18, height: 18)
badgeLabel.backgroundColor = UIColor.red
badgeLabel.isHidden = false // Ensure it is not hidden
// badgeLabel.isHidden = false // Ensure it is not hidden
badgeLabel.clipsToBounds = true
badgeLabel.layer.cornerRadius = 9
badgeLabel.textColor = UIColor.white
badgeLabel.font = FontCustom.shareInstance.customFont(fontName: .Exo2_Regular, size: 10)
badgeLabel.textAlignment = .center
badgeLabel.text = text
// Add the badge label to the button if not already added
if badgeLabel.superview != button {
button.addSubview(badgeLabel)
}
// Ensure the badge label is brought to the front
button.bringSubviewToFront(badgeLabel)
}
func setupCartButton() -> UIBarButtonItem {
func setupCartButton(target: Any?, action: Selector) -> UIBarButtonItem {
let filterBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 45, height: 45))
filterBtn.setImage(UIImage(named: "CartIcon"), for: .normal)
filterBtn.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
filterBtn.addTarget(target, action: action, for: .touchUpInside)
// Configure the badge label
setupBadge(for: filterBtn, with: CartDataCache.cartListData.count.toString())
return UIBarButtonItem(customView: filterBtn)
}
@objc private func buttonPressed() {
if let action = tapAction {
action()
func updateBadge(for button: UIButton, with text: String) {
if let badgeLabel = button.viewWithTag(999) as? UILabel {
badgeLabel.text = text
badgeLabel.isHidden = text.isEmpty
}
}
}

View File

@@ -134,7 +134,7 @@ class OnBoardVM{
guard let dataUser = data.data else{return}
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) {
let userDataConverted = UserDataDM.ResultData(id: nil, username: dataUser.username, fullname: dataUser.fullname, birthdate: nil, email: nil, avtar: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
let userDataConverted = UserDataDM.ResultData(id: nil, username: dataUser.username, fullname: dataUser.fullname, birthdate: nil, email: nil, avtar: nil, avtarURL: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
AuthFunc.shareInstance.loginDefaults(data: userDataConverted)
}
default:

View File

@@ -114,6 +114,7 @@ struct APIEndPoints {
static let sub_category_listing = makeURL(path: "sub_category_listing")
static let shop_product_listing = makeURL(path: "shop_product_listing")
static let shop_product_listing_v2 = makeURL(path: "v2/shop_product_listing")
static let shop_product_view = makeURL(path: "shop_product_view")
}
struct Cart{

View File

@@ -50,7 +50,7 @@ class NetworkManager{
let loginCred = getLoginIDPass()
// Execute the request on the specified queue
queue.async {
AF.request(url, method: method, parameters: parameters, encoding: encoding, headers: headers, requestModifier: { $0.timeoutInterval = 30 })
AF.request(url, method: method, parameters: parameters, encoding: encoding, headers: headers, requestModifier: { $0.timeoutInterval = 20 })
.authenticate(username: loginCred.0, password: loginCred.1)
.validate(statusCode: 200..<300)
.responseDecodable(of: T.self) { response in

View File

@@ -65,7 +65,7 @@ class SplashVM{
func getUserData(){
if AuthFunc.shareInstance.getUserType() == 3{
//setusertype
AuthFunc.shareInstance.userData = UserDataDM.ResultData(id: nil, birthdate: nil, email: nil, avtar: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
AuthFunc.shareInstance.userData = UserDataDM.ResultData(id: nil, birthdate: nil, email: nil, avtar: nil, avtarURL: nil, userType: "3", languageMasterID: nil, lastLogin: nil, rememberToken: nil, childDetail: nil, language: nil, alreadyLoggedIn: nil, isDeactive: nil)
UIApplication.setRootView(SideMenuController.instantiate(from: .Home))
return
}

View File

@@ -18,6 +18,9 @@ class ProductDetailsVC: UIViewController {
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var productImageCV: UICollectionView!
@IBOutlet weak var shadowView: UIView!
@IBOutlet weak var noDataStack: UIStackView!
@IBOutlet weak var retryBtn: UIButton!
@IBOutlet weak var scrollView: UIScrollView!
var vm = ProductDetailsVM()
@@ -32,6 +35,11 @@ class ProductDetailsVC: UIViewController {
override func viewWillAppear(_ animated: Bool) {
self.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 viewDidAppear(_ animated: Bool) {
@@ -60,10 +68,18 @@ class ProductDetailsVC: UIViewController {
vm.addToCart(shopMasterID: shopMasterID)
}
}else{
print("View")
if let shopMasterID = vm.productDetails?.id{
vm.removeItemFromCart(shopMasterID: shopMasterID)
}
}
}
@IBAction func retryBtnTapped(_ sender: UIButton) {
if let productID = vm.productID{
vm.getProductDetails(productID: productID)
}
}
}
// MARK: - Collection delegate and datasource

View File

@@ -19,50 +19,15 @@ class ShopCategoryVC: UIViewController {
vm.initView()
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
// // Create the button
// let backbutton = UIButton(type: .custom)
// backbutton.setImage(UIImage(named: "CartIcon"), for: .normal) // Image can be downloaded from the provided link
// backbutton.setTitleColor(.black, for: .normal) // You can change the TitleColor
// backbutton.addTarget(self, action: #selector(cartBtnTapped), for: .touchUpInside)
//
// // Set button height and width
// let buttonHeight: CGFloat = 50
// let buttonWidth: CGFloat = 50
// backbutton.translatesAutoresizingMaskIntoConstraints = false
// backbutton.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true
// backbutton.heightAnchor.constraint(equalToConstant: buttonHeight).isActive = true
//
// // Create a container view for the button
// let containerView = UIView(frame: CGRect(x: 0, y: 0, width: buttonWidth, height: buttonHeight))
// containerView.addSubview(backbutton)
//
// // Set constraints for the button inside the container view
// NSLayoutConstraint.activate([
// backbutton.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
// backbutton.centerXAnchor.constraint(equalTo: containerView.centerXAnchor)
// ])
//
// // Create a UIBarButtonItem with the custom view
// let customBarButton = UIBarButtonItem(customView: containerView)
//
// // Create a flexible space item to push the custom view to the left
// let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
// flexibleSpace.width = 10
// // Create a negative spacer to fine-tune the position
// let negativeSpacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
// negativeSpacer.width = 10 // Adjust this value to move the button to the left
//
// // Add the custom bar button and the spacer to the navigation bar
// self.navigationItem.rightBarButtonItems = [flexibleSpace,negativeSpacer, customBarButton]
}
@objc func cartBtnTapped(){
print("cart tapped")
}
override func viewWillAppear(_ animated: Bool) {
self.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 viewDidAppear(_ animated: Bool) {

View File

@@ -20,73 +20,17 @@ class ShopListingVC: UIViewController {
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
// // Create the button
// let backbutton = UIButton(type: .custom)
// backbutton.setImage(UIImage(named: "CartIcon"), for: .normal) // Image can be downloaded from the provided link
// backbutton.setTitleColor(.black, for: .normal) // You can change the TitleColor
// backbutton.addTarget(self, action: #selector(vm.cartBtnTapped), for: .touchUpInside)
//
// // Set button height and width
// let buttonHeight: CGFloat = 50
// let buttonWidth: CGFloat = 50
// backbutton.translatesAutoresizingMaskIntoConstraints = false
// backbutton.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true
// backbutton.heightAnchor.constraint(equalToConstant: buttonHeight).isActive = true
//
// // Create the badge label
// CartDataCache.cartBadgeLabel.text = CartDataCache.cartCount.toString() // Set your badge number here
// CartDataCache.cartBadgeLabel.textColor = .white
// CartDataCache.cartBadgeLabel.backgroundColor = .red
// CartDataCache.cartBadgeLabel.font = UIFont.systemFont(ofSize: 12)
// CartDataCache.cartBadgeLabel.textAlignment = .center
// CartDataCache.cartBadgeLabel.layer.cornerRadius = 10
// CartDataCache.cartBadgeLabel.clipsToBounds = true
//
// // Set badge label constraints
// CartDataCache.cartBadgeLabel.translatesAutoresizingMaskIntoConstraints = false
// CartDataCache.cartBadgeLabel.widthAnchor.constraint(equalToConstant: 20).isActive = true
// CartDataCache.cartBadgeLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
//
// // Create a container view for the button
// let containerView = UIView(frame: CGRect(x: 0, y: 0, width: buttonWidth, height: buttonHeight))
// containerView.backgroundColor = .blue
// containerView.addSubview(backbutton)
//
// containerView.addSubview(CartDataCache.cartBadgeLabel)
//
// // Set constraints for the button inside the container view
// NSLayoutConstraint.activate([
// backbutton.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
// backbutton.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
//
// // Position the badge at the top-right corner of the button
// CartDataCache.cartBadgeLabel.topAnchor.constraint(equalTo: backbutton.topAnchor, constant: -3),
// CartDataCache.cartBadgeLabel.rightAnchor.constraint(equalTo: backbutton.rightAnchor, constant: -2)
// ])
//
// // Create a UIBarButtonItem with the custom view
// let customBarButton = UIBarButtonItem(customView: containerView)
//
// // Create a flexible space item to push the custom view to the left
// let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
// flexibleSpace.width = 10
//
// // Create a negative spacer to fine-tune the position
// let negativeSpacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
// negativeSpacer.width = 10 // Adjust this value to move the button to the left
//
// // Add the custom bar button and the spacer to the navigation bar
// self.navigationItem.rightBarButtonItems = [flexibleSpace, negativeSpacer, customBarButton]
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
self.navigationController?.setColor(color: .white)
// 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) {
@@ -134,65 +78,65 @@ extension ShopListingVC : TableViewSRC{
extension UIViewController {
func createCartButton(imageName: String,
badgeNumber: Int,
buttonSize: CGSize = CGSize(width: 50, height: 50),
badgeColor: UIColor = .red,
badgeTextColor: UIColor = .white,
buttonColor: UIColor = .blue,
target: Any,
action: Selector) -> UIBarButtonItem {
// Create the button
let button = UIButton(type: .custom)
button.setImage(UIImage(named: imageName), for: .normal)
button.setTitleColor(.black, for: .normal)
button.addTarget(target, action: action, for: .touchUpInside)
button.isEnabled = true
button.isUserInteractionEnabled = true
// Set button height and width
button.translatesAutoresizingMaskIntoConstraints = false
button.widthAnchor.constraint(equalToConstant: buttonSize.width).isActive = true
button.heightAnchor.constraint(equalToConstant: buttonSize.height).isActive = true
// Create the badge label
// let badgeLabel = UILabel()
CartDataCache.cartBadgeLabel.text = "\(badgeNumber)"
CartDataCache.cartBadgeLabel.textColor = badgeTextColor
CartDataCache.cartBadgeLabel.backgroundColor = badgeColor
CartDataCache.cartBadgeLabel.font = UIFont.systemFont(ofSize: 12)
CartDataCache.cartBadgeLabel.textAlignment = .center
CartDataCache.cartBadgeLabel.layer.cornerRadius = 10
CartDataCache.cartBadgeLabel.clipsToBounds = true
badgeNumber == 0 ? (CartDataCache.cartBadgeLabel.isHidden = true) : (CartDataCache.cartBadgeLabel.isHidden = false)
// Set badge label constraints
CartDataCache.cartBadgeLabel.translatesAutoresizingMaskIntoConstraints = false
CartDataCache.cartBadgeLabel.widthAnchor.constraint(equalToConstant: 20).isActive = true
CartDataCache.cartBadgeLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
// Create a container view for the button
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: buttonSize.width, height: buttonSize.height))
containerView.backgroundColor = buttonColor
containerView.addSubview(button)
containerView.addSubview(CartDataCache.cartBadgeLabel)
containerView.isUserInteractionEnabled = true
// Set constraints for the button inside the container view
NSLayoutConstraint.activate([
button.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
button.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
// Position the badge at the top-right corner of the button
CartDataCache.cartBadgeLabel.topAnchor.constraint(equalTo: button.topAnchor, constant: -3),
CartDataCache.cartBadgeLabel.rightAnchor.constraint(equalTo: button.rightAnchor, constant: -2)
])
// Create a UIBarButtonItem with the custom view
let customBarButton = UIBarButtonItem(customView: containerView)
// Return the custom bar button
return customBarButton
}
}
//extension UIViewController {
//
// func createCartButton(imageName: String,
// badgeNumber: Int,
// buttonSize: CGSize = CGSize(width: 50, height: 50),
// badgeColor: UIColor = .red,
// badgeTextColor: UIColor = .white,
// buttonColor: UIColor = .blue,
// target: Any,
// action: Selector) -> UIBarButtonItem {
//
// // Create the button
// let button = UIButton(type: .custom)
// button.setImage(UIImage(named: imageName), for: .normal)
// button.setTitleColor(.black, for: .normal)
// button.addTarget(target, action: action, for: .touchUpInside)
// button.isEnabled = true
// button.isUserInteractionEnabled = true
// // Set button height and width
// button.translatesAutoresizingMaskIntoConstraints = false
// button.widthAnchor.constraint(equalToConstant: buttonSize.width).isActive = true
// button.heightAnchor.constraint(equalToConstant: buttonSize.height).isActive = true
//
// // Create the badge label
//// let badgeLabel = UILabel()
// CartDataCache.cartBadgeLabel.text = "\(badgeNumber)"
// CartDataCache.cartBadgeLabel.textColor = badgeTextColor
// CartDataCache.cartBadgeLabel.backgroundColor = badgeColor
// CartDataCache.cartBadgeLabel.font = UIFont.systemFont(ofSize: 12)
// CartDataCache.cartBadgeLabel.textAlignment = .center
// CartDataCache.cartBadgeLabel.layer.cornerRadius = 10
// CartDataCache.cartBadgeLabel.clipsToBounds = true
//
// badgeNumber == 0 ? (CartDataCache.cartBadgeLabel.isHidden = true) : (CartDataCache.cartBadgeLabel.isHidden = false)
// // Set badge label constraints
// CartDataCache.cartBadgeLabel.translatesAutoresizingMaskIntoConstraints = false
// CartDataCache.cartBadgeLabel.widthAnchor.constraint(equalToConstant: 20).isActive = true
// CartDataCache.cartBadgeLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
//
// // Create a container view for the button
// let containerView = UIView(frame: CGRect(x: 0, y: 0, width: buttonSize.width, height: buttonSize.height))
//
// containerView.backgroundColor = buttonColor
// containerView.addSubview(button)
// containerView.addSubview(CartDataCache.cartBadgeLabel)
// containerView.isUserInteractionEnabled = true
// // Set constraints for the button inside the container view
// NSLayoutConstraint.activate([
// button.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
// button.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
//
// // Position the badge at the top-right corner of the button
// CartDataCache.cartBadgeLabel.topAnchor.constraint(equalTo: button.topAnchor, constant: -3),
// CartDataCache.cartBadgeLabel.rightAnchor.constraint(equalTo: button.rightAnchor, constant: -2)
// ])
//
// // Create a UIBarButtonItem with the custom view
// let customBarButton = UIBarButtonItem(customView: containerView)
// // Return the custom bar button
// return customBarButton
// }
//}

View File

@@ -22,49 +22,15 @@ class ShopProductsVC: UIViewController {
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
// Create the button
let backbutton = UIButton(type: .custom)
backbutton.setImage(UIImage(named: "CartIcon"), for: .normal) // Image can be downloaded from the provided link
backbutton.setTitleColor(.black, for: .normal) // You can change the TitleColor
backbutton.addTarget(self, action: #selector(cartBtnTapped), for: .touchUpInside)
// Set button height and width
let buttonHeight: CGFloat = 50
let buttonWidth: CGFloat = 50
backbutton.translatesAutoresizingMaskIntoConstraints = false
backbutton.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true
backbutton.heightAnchor.constraint(equalToConstant: buttonHeight).isActive = true
// Create a container view for the button
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: buttonWidth, height: buttonHeight))
containerView.addSubview(backbutton)
// Set constraints for the button inside the container view
NSLayoutConstraint.activate([
backbutton.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
backbutton.centerXAnchor.constraint(equalTo: containerView.centerXAnchor)
])
// Create a UIBarButtonItem with the custom view
let customBarButton = UIBarButtonItem(customView: containerView)
// Create a flexible space item to push the custom view to the left
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
flexibleSpace.width = 10
// Create a negative spacer to fine-tune the position
let negativeSpacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
negativeSpacer.width = 10 // Adjust this value to move the button to the left
// Add the custom bar button and the spacer to the navigation bar
self.navigationItem.rightBarButtonItems = [flexibleSpace,negativeSpacer, customBarButton]
}
@objc func cartBtnTapped(){
print("cart tapped")
}
override func viewWillAppear(_ animated: Bool) {
self.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 viewDidAppear(_ animated: Bool) {
@@ -128,8 +94,7 @@ extension ShopProductsVC : CollectionViewSRC{
let data = vm.shopProductsData[indexPath.row]
let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.productDetailsVC) as! ProductDetailsVC
vcPush.vm.categoryName = vm.pageTitle ?? "Shop"
vcPush.vm.productDetails = data
vcPush.vm.productID = data.id
self.navigationController?.pushViewController(vcPush, animated: true)
case subCategoryCV:
if let selectedSubCategory = vm.subCategoryData[indexPath.row].id{

View File

@@ -29,11 +29,11 @@ struct ShopProductsListingDM: Codable {
let taxValue: String?
let shopMasterDetail: CartListingDM.ShopMasterDetail?
let shopImage: [String]?
let addedToCart: Bool?
var addedToCart: Bool?
let productFinalPrice : Double?
let category : Category?
enum CodingKeys: String, CodingKey {
case id
case id, category
case skuID = "sku_id"
case productName = "product_name"
case productThumbnail = "product_thumbnail"
@@ -50,6 +50,18 @@ struct ShopProductsListingDM: Codable {
case productFinalPrice = "product_final_price"
}
}
// MARK: - Category
struct Category: Codable {
let id: Int?
let categoryName: String?
enum CodingKeys: String, CodingKey {
case id
case categoryName = "category_name"
}
}
// MARK: - ShopMasterDetail
struct ShopMasterDetail: Codable {
@@ -67,65 +79,64 @@ struct ShopProductsListingDM: Codable {
}
}
/*
// MARK: - AddressListDMElement
struct AddressListDMElement: Codable {
let id: Int?
let skuID, productName: String?
let categoryMasterID, subCategoryMasterID: Int?
let productPrice: String?
let remainStockQuantity: Int?
let stockStatus: String?
let taxCategory: JSONNull?
let taxValue: String?
let shopMasterDetail: ShopMasterDetail?
let shopImage: [String]?
let category: Category?
let addedToCart: Bool?
//struct ShopProductDM: Codable {
// let result: ResultData?
//
// // MARK: - ResultData
// struct ResultData: Codable {
// let sabakDegiNaniSeries: [SabakDegiNaniSery]?
//
// enum CodingKeys: String, CodingKey {
// case sabakDegiNaniSeries = "Sabak Degi Nani Series"
// }
// }
//
// // MARK: - SabakDegiNaniSery
// struct SabakDegiNaniSery: Codable {
// let id: Int?
// let skuID, productName, productThumbnail: String?
// let categoryMasterID, subCategoryMasterID: Int?
// let productPrice: String?
// let remainStockQuantity: Int?
// let stockStatus: String?
//// let taxCategory: JSONNull?
// let taxValue: String?
// let shopMasterDetail: ShopMasterDetail?
// let shopImage: [String]?
// let addedToCart: Bool?
//
// enum CodingKeys: String, CodingKey {
// case id
// case skuID = "sku_id"
// case productName = "product_name"
// case productThumbnail = "product_thumbnail"
// case categoryMasterID = "category_master_id"
// case subCategoryMasterID = "sub_category_master_id"
// case productPrice = "product_price"
// case remainStockQuantity = "remain_stock_quantity"
// case stockStatus = "stock_status"
//// case taxCategory = "tax_category"
// case taxValue = "tax_value"
// case shopMasterDetail = "shop_master_detail"
// case shopImage = "shop_image"
// case addedToCart = "added_to_cart"
// }
// }
//
// // MARK: - ShopMasterDetail
// struct ShopMasterDetail: Codable {
// let id, productID: Int?
// let productNameEnglish, productNameHindi, descriptionEnglish, descriptionHindi: String?
//
// enum CodingKeys: String, CodingKey {
// case id
// case productID = "product_id"
// case productNameEnglish = "product_name_english"
// case productNameHindi = "product_name_hindi"
// case descriptionEnglish = "description_english"
// case descriptionHindi = "description_hindi"
// }
// }
//
//}
//
enum CodingKeys: String, CodingKey {
case id
case skuID = "sku_id"
case productName = "product_name"
case categoryMasterID = "category_master_id"
case subCategoryMasterID = "sub_category_master_id"
case productPrice = "product_price"
case remainStockQuantity = "remain_stock_quantity"
case stockStatus = "stock_status"
case taxCategory = "tax_category"
case taxValue = "tax_value"
case shopMasterDetail = "shop_master_detail"
case shopImage = "shop_image"
case category
case addedToCart = "added_to_cart"
}
}
// MARK: - Category
struct Category: Codable {
let id: Int?
let categoryName: String?
enum CodingKeys: String, CodingKey {
case id
case categoryName = "category_name"
}
}
// MARK: - ShopMasterDetail
struct ShopMasterDetail: Codable {
let id, productID: Int?
let productNameEnglish, productNameHindi, descriptionEnglish, descriptionHindi: String?
enum CodingKeys: String, CodingKey {
case id
case productID = "product_id"
case productNameEnglish = "product_name_english"
case productNameHindi = "product_name_hindi"
case descriptionEnglish = "description_english"
case descriptionHindi = "description_hindi"
}
}
*/

View File

@@ -186,10 +186,35 @@
<rect key="frame" x="0.0" y="59" width="393" height="793"/>
<color key="backgroundColor" red="0.82745098039999998" green="0.93725490199999995" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
</view>
<stackView hidden="YES" opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="PDw-D2-MIm">
<rect key="frame" x="113.66666666666669" y="318" width="166" height="241"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="SupportGirlImage" translatesAutoresizingMaskIntoConstraints="NO" id="fqC-iZ-FnK">
<rect key="frame" x="0.0" y="0.0" width="166" height="166"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No Data Found!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WMd-v5-3Bf" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="0.0" y="176" width="166" height="24"/>
<fontDescription key="fontDescription" name="Exo2-Bold" family="Exo 2" pointSize="20"/>
<color key="textColor" name="TextDarkBlue"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="upB-Eu-Ooo">
<rect key="frame" x="0.0" y="210" width="166" height="31"/>
<color key="tintColor" name="TextDarkBlue"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Retry?">
<fontDescription key="titleFontDescription" name="Exo2-Bold" family="Exo 2" pointSize="14"/>
</buttonConfiguration>
<connections>
<action selector="retryBtnTapped:" destination="50W-Kn-pPe" eventType="touchUpInside" id="qEg-zE-Lwa"/>
</connections>
</button>
</subviews>
</stackView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="OrderBottom" translatesAutoresizingMaskIntoConstraints="NO" id="11o-Wz-oVy">
<rect key="frame" x="0.0" y="557.33333333333337" width="393" height="294.66666666666663"/>
</imageView>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wxy-J9-S7w">
<scrollView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wxy-J9-S7w">
<rect key="frame" x="0.0" y="59" width="393" height="759"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="14" translatesAutoresizingMaskIntoConstraints="NO" id="2Hi-i7-d5A">
@@ -331,6 +356,7 @@
<constraints>
<constraint firstItem="wxy-J9-S7w" firstAttribute="top" secondItem="lMc-y6-eRf" secondAttribute="top" id="0Dw-gY-fwD"/>
<constraint firstItem="Sf0-tQ-I1Z" firstAttribute="top" secondItem="lMc-y6-eRf" secondAttribute="top" id="4eA-Ne-ylA"/>
<constraint firstItem="PDw-D2-MIm" firstAttribute="centerY" secondItem="lMc-y6-eRf" secondAttribute="centerY" id="4rO-nR-njd"/>
<constraint firstItem="11o-Wz-oVy" firstAttribute="leading" secondItem="lMc-y6-eRf" secondAttribute="leading" id="5aK-8E-8eP"/>
<constraint firstAttribute="bottom" secondItem="Sf0-tQ-I1Z" secondAttribute="bottom" id="6SO-op-X8q"/>
<constraint firstItem="Sf0-tQ-I1Z" firstAttribute="leading" secondItem="lMc-y6-eRf" secondAttribute="leading" id="CvR-51-mma"/>
@@ -339,17 +365,21 @@
<constraint firstItem="wxy-J9-S7w" firstAttribute="trailing" secondItem="lMc-y6-eRf" secondAttribute="trailing" id="PHj-gT-GZ1"/>
<constraint firstItem="11o-Wz-oVy" firstAttribute="trailing" secondItem="lMc-y6-eRf" secondAttribute="trailing" id="TWL-yC-bnk"/>
<constraint firstItem="wxy-J9-S7w" firstAttribute="leading" secondItem="lMc-y6-eRf" secondAttribute="leading" id="X4E-Gc-aRw"/>
<constraint firstItem="PDw-D2-MIm" firstAttribute="centerX" secondItem="lMc-y6-eRf" secondAttribute="centerX" id="gM9-yg-ZFf"/>
<constraint firstItem="lMc-y6-eRf" firstAttribute="trailing" secondItem="Sf0-tQ-I1Z" secondAttribute="trailing" id="rNS-vr-yQK"/>
</constraints>
</view>
<connections>
<outlet property="addToCartBtn" destination="ahD-zd-wgq" id="q5Z-e2-ik2"/>
<outlet property="categoryName" destination="pXa-BI-1Vq" id="ZOJ-87-NoN"/>
<outlet property="noDataStack" destination="PDw-D2-MIm" id="E88-iq-agZ"/>
<outlet property="pageControl" destination="S11-hP-BvF" id="TVr-VN-q6m"/>
<outlet property="productDescription" destination="MGf-Sz-m0H" id="xXr-7b-crc"/>
<outlet property="productImageCV" destination="rPD-8U-l3M" id="Q6T-l2-VTB"/>
<outlet property="productPrice" destination="wA2-Vl-eLw" id="DAV-So-gfZ"/>
<outlet property="productTitle" destination="Xon-3Q-PPf" id="txd-Sp-8eO"/>
<outlet property="retryBtn" destination="upB-Eu-Ooo" id="mzC-Ba-zSt"/>
<outlet property="scrollView" destination="wxy-J9-S7w" id="dqi-T2-0Se"/>
<outlet property="shadowView" destination="7cG-sy-354" id="05t-Pe-JYb"/>
<outlet property="skuID" destination="iAp-gN-dq2" id="clh-vQ-jib"/>
</connections>
@@ -361,10 +391,14 @@
</scenes>
<resources>
<image name="OrderBottom" width="570.66668701171875" height="294.66665649414062"/>
<image name="SupportGirlImage" width="166" height="166"/>
<image name="cart.fill" catalog="system" width="128" height="102"/>
<namedColor name="ImageDarkBlue">
<color red="0.035000000149011612" green="0.0" blue="0.36500000953674316" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="TextDarkBlue">
<color red="0.10599999874830246" green="0.050999999046325684" blue="0.60399997234344482" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>

View File

@@ -13,14 +13,33 @@ class ProductDetailsVM{
weak var vc : ProductDetailsVC!
var productDetails : ShopProductsListingDM.ResultData?
var categoryName = "NA"
var productID : Int?
var cartButton: UIBarButtonItem!
func initView(){
addGradient()
setupCell()
cartButton = BadgeBarBtn.shared.setupCartButton(target: self, action: #selector(cartButtonTapped))
self.vc.navigationItem.rightBarButtonItem = cartButton
if let productID {
self.getProductDetails(productID: productID)
}
}
@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)
}
func updateView(){
//set details
if let productDetails{
vc.productImageCV.reloadData()
// 11 - hindi , 12 - english
if productDetails.subCategoryMasterID == 12{
vc.productTitle.text = productDetails.shopMasterDetail?.productNameEnglish
if let desc = productDetails.shopMasterDetail?.descriptionEnglish, let htmlText = desc.replacingOccurrences(of: "<br>", with: "").htmlToAttributedString{
@@ -37,14 +56,14 @@ class ProductDetailsVM{
}
}
vc.categoryName.text = categoryName
vc.categoryName.text = productDetails.category?.categoryName
vc.skuID.text = productDetails.skuID
vc.productPrice.text = productDetails.productPrice
vc.pageControl.numberOfPages = productDetails.shopImage?.count ?? 1
vc.pageControl.currentPage = 0
if let addedToCart = productDetails.addedToCart, addedToCart{
vc.addToCartBtn.setTitle("View Cart", for: .normal)
vc.addToCartBtn.setTitle("Remove", for: .normal)
}else{
vc.addToCartBtn.setTitle("Add to Cart", for: .normal)
}
@@ -85,16 +104,14 @@ class ProductDetailsVM{
Error
*/
Utilities.dismissProgressHUD()
Utilities.alertWithBtnCompletion(title: "Error", msgBody: data.message ?? K.ConstantString.unRecognised, okBtnStr: "Retry?", vc: self.vc) { isDone in
}
Utilities.alert(title: "Error", message: data.message ?? K.ConstantString.unRecognised, viewController: self.vc)
case 1:
Utilities.dismissProgressHUD()
self.vc.toast(msg: data.message ?? "Added to cart", time: 2) {
self.vc.toast(msg: data.message ?? "Added to cart", time: 1) {
if let productDetails = self.productDetails{
CartDataCache.cartListData.append(CartListingDM.ResultData(id: productDetails.id, skuID: productDetails.skuID, productName: productDetails.productName, categoryMasterID: productDetails.categoryMasterID, subCategoryMasterID: productDetails.subCategoryMasterID, productPrice: productDetails.productPrice, remainStockQuantity: productDetails.remainStockQuantity, stockStatus: productDetails.stockStatus, taxValue: productDetails.taxValue, productQuantity: productDetails.remainStockQuantity, shopMasterDetail: productDetails.shopMasterDetail, shopImage: productDetails.shopImage, productFinalPrice: productDetails.productFinalPrice))
self.vc.addToCartBtn.setTitle("View Cart", for: .normal)
self.vc.addToCartBtn.setTitle("Remove", for: .normal)
self.updateCartIcon()
}
}
default:
@@ -111,4 +128,101 @@ class ProductDetailsVM{
}
}
}
func removeItemFromCart(shopMasterID : Int){
Utilities.startProgressHUD()
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["shop_master_id" : shopMasterID]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Cart.remove_cart, method: .post,parameters: params,headers: headers) { [weak self](result : Result<BaseResponseModel<CommonResponseModel>, NetworkManager.APIError>) in
switch result{
case .success(let data):
guard let self else{
Utilities.dismissProgressHUD()
return
}
switch data.success{
case 0:
/*
Error
*/
Utilities.dismissProgressHUD()
Utilities.alert(title: "Error", message: data.message ?? K.ConstantString.unRecognised, viewController: self.vc)
case 1:
Utilities.dismissProgressHUD()
self.vc.toast(msg: data.message ?? "Removed from cart", time: 1) {
self.productDetails?.addedToCart = false
if let index = CartDataCache.cartListData.firstIndex(where: {$0.id == self.productDetails?.id}){
CartDataCache.cartListData.remove(at: index)
self.updateCartIcon()
self.vc.addToCartBtn.setTitle("Add to Cart", for: .normal)
}
}
default:
Utilities.dismissProgressHUD()
break
}
case .failure(let error):
guard let self else{
Utilities.dismissProgressHUD()
return
}
Utilities.dismissProgressHUD()
Utilities.alert(title: "Error", message: error.localizedDescription, viewController: self.vc)
}
}
}
func updateCartIcon(){
// Update the badge label with the current cart data
if let button = cartButton.customView as? UIButton {
BadgeBarBtn.shared.updateBadge(for: button, with: CartDataCache.cartListData.count.toString())
}
}
func getProductDetails(productID : Int){
Utilities.startProgressHUD()
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["product_id" : productID]
// 11 - hindi , 12 - english
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Shop.shop_product_view, method: .post,parameters: params,headers: headers) { [weak self](result : Result<BaseResponseModel<[ShopProductsListingDM.ResultData]>, NetworkManager.APIError>) in
switch result{
case .success(let data):
guard let self else{
Utilities.dismissProgressHUD()
return
}
switch data.success{
case 0:
/*
Error
*/
Utilities.dismissProgressHUD()
self.vc.toast(msg: data.message ?? K.ConstantString.unRecognised, time: 2)
self.vc.scrollView.isHidden = true
self.vc.noDataStack.isHidden = false
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data else{return}
self.productDetails = data.first
self.updateView()
self.vc.scrollView.isHidden = false
self.vc.noDataStack.isHidden = true
default:
Utilities.dismissProgressHUD()
break
}
case .failure(let error):
guard let self else{
Utilities.dismissProgressHUD()
return
}
Utilities.dismissProgressHUD()
self.vc.toast(msg: error.localizedDescription, time: 2)
self.vc.scrollView.isHidden = true
self.vc.noDataStack.isHidden = false
}
}
}
}

View File

@@ -14,17 +14,21 @@ class ShopCategoryVM{
var superCatID : Int?
var categoryData = [ShopCategoryDM.ResultData]()
var cartButton: UIBarButtonItem!
func initView(){
setupCell()
addGradient()
getCategory()
let btn = BadgeBarBtn.shared.setupCartButton()
self.vc.navigationItem.rightBarButtonItems = [btn]
BadgeBarBtn.shared.tapAction = {
print("tapped")
}
cartButton = BadgeBarBtn.shared.setupCartButton(target: self, action: #selector(cartButtonTapped))
self.vc.navigationItem.rightBarButtonItem = cartButton
}
@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)
}
func setupCell(){

View File

@@ -12,24 +12,33 @@ class ShopListingVM{
weak var vc : ShopListingVC!
var superCatData = [ShopSuperCategoryDM.ResultData]()
var cartButton: UIBarButtonItem!
func initView(){
setupCell()
addGradient()
getSuperCategory()
let btn = BadgeBarBtn.shared.setupCartButton()
self.vc.navigationItem.rightBarButtonItems = [btn]
BadgeBarBtn.shared.tapAction = {
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)
}
//check if cart is not fetched
if !CartDataCache.isFetched{
CartDataCache.shareInstance.getCartList(vc: self.vc)
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())
}
}
}
}
cartButton = BadgeBarBtn.shared.setupCartButton(target: self, action: #selector(self.cartButtonTapped))
self.vc.navigationItem.rightBarButtonItem = cartButton
}
@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)
}
func setupCell(){
@@ -46,10 +55,6 @@ class ShopListingVM{
vc.view.applyGradient(colors: [color2, color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0))
}
@objc func cartBtnTapped(){
print("cart tapped")
}
// MARK: - Get SuperCategory
func getSuperCategory(){

View File

@@ -20,11 +20,20 @@ class ShopProductsVM{
var pageNo = 0
var stopFetch = false
var cartButton: UIBarButtonItem!
func initView(){
getCategory()
addGradient()
setupCell()
cartButton = BadgeBarBtn.shared.setupCartButton(target: self, action: #selector(cartButtonTapped))
self.vc.navigationItem.rightBarButtonItem = cartButton
}
@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)
}
func addGradient(){
@@ -101,7 +110,10 @@ class ShopProductsVM{
}
func getShopProducts(subCategoryID : Int?){
guard let categoryID else{return}
guard let categoryID else{
Utilities.dismissProgressHUD()
return
}
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["category_id" : categoryID,
"sub_category_id" : ((subCategoryID == -1) ? "" : subCategoryID?.toString() ) ?? "",

View File

@@ -22,6 +22,11 @@ class MyOrdersVC: UIViewController {
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) {

View File

@@ -10,22 +10,31 @@ import UIKit
class MyOrdersVM{
weak var vc : MyOrdersVC!
var cartButton: UIBarButtonItem!
func initView(){
vc.title = "MY ORDERS".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
let btn = BadgeBarBtn.shared.setupCartButton()
self.vc.navigationItem.rightBarButtonItems = [btn]
BadgeBarBtn.shared.tapAction = {
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)
}
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)
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)
}
}

View File

@@ -99,9 +99,9 @@ class SideMenuVM{
break
}
if let avatar = data.avtar{
vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
// vc.avatarImage.imageURL(avatar)
if let avatar = data.avtarURL{
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
vc.avatarImage.imageURL(avatar)
}
}

View File

@@ -11,7 +11,7 @@ import WebKit
class RadioVC: UIViewController, WKNavigationDelegate {
@IBOutlet var webView: WKWebView!
var url = "https://wokaland.com/admin/api/woka_fm"
var url = "https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/api/woka_fm"
// var url = "https://s4.voscast.com:9161/stream" provide on 18th july
// var url = "https://planetcast.radiowalla.in/radio.mp3" //url from 24th july

View File

@@ -176,9 +176,9 @@ class ThemeOneVM{
break
}
if let avatar = data.avtar{
// vc.avatarImage.imageURL(avatar)
vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
if let avatar = data.avtarURL{
vc.avatarImage.imageURL(avatar)
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
}
}

View File

@@ -181,9 +181,9 @@ class ThemeTwoVM{
break
}
if let avatar = data.avtar{
vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
// vc.avatarImage.imageURL(avatar)
if let avatar = data.avtarURL{
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
vc.avatarImage.imageURL(avatar)
}
}