home commit. added activity indicator

This commit is contained in:
Bilal
2024-07-30 00:21:39 +05:30
parent edcb7c4e29
commit 8aefc0fe8c
11 changed files with 91 additions and 54 deletions

View File

@@ -82,16 +82,32 @@ extension AddressListVC : TableViewSRC{
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Resetting the Radio clicks
for index in CartDataCache.addressData.indices {
CartDataCache.addressData[index].isDefault = false
}
//
if CartDataCache.addressData[indexPath.row].eddDate == nil || CartDataCache.addressData[indexPath.row].eddDate == ""{
if let pincode = CartDataCache.addressData[indexPath.row].pincode, let id = CartDataCache.addressData[indexPath.row].id{
vm.checkEstimatedDeliveryData(pinCode: pincode, id: id)
// check if array has same pincode and edd is there
if let alreadyPincodePresent = CartDataCache.addressData.firstIndex(where: {$0.pincode == pincode && $0.eddDate != nil}){
CartDataCache.addressData[indexPath.row].eddDate = CartDataCache.addressData[alreadyPincodePresent].eddDate
}else{
// else if not present fetch it again
CartDataCache.addressData[indexPath.row].isAnimating = true
vm.checkEstimatedDeliveryData(pinCode: pincode, id: id)
}
}
}
CartDataCache.addressData[indexPath.row].isDefault = true
tableView.reloadData()
tableView.reloadData(with: .fade)
}
}
extension UITableView {
func reloadData(with animation: UITableView.RowAnimation) {
reloadSections(IndexSet(integersIn: 0..<numberOfSections), with: animation)
}
}

View File

@@ -77,7 +77,7 @@ class VerifyAddressPincodeVC: UIViewController {
}
func checkEstimatedDeliveryData(pinCode : String){
Utilities.startProgressHUD()
Utilities.startProgressHUD(msg: "Checking Pincode..")
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["pincode" : pinCode]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Address.pincode_serviceability_check_edd, method: .post, parameters: params,headers: headers) { [weak self](result : Result<BaseResponseModel<CheckEddDM>, NetworkManager.APIError>) in