diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index d64ca83..7062955 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 523ED2752BDA2BC900CFED02 /* WOKATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 523ED2742BDA2BC900CFED02 /* WOKATests.swift */; }; 523ED27F2BDA2BC900CFED02 /* WOKAUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 523ED27E2BDA2BC900CFED02 /* WOKAUITests.swift */; }; 523ED2812BDA2BC900CFED02 /* WOKAUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 523ED2802BDA2BC900CFED02 /* WOKAUITestsLaunchTests.swift */; }; + 52423CD12CB6A8A900623CA7 /* CheckReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52423CD02CB6A8A300623CA7 /* CheckReachability.swift */; }; 5242FE592C24203E0086A86D /* WebSeriesSeasonVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5242FE582C24203E0086A86D /* WebSeriesSeasonVC.swift */; }; 5242FE5B2C24317A0086A86D /* WebSeriesSeasonVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5242FE5A2C24317A0086A86D /* WebSeriesSeasonVM.swift */; }; 524612032C64E89E001DA728 /* MyListViewAllVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524612022C64E89E001DA728 /* MyListViewAllVM.swift */; }; @@ -451,6 +452,7 @@ 523ED27A2BDA2BC900CFED02 /* WOKAUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WOKAUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 523ED27E2BDA2BC900CFED02 /* WOKAUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WOKAUITests.swift; sourceTree = ""; }; 523ED2802BDA2BC900CFED02 /* WOKAUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WOKAUITestsLaunchTests.swift; sourceTree = ""; }; + 52423CD02CB6A8A300623CA7 /* CheckReachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckReachability.swift; sourceTree = ""; }; 5242FE582C24203E0086A86D /* WebSeriesSeasonVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSeriesSeasonVC.swift; sourceTree = ""; }; 5242FE5A2C24317A0086A86D /* WebSeriesSeasonVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSeriesSeasonVM.swift; sourceTree = ""; }; 524612022C64E89E001DA728 /* MyListViewAllVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyListViewAllVM.swift; sourceTree = ""; }; @@ -1523,6 +1525,7 @@ 52C8B0512BDA4B51003B51D0 /* Helpers */ = { isa = PBXGroup; children = ( + 52423CD02CB6A8A300623CA7 /* CheckReachability.swift */, 5282DB2D2C981E9300465BA1 /* AdResuable */, 5201D4272C7F22DD008E3211 /* Network */, 9CDAEB0F2C53F12800890C47 /* Shadows */, @@ -2586,6 +2589,7 @@ 52ACC1252C610CBC00791528 /* UserClicks+CoreDataClass.swift in Sources */, 52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */, 9CBCB29D2BE4D6BB007D7934 /* LoginVM.swift in Sources */, + 52423CD12CB6A8A900623CA7 /* CheckReachability.swift in Sources */, 52BBFCB42C5275E100F7D0D1 /* AddressListVM.swift in Sources */, 524C42312C0499560016A11C /* NotificationCenterReloads.swift in Sources */, 9C8C4FAE2C1315410017DD3B /* WebViewVC.swift in Sources */, diff --git a/WOKA/Audio Books/AudioBookHomeVC.swift b/WOKA/Audio Books/AudioBookHomeVC.swift index 9c62a4a..6aaf2fa 100644 --- a/WOKA/Audio Books/AudioBookHomeVC.swift +++ b/WOKA/Audio Books/AudioBookHomeVC.swift @@ -87,6 +87,11 @@ class AudioBookHomeVC: UIViewController { } @IBAction func loadMoreBtn(_ sender: LocalisedElementsButton) { + PersistentStorage.shared.addOthersCount() + if CheckReachability.reachability?.isReachable == false{ + self.toast(msg: K.ConstantString.noInternet , time: 2) + return + } loadMoreBtn.isHidden = true vm.pageNo += 1 loadMoreActivityIndicator.startAnimating() diff --git a/WOKA/Games/Controller/GamesListVC.swift b/WOKA/Games/Controller/GamesListVC.swift index 1a1a2b5..b23ad2c 100644 --- a/WOKA/Games/Controller/GamesListVC.swift +++ b/WOKA/Games/Controller/GamesListVC.swift @@ -112,7 +112,10 @@ class GamesListVC: UIViewController { @IBAction func loadMoreBtnTapped(_ sender: LocalisedElementsButton) { PersistentStorage.shared.addOthersCount() - + if CheckReachability.reachability?.isReachable == false{ + self.toast(msg: K.ConstantString.noInternet , time: 2) + return + } loadMoreBtn.isHidden = true vm.pageNo += 1 loadMoreActivityIndicator.startAnimating() diff --git a/WOKA/Helpers/CheckReachability.swift b/WOKA/Helpers/CheckReachability.swift new file mode 100644 index 0000000..b744db5 --- /dev/null +++ b/WOKA/Helpers/CheckReachability.swift @@ -0,0 +1,11 @@ +// +// CheckReachability.swift +// WOKA +// +// Created by MacBook Pro on 09/10/24. +// +import Alamofire + +class CheckReachability{ + static var reachability = NetworkReachabilityManager() +} diff --git a/WOKA/Helpers/LoadingIndicatorImageView.swift b/WOKA/Helpers/LoadingIndicatorImageView.swift index c10a3f9..6125ad2 100644 --- a/WOKA/Helpers/LoadingIndicatorImageView.swift +++ b/WOKA/Helpers/LoadingIndicatorImageView.swift @@ -8,36 +8,68 @@ import UIKit import SDWebImage +enum ImageType{ + case homeAvatar + case none +} extension UIImageView { - func imageURL(_ url: String, color : UIColor = UIColor.black) { + func imageURL(_ url: String, color : UIColor = UIColor.appColor(.TextDarkBlue)!, type : ImageType = .none) { + let customIndicator = SDWebImageActivityIndicator.medium + customIndicator.indicatorView.color = color + self.sd_imageIndicator = customIndicator - let activityIndicator = UIActivityIndicatorView(style: .medium) - activityIndicator.tintColor = UIColor.darkGray - activityIndicator.color = color - activityIndicator.frame = CGRect(x: 0, y: 0, width: 64, height: 64) - activityIndicator.hidesWhenStopped = true - DispatchQueue.main.async { - activityIndicator.startAnimating() - } - activityIndicator.translatesAutoresizingMaskIntoConstraints = true - - // activityIndicator.center = CGPoint(x: self.frame.size.width / 2, y: self.frame.size.height / 2) - activityIndicator.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)) - - // bottom is for resizing the indicator to be perfect in center - activityIndicator.autoresizingMask = (UIView.AutoresizingMask(rawValue: UIView.AutoresizingMask.RawValue(UInt8(UIView.AutoresizingMask.flexibleRightMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleLeftMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleBottomMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleTopMargin.rawValue)))) - - self.addSubview(activityIndicator) - - self.sd_setImage(with: URL(string: url.replacingOccurrences(of: " ", with: "%20"))) { (image, error, cacheType, url) in -// activityIndicator.stopAnimating() - DispatchQueue.main.async { - activityIndicator.stopAnimating() -// activityIndicator.removeFromSuperview() + self.sd_setImage(with: URL(string: url.replacingOccurrences(of: " ", with: "%20"))) { [weak self] (image, error, cacheType, url) in + if error != nil{ + // do a placeholder image here + guard let self else{return} + handlePlaceHolder(type: type) } } } + + + //Update the placeholder images respective to the type + func handlePlaceHolder(type : ImageType){ + switch type{ + case .homeAvatar: + self.image = UIImage(named: "DefaultAvatar") + case .none: + self.image = UIImage(named: "WokaLogo") + + break + } + } + + //Old Detained Code +// func imageURL(_ url: String, color : UIColor = UIColor.black) { +// +// let activityIndicator = UIActivityIndicatorView(style: .medium) +// activityIndicator.tintColor = UIColor.darkGray +// activityIndicator.color = color +// activityIndicator.frame = CGRect(x: 0, y: 0, width: 64, height: 64) +// activityIndicator.hidesWhenStopped = true +// DispatchQueue.main.async { +// activityIndicator.startAnimating() +// } +// activityIndicator.translatesAutoresizingMaskIntoConstraints = true +// +// // activityIndicator.center = CGPoint(x: self.frame.size.width / 2, y: self.frame.size.height / 2) +// activityIndicator.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)) +// +// // bottom is for resizing the indicator to be perfect in center +// activityIndicator.autoresizingMask = (UIView.AutoresizingMask(rawValue: UIView.AutoresizingMask.RawValue(UInt8(UIView.AutoresizingMask.flexibleRightMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleLeftMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleBottomMargin.rawValue) | UInt8(UIView.AutoresizingMask.flexibleTopMargin.rawValue)))) +// +// self.addSubview(activityIndicator) +// +// self.sd_setImage(with: URL(string: url.replacingOccurrences(of: " ", with: "%20"))) { (image, error, cacheType, url) in +//// activityIndicator.stopAnimating() +// DispatchQueue.main.async { +// activityIndicator.stopAnimating() +//// activityIndicator.removeFromSuperview() +// } +// } +// } } extension UIButton { diff --git a/WOKA/Karaoke/Controller/KaraokeListingVC.swift b/WOKA/Karaoke/Controller/KaraokeListingVC.swift index 9161aa5..839a531 100644 --- a/WOKA/Karaoke/Controller/KaraokeListingVC.swift +++ b/WOKA/Karaoke/Controller/KaraokeListingVC.swift @@ -87,6 +87,10 @@ class KaraokeListingVC: UIViewController { @IBAction func loadMoreBtnTapped(_ sender: LocalisedElementsButton) { PersistentStorage.shared.addOthersCount() + if CheckReachability.reachability?.isReachable == false{ + self.toast(msg: K.ConstantString.noInternet , time: 2) + return + } loadMoreBtn.isHidden = true vm.pageNo += 1 loadMoreActivityIndicator.startAnimating() diff --git a/WOKA/Main/AuthFunc/AuthFuncTimeHandling.swift b/WOKA/Main/AuthFunc/AuthFuncTimeHandling.swift index 6c80443..050a7be 100644 --- a/WOKA/Main/AuthFunc/AuthFuncTimeHandling.swift +++ b/WOKA/Main/AuthFunc/AuthFuncTimeHandling.swift @@ -9,6 +9,15 @@ import UIKit extension AuthFunc{ + /// This function will make predefined time sets for handling UI updates. + /// + /// + /// + /// Usage: + /// + /// Used to initialize the timings set for the theme 1 bakground update. + /// + /// - Returns: Nothing. func initTimePeriods(){ // Define the time periods let morning = TimePeriod.morning( diff --git a/WOKA/Main/Delegate/SceneDelegate.swift b/WOKA/Main/Delegate/SceneDelegate.swift index 96ca735..536caf0 100644 --- a/WOKA/Main/Delegate/SceneDelegate.swift +++ b/WOKA/Main/Delegate/SceneDelegate.swift @@ -52,7 +52,5 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { PersistentStorage.shared.checkLastSync() } } - - } diff --git a/WOKA/Shop/Shop.storyboard b/WOKA/Shop/Shop.storyboard index fe1f2ce..7bfe7ce 100644 --- a/WOKA/Shop/Shop.storyboard +++ b/WOKA/Shop/Shop.storyboard @@ -122,7 +122,7 @@ - + @@ -290,15 +290,15 @@ - + - + -