From 8aefc0fe8c9f23de4b2f5fc07014cab8a3bdc0c5 Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 30 Jul 2024 00:21:39 +0530 Subject: [PATCH] home commit. added activity indicator --- .../xcshareddata/xcschemes/WOKA.xcscheme | 14 ++++- WOKA/Address/Address.storyboard | 62 +++++++++---------- WOKA/Address/Controller/AddressListVC.swift | 20 +++++- .../Controller/VerifyAddressPincodeVC.swift | 2 +- WOKA/Address/Model/AddressListDM.swift | 1 + WOKA/Address/View/AddressCell.swift | 11 +++- WOKA/Address/View/AddressCell.xib | 16 +++-- WOKA/Address/ViewModel/AddressListVM.swift | 2 + .../KaraokePause.imageset/Contents.json | 6 +- WOKA/Home/Controller/ExploreWokaVC.swift | 2 +- WOKA/Home/Home.storyboard | 9 +-- 11 files changed, 91 insertions(+), 54 deletions(-) diff --git a/WOKA.xcodeproj/xcshareddata/xcschemes/WOKA.xcscheme b/WOKA.xcodeproj/xcshareddata/xcschemes/WOKA.xcscheme index 1406248..77be55b 100644 --- a/WOKA.xcodeproj/xcshareddata/xcschemes/WOKA.xcscheme +++ b/WOKA.xcodeproj/xcshareddata/xcschemes/WOKA.xcscheme @@ -77,7 +77,19 @@ + isEnabled = "NO"> + + + + + + diff --git a/WOKA/Address/Address.storyboard b/WOKA/Address/Address.storyboard index 699ef03..2e04ae8 100644 --- a/WOKA/Address/Address.storyboard +++ b/WOKA/Address/Address.storyboard @@ -123,16 +123,16 @@ - + - + - + @@ -164,7 +164,7 @@ - + - + @@ -196,7 +196,7 @@ - + - + @@ -228,7 +228,7 @@ - + - + @@ -245,7 +245,7 @@ - + @@ -260,7 +260,7 @@ - + - + @@ -277,7 +277,7 @@ - + @@ -292,7 +292,7 @@ - + - + @@ -324,7 +324,7 @@ - + - + @@ -356,7 +356,7 @@ - + - + @@ -388,14 +388,14 @@ - + - + @@ -607,31 +607,31 @@ - + - + - + - + - + - + - + - + - + diff --git a/WOKA/Address/Controller/AddressListVC.swift b/WOKA/Address/Controller/AddressListVC.swift index c281f51..2a41453 100644 --- a/WOKA/Address/Controller/AddressListVC.swift +++ b/WOKA/Address/Controller/AddressListVC.swift @@ -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.., NetworkManager.APIError>) in diff --git a/WOKA/Address/Model/AddressListDM.swift b/WOKA/Address/Model/AddressListDM.swift index 14870e2..e9c89aa 100644 --- a/WOKA/Address/Model/AddressListDM.swift +++ b/WOKA/Address/Model/AddressListDM.swift @@ -14,6 +14,7 @@ struct AddressListDM: Codable { let state, pincode, country, phoneNo: String? let email: String? var isDefault : Bool? = false + var isAnimating : Bool? = false var eddDate : String? = nil enum CodingKeys: String, CodingKey { diff --git a/WOKA/Address/View/AddressCell.swift b/WOKA/Address/View/AddressCell.swift index b71c80c..f8e7eb3 100644 --- a/WOKA/Address/View/AddressCell.swift +++ b/WOKA/Address/View/AddressCell.swift @@ -14,6 +14,7 @@ class AddressCell: UITableViewCell { @IBOutlet weak var phoneNo: LocalisedElementsLabel! @IBOutlet weak var expecteDelivery: LocalisedElementsLabel! @IBOutlet weak var radioImage: UIImageView! + @IBOutlet weak var activityIndicator: UIActivityIndicatorView! override func awakeFromNib() { super.awakeFromNib() @@ -39,11 +40,19 @@ class AddressCell: UITableViewCell { self.radioImage.image = UIImage(named: "RadioOn") self.expecteDelivery.text = "" if let eddDate = data.eddDate{ - self.expecteDelivery.text = "Expected Delivery by" + "\n" + (data.eddDate ?? "NA") + self.expecteDelivery.text = "Expected Delivery by" + "\n" + eddDate } }else{ self.radioImage.image = UIImage(named: "RadioOff") self.expecteDelivery.text = "" } + + if let isAnimating = data.isAnimating{ + if isAnimating{ + activityIndicator.startAnimating() + }else{ + activityIndicator.stopAnimating() + } + } } } diff --git a/WOKA/Address/View/AddressCell.xib b/WOKA/Address/View/AddressCell.xib index 496ead6..48e0f0c 100644 --- a/WOKA/Address/View/AddressCell.xib +++ b/WOKA/Address/View/AddressCell.xib @@ -46,33 +46,36 @@ - + - @@ -87,6 +90,7 @@ + diff --git a/WOKA/Address/ViewModel/AddressListVM.swift b/WOKA/Address/ViewModel/AddressListVM.swift index d9fce04..cce7338 100644 --- a/WOKA/Address/ViewModel/AddressListVM.swift +++ b/WOKA/Address/ViewModel/AddressListVM.swift @@ -69,6 +69,7 @@ class AddressListVM{ CartDataCache.addressData = data if CartDataCache.addressData.count != 0{ CartDataCache.addressData[0].isDefault = true + CartDataCache.addressData[0].isAnimating = true } self.vc.tableView.reloadData() if let pincode = CartDataCache.addressData.first?.pincode , let id = CartDataCache.addressData.first?.id{ @@ -114,6 +115,7 @@ class AddressListVM{ guard let data = data.data?.result else{return} if let index = CartDataCache.addressData.firstIndex(where: {$0.id == id}){ CartDataCache.addressData[index].eddDate = data.edd + CartDataCache.addressData[index].isAnimating = false self.vc.tableView.reloadData() } default: diff --git a/WOKA/Assets/Assets.xcassets/Karaoke/KaraokePause.imageset/Contents.json b/WOKA/Assets/Assets.xcassets/Karaoke/KaraokePause.imageset/Contents.json index 15b72ef..2bd4cc6 100644 --- a/WOKA/Assets/Assets.xcassets/Karaoke/KaraokePause.imageset/Contents.json +++ b/WOKA/Assets/Assets.xcassets/Karaoke/KaraokePause.imageset/Contents.json @@ -1,17 +1,17 @@ { "images" : [ { - "filename" : "Pause.png", + "filename" : "pause.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "Pause@2x.png", + "filename" : "pause@2x.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "Pause@3x.png", + "filename" : "pause@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/WOKA/Home/Controller/ExploreWokaVC.swift b/WOKA/Home/Controller/ExploreWokaVC.swift index 8f57e87..f67443b 100644 --- a/WOKA/Home/Controller/ExploreWokaVC.swift +++ b/WOKA/Home/Controller/ExploreWokaVC.swift @@ -27,7 +27,7 @@ class ExploreWokaVC: UIViewController { override func viewDidLoad() { super.viewDidLoad() drawBackgroundBlur() - // Do any additional setup after loading the view. + } override func viewDidLayoutSubviews() { diff --git a/WOKA/Home/Home.storyboard b/WOKA/Home/Home.storyboard index d45171e..0811e60 100644 --- a/WOKA/Home/Home.storyboard +++ b/WOKA/Home/Home.storyboard @@ -80,7 +80,7 @@ - + @@ -586,13 +586,6 @@ -