From 72bd8dd3f25e0fcadce75a9d7c3880ecf2e381fa Mon Sep 17 00:00:00 2001 From: BilalKhanWDI Date: Mon, 5 Aug 2024 17:37:06 +0530 Subject: [PATCH] Added Notificatio Navigations --- WOKA.xcodeproj/project.pbxproj | 4 + WOKA/Constants K/AnalyticsEventKeys.swift | 2 +- WOKA/Games/Controller/GamesWebViewVC.swift | 54 ++++------- .../ViewModel/SplashVM.swift | 2 +- WOKA/Theme/Base.lproj/Theme.storyboard | 40 +++++++- WOKA/Theme/CommonNwCall.swift | 78 +++++++-------- WOKA/Theme/Controller/ThemeOneVC.swift | 17 ++-- WOKA/Theme/Controller/ThemeTwoVC.swift | 17 ++-- .../Theme/Controller/UserNotificationVC.swift | 69 +++++++------ WOKA/Theme/ViewModel/UserNotificationVM.swift | 97 +++++++++++++++++++ WOKA/WOKAFM/Controller/WokaFMVC.swift | 4 +- WOKA/WOKAFM/ViewModel/WokaFMVM.swift | 4 +- 12 files changed, 262 insertions(+), 126 deletions(-) create mode 100644 WOKA/Theme/ViewModel/UserNotificationVM.swift diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index 2cdf2a7..85bc08f 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -106,6 +106,7 @@ 528E5F232C24660F00E33E4E /* SeasonCategoryCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 528E5F212C24660F00E33E4E /* SeasonCategoryCell.xib */; }; 529B0DD42C06156B00CFC54B /* LoginNavVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529B0DD32C06156B00CFC54B /* LoginNavVC.swift */; }; 529B0DD62C070C0F00CFC54B /* GuestDataDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529B0DD52C070C0F00CFC54B /* GuestDataDM.swift */; }; + 529CFEEE2C60F49000B0B380 /* UserNotificationVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529CFEED2C60F49000B0B380 /* UserNotificationVM.swift */; }; 52A3F6A52BECBA8D0000BB0B /* LinkedChildDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */; }; 52A3F6A82BECBF2A0000BB0B /* LinkedChildCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */; }; 52A3F6A92BECBF2A0000BB0B /* LinkedChildCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */; }; @@ -453,6 +454,7 @@ 528E5F212C24660F00E33E4E /* SeasonCategoryCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SeasonCategoryCell.xib; sourceTree = ""; }; 529B0DD32C06156B00CFC54B /* LoginNavVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginNavVC.swift; sourceTree = ""; }; 529B0DD52C070C0F00CFC54B /* GuestDataDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuestDataDM.swift; sourceTree = ""; }; + 529CFEED2C60F49000B0B380 /* UserNotificationVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserNotificationVM.swift; sourceTree = ""; }; 52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildDM.swift; sourceTree = ""; }; 52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildCell.swift; sourceTree = ""; }; 52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LinkedChildCell.xib; sourceTree = ""; }; @@ -1626,6 +1628,7 @@ 52FDBA7C2BFF481A009D7AC7 /* ThemeOneVM.swift */, 524C422A2C04781B0016A11C /* ThemeTwoVM.swift */, 52BC3BF12C170264002FACA6 /* MoreVM.swift */, + 529CFEED2C60F49000B0B380 /* UserNotificationVM.swift */, ); path = ViewModel; sourceTree = ""; @@ -2136,6 +2139,7 @@ 524C422B2C04781B0016A11C /* ThemeTwoVM.swift in Sources */, 52A6DCA22C4E3B7500F63C51 /* ShopListingVM.swift in Sources */, 52C8EC7A2C353653002DC35C /* ContinueAudioListDM.swift in Sources */, + 529CFEEE2C60F49000B0B380 /* UserNotificationVM.swift in Sources */, 52B8D4DF2C04A25E00ED65F3 /* StatusBar.swift in Sources */, 5259541D2BE8D94400191286 /* QueueHelper.swift in Sources */, 9CDAEB142C54132E00890C47 /* CheckEddDM.swift in Sources */, diff --git a/WOKA/Constants K/AnalyticsEventKeys.swift b/WOKA/Constants K/AnalyticsEventKeys.swift index 2657742..9941d6e 100644 --- a/WOKA/Constants K/AnalyticsEventKeys.swift +++ b/WOKA/Constants K/AnalyticsEventKeys.swift @@ -9,7 +9,7 @@ import Foundation extension K{ struct AnalyticsEventKeys{ - static var new_guest_login = "new_guest_login" + static var guest_login_iOS = "guest_login_iOS" static var user_signup = "user_signup" } } diff --git a/WOKA/Games/Controller/GamesWebViewVC.swift b/WOKA/Games/Controller/GamesWebViewVC.swift index 3cf0d80..68718a8 100644 --- a/WOKA/Games/Controller/GamesWebViewVC.swift +++ b/WOKA/Games/Controller/GamesWebViewVC.swift @@ -22,7 +22,7 @@ class GamesWebViewVC: UIViewController { appDelegate.deviceOrientation = .landscapeRight let value = UIInterfaceOrientation.landscapeRight.rawValue UIDevice.current.setValue(value, forKey: "orientation") - rotateToLandsScapeDevice() +// rotateToLandsScapeDevice() } guard let url else{return} @@ -34,31 +34,10 @@ class GamesWebViewVC: UIViewController { webView.load(request) } - func rotateToLandsScapeDevice(){ -// let appDelegate = UIApplication.shared.delegate as! AppDelegate -// appDelegate.myOrientation = .landscapeRight -// if #available(iOS 16.0, *) { -// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene -// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: UIInterfaceOrientationMask.landscapeRight)) -// } else { -// UIDevice.current.setValue(UIInterfaceOrientationMask.landscapeRight.rawValue, forKey: "orientation") -// } -// UIView.setAnimationsEnabled(true) - } - - func rotateToPotraitScapeDevice(){ - -// let appDelegate = UIApplication.shared.delegate as! AppDelegate -// appDelegate.myOrientation = .portrait -// if #available(iOS 16.0, *) { -// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene -// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: UIInterfaceOrientationMask.portrait)) -// } else { -// UIDevice.current.setValue(UIInterfaceOrientationMask.landscapeRight.rawValue, forKey: "orientation") -// } -//// UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") -// UIView.setAnimationsEnabled(true) - } + // func rotateView(to angle: CGFloat) { + // // Apply rotation to the view's transform + // view.transform = CGAffineTransform(rotationAngle: angle) + // } @IBAction func backBtnTapped(_ sender: UIButton) { let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) @@ -67,17 +46,20 @@ class GamesWebViewVC: UIViewController { vcPush.contentLabel = "Clicking \"OK\" will exit you from the game. Are you sure you want to proceed?" vcPush.yesBtnText = "OK" vcPush.noBtnText = "Cancel" - vcPush.onDoneBlock = { mode in + vcPush.onDoneBlock = { [weak self] mode in + guard let self else{return} switch mode{ case .yes: - appDelegate.deviceOrientation = .portrait + if orientation == .landscape{ + appDelegate.deviceOrientation = .portrait + let value = UIInterfaceOrientation.portrait.rawValue + UIDevice.current.setValue(value, forKey: "orientation") + }else{ + Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false) { _ in + self.dismiss(animated: true) + } + } - let value = UIInterfaceOrientation.portrait.rawValue - UIDevice.current.setValue(value, forKey: "orientation") - UIViewController.attemptRotationToDeviceOrientation() -// Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in -// self.dismiss(animated: true) -// } case .no: print("no") } @@ -100,8 +82,8 @@ class GamesWebViewVC: UIViewController { private func checkOrientation() { let isPortrait = UIScreen.main.bounds.size.width < UIScreen.main.bounds.size.height if isPortrait { - print("Device is in portrait mode") - Timer.scheduledTimer(withTimeInterval: 0.4, repeats: false) { _ in +// print("Device is in portrait mode") + Timer.scheduledTimer(withTimeInterval: 0.8, repeats: false) { _ in self.dismiss(animated: true) } } else { diff --git a/WOKA/OnBoarding Module/ViewModel/SplashVM.swift b/WOKA/OnBoarding Module/ViewModel/SplashVM.swift index 5ff218f..3110dca 100644 --- a/WOKA/OnBoarding Module/ViewModel/SplashVM.swift +++ b/WOKA/OnBoarding Module/ViewModel/SplashVM.swift @@ -17,7 +17,7 @@ class SplashVM{ func initView(){ -// Analytics.logEvent(K.AnalyticsEventKeys.new_guest_login, parameters: ["os_type" : "iOS"]) +// Analytics.logEvent(K.AnalyticsEventKeys.guest_login_iOS, parameters: nil) vc.activityIndicator.hidesWhenStopped = true let color1 = #colorLiteral(red: 0.144693464, green: 0.1426281333, blue: 0.6686832905, alpha: 1) diff --git a/WOKA/Theme/Base.lproj/Theme.storyboard b/WOKA/Theme/Base.lproj/Theme.storyboard index 98791ec..95157d9 100644 --- a/WOKA/Theme/Base.lproj/Theme.storyboard +++ b/WOKA/Theme/Base.lproj/Theme.storyboard @@ -718,17 +718,53 @@ + + + + @@ -1287,10 +1323,10 @@ - + - + diff --git a/WOKA/Theme/CommonNwCall.swift b/WOKA/Theme/CommonNwCall.swift index d0c537c..257e5ed 100644 --- a/WOKA/Theme/CommonNwCall.swift +++ b/WOKA/Theme/CommonNwCall.swift @@ -8,42 +8,42 @@ import UIKit import Alamofire -class CommonNwCall{ - - static let shareInstance = CommonNwCall() - var userNotification = [UserNotificationDM]() - - func getUserNotification(vc : UIViewController , isRefreshing : Bool? = nil, completion : @escaping (Bool) -> Void){ - if isRefreshing == false || isRefreshing == nil{ - Utilities.startProgressHUD() - } - let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()] - NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.get_user_notifications, method: .get,headers : headers) {(result : Result, NetworkManager.APIError>) in - switch result{ - case .success(let data): - switch data.success{ - case 0: - /* - Error - */ - Utilities.dismissProgressHUD() - vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) - completion(false) - case 1: - Utilities.dismissProgressHUD() - guard let data = data.data else{return} - self.userNotification.removeAll() - self.userNotification.append(contentsOf: data) - //Fetched Blogs - completion(true) - default: - completion(false) - } - case .failure(let error): - Utilities.dismissProgressHUD() - vc.toast(msg: error.localizedDescription , time: 2) - completion(false) - } - } - } -} +//class CommonNwCall{ +// +// static let shareInstance = CommonNwCall() +// var userNotification = [UserNotificationDM]() +// +// func getUserNotification(vc : UIViewController , isRefreshing : Bool? = nil, completion : @escaping (Bool) -> Void){ +// if isRefreshing == false || isRefreshing == nil{ +// Utilities.startProgressHUD() +// } +// let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()] +// NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.get_user_notifications, method: .get,headers : headers) {(result : Result, NetworkManager.APIError>) in +// switch result{ +// case .success(let data): +// switch data.success{ +// case 0: +// /* +// Error +// */ +// Utilities.dismissProgressHUD() +// vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) +// completion(false) +// case 1: +// Utilities.dismissProgressHUD() +// guard let data = data.data else{return} +// self.userNotification.removeAll() +// self.userNotification.append(contentsOf: data) +// //Fetched Blogs +// completion(true) +// default: +// completion(false) +// } +// case .failure(let error): +// Utilities.dismissProgressHUD() +// vc.toast(msg: error.localizedDescription , time: 2) +// completion(false) +// } +// } +// } +//} diff --git a/WOKA/Theme/Controller/ThemeOneVC.swift b/WOKA/Theme/Controller/ThemeOneVC.swift index 08a066c..54448aa 100644 --- a/WOKA/Theme/Controller/ThemeOneVC.swift +++ b/WOKA/Theme/Controller/ThemeOneVC.swift @@ -117,13 +117,16 @@ class ThemeOneVC: UIViewController { } @IBAction func notificationBtnTapped(_ sender: UIButton) { - CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in - if isDone{ - let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) - let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC - self.navigationController?.pushViewController(vcPush, animated: true) - } - } +// CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in +// if isDone{ +// let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) +// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC +// self.navigationController?.pushViewController(vcPush, animated: true) +// } +// } + let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC + self.navigationController?.pushViewController(vcPush, animated: true) } @IBAction func radioBtnTapped(_ sender: UIButton) { diff --git a/WOKA/Theme/Controller/ThemeTwoVC.swift b/WOKA/Theme/Controller/ThemeTwoVC.swift index f5d47eb..83c65c0 100644 --- a/WOKA/Theme/Controller/ThemeTwoVC.swift +++ b/WOKA/Theme/Controller/ThemeTwoVC.swift @@ -60,13 +60,16 @@ class ThemeTwoVC: UIViewController { } @IBAction func notificationBtnTapped(_ sender: UIButton) { - CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in - if isDone{ - let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) - let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC - self.navigationController?.pushViewController(vcPush, animated: true) - } - } +// CommonNwCall.shareInstance.getUserNotification(vc: self) { isDone in +// if isDone{ +// let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) +// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC +// self.navigationController?.pushViewController(vcPush, animated: true) +// } +// } + let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Home.userNotificationVC) as! UserNotificationVC + self.navigationController?.pushViewController(vcPush, animated: true) } @IBAction func playTrailer(_ sender: LocalisedElementsButton) { diff --git a/WOKA/Theme/Controller/UserNotificationVC.swift b/WOKA/Theme/Controller/UserNotificationVC.swift index 9ef4f10..b87f47f 100644 --- a/WOKA/Theme/Controller/UserNotificationVC.swift +++ b/WOKA/Theme/Controller/UserNotificationVC.swift @@ -10,37 +10,22 @@ import UIKit class UserNotificationVC: UIViewController { @IBOutlet weak var tableView: UITableView! - let refreshControl = UIRefreshControl() - let feedbackGenerator = UIImpactFeedbackGenerator(style: .light) + @IBOutlet weak var noDataStack: UIStackView! + + + var vm = UserNotificationVM() + override func viewDidLoad() { super.viewDidLoad() - let color1 = #colorLiteral(red: 0.05490196078, green: 0.01176470588, blue: 0.3882352941, alpha: 1) - let color2 = #colorLiteral(red: 0.2041364683, green: 0.156624428, blue: 0.5904380268, alpha: 1) - self.view.applyMultiGradient(colors: [color1, color2,color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 0.8)) - self.title = "NOTIFICATIONS" - setupCell() + vm.vc = self + vm.initView() navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) navigationController?.navigationBar.shadowImage = UIImage() - - //Adding pull to Refresh - refreshControl.attributedTitle = NSAttributedString(string: "Refreshing...",attributes: [.foregroundColor: UIColor.white]) - refreshControl.tintColor = .white - refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged) - tableView.addSubview(refreshControl) } - // MARK: - Pull to refresh - @objc func refresh(_ sender: AnyObject) { - CommonNwCall.shareInstance.getUserNotification(vc: self,isRefreshing: true) { [weak self] isDone in - guard let self else{return} - feedbackGenerator.impactOccurred() - tableView.reloadData() - refreshControl.endRefreshing() - } - } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) @@ -57,25 +42,51 @@ class UserNotificationVC: UIViewController { self.navigationController?.setColor(color: .black) } - func setupCell(){ - tableView.register(UINib(nibName: K.CellIdentifier.Home.userNotificationCell, bundle: nil), forCellReuseIdentifier: K.CellIdentifier.Home.userNotificationCell) - tableView.delegate = self - tableView.dataSource = self + @IBAction func retryBtnTapped(_ sender: UIButton) { } - } + // MARK: - TableView DataSource , Delegates extension UserNotificationVC : TableViewSRC{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return CommonNwCall.shareInstance.userNotification.count + return vm.userNotification.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.Home.userNotificationCell) as! UserNotificationCell - let data = CommonNwCall.shareInstance.userNotification[indexPath.row] + let data = vm.userNotification[indexPath.row] cell.setData(data: data) return cell } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if let type = vm.userNotification[indexPath.row].postType{ + switch type{ + case 1,2,3,4: + let sb = UIStoryboard(name: K.StoryBoard.webSeries, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.WebSeries.webSeriesVC) as! WebSeriesVC + self.navigationController?.pushViewController(vcPush, animated: true) + case 6: + let sb = UIStoryboard(name: K.StoryBoard.Games, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Games.gamesListVC) as! GamesListVC + self.navigationController?.pushViewController(vcPush, animated: true) + case 7: + let sb = UIStoryboard(name: K.StoryBoard.audioBooks, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.AudioBooks.audioBookHomeVC) as! AudioBookHomeVC + self.navigationController?.pushViewController(vcPush, animated: true) + case 8: + let sb = UIStoryboard(name: K.StoryBoard.Karaoke, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Karaoke.karaokeListingVC) as! KaraokeListingVC + self.navigationController?.pushViewController(vcPush, animated: true) + case 9: + let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopListingVC) as! ShopListingVC + self.navigationController?.pushViewController(vcPush, animated: true) + default: + break + } + } + } } diff --git a/WOKA/Theme/ViewModel/UserNotificationVM.swift b/WOKA/Theme/ViewModel/UserNotificationVM.swift new file mode 100644 index 0000000..7fe3ce8 --- /dev/null +++ b/WOKA/Theme/ViewModel/UserNotificationVM.swift @@ -0,0 +1,97 @@ +// +// UserNotificationVM.swift +// WOKA +// +// Created by MacBook Pro on 05/08/24. +// + +import UIKit +import Alamofire + +class UserNotificationVM{ + + weak var vc : UserNotificationVC! + var userNotification = [UserNotificationDM]() + let refreshControl = UIRefreshControl() + let feedbackGenerator = UIImpactFeedbackGenerator(style: .light) + + func initView(){ + let color1 = #colorLiteral(red: 0.05490196078, green: 0.01176470588, blue: 0.3882352941, alpha: 1) + let color2 = #colorLiteral(red: 0.2041364683, green: 0.156624428, blue: 0.5904380268, alpha: 1) + self.vc.view.applyMultiGradient(colors: [color1, color2,color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 0.8)) + self.vc.title = "NOTIFICATIONS" + setupCell() + Utilities.startProgressHUD() + getUserNotification() + + //Adding pull to Refresh + refreshControl.attributedTitle = NSAttributedString(string: "Refreshing...",attributes: [.foregroundColor: UIColor.white]) + refreshControl.tintColor = .white + refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged) + vc.tableView.addSubview(refreshControl) + } + + func setupCell(){ + vc.tableView.register(UINib(nibName: K.CellIdentifier.Home.userNotificationCell, bundle: nil), forCellReuseIdentifier: K.CellIdentifier.Home.userNotificationCell) + vc.tableView.delegate = vc.self + vc.tableView.dataSource = vc.self + } + + // MARK: - Pull to refresh + + @objc func refresh(_ sender: AnyObject) { +// CommonNwCall.shareInstance.getUserNotification(vc: self,isRefreshing: true) { [weak self] isDone in +// guard let self else{return} +// feedbackGenerator.impactOccurred() +// tableView.reloadData() +// refreshControl.endRefreshing() +// } + getUserNotification() + refreshControl.beginRefreshing() + } + + // MARK: - Get Notifications + + func getUserNotification(){ + let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()] + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.get_user_notifications, method: .get,headers : headers) { [weak self](result : Result, NetworkManager.APIError>) in + guard let self else{return} + switch result{ + case .success(let data): + switch data.success{ + case 0: + /* + Error + */ + Utilities.dismissProgressHUD() + self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + self.vc.noDataStack.isHidden = false + self.vc.tableView.isHidden = true + refreshControl.endRefreshing() + case 1: + Utilities.dismissProgressHUD() + guard let data = data.data else{return} + self.userNotification.removeAll() + self.userNotification.append(contentsOf: data) + feedbackGenerator.impactOccurred() + self.vc.tableView.reloadData() + self.vc.noDataStack.isHidden = true + self.vc.tableView.isHidden = false + refreshControl.endRefreshing() + default: + self.vc.toast(msg: K.ConstantString.unRecognised , time: 2) + Utilities.dismissProgressHUD() + refreshControl.endRefreshing() + break + } + case .failure(let error): + Utilities.dismissProgressHUD() + refreshControl.endRefreshing() + vc.toast(msg: error.localizedDescription , time: 2) + self.vc.noDataStack.isHidden = false + self.vc.tableView.isHidden = true + } + } + } + +} diff --git a/WOKA/WOKAFM/Controller/WokaFMVC.swift b/WOKA/WOKAFM/Controller/WokaFMVC.swift index a96bb47..07b2ee4 100644 --- a/WOKA/WOKAFM/Controller/WokaFMVC.swift +++ b/WOKA/WOKAFM/Controller/WokaFMVC.swift @@ -10,7 +10,7 @@ import AVFoundation import Alamofire class WokaFMVC: UIViewController { - + @IBOutlet weak var roundView: UIView! @IBOutlet weak var mainView: UIView! @IBOutlet weak var playBtn: UIButton! @@ -19,7 +19,7 @@ class WokaFMVC: UIViewController { @IBOutlet weak var activityIndicator: UIActivityIndicatorView! var vm = WokaFMVM() - + override func viewDidLoad() { super.viewDidLoad() vm.vc = self diff --git a/WOKA/WOKAFM/ViewModel/WokaFMVM.swift b/WOKA/WOKAFM/ViewModel/WokaFMVM.swift index 534074a..b43eb2f 100644 --- a/WOKA/WOKAFM/ViewModel/WokaFMVM.swift +++ b/WOKA/WOKAFM/ViewModel/WokaFMVM.swift @@ -13,7 +13,8 @@ class WokaFMVM{ weak var vc : WokaFMVC! //Approved url from client - var url = "https://stream.rcast.net" + var url = "https://stream.rcast.net/71643" + var player: AVPlayer! var playerItem: AVPlayerItem! @@ -49,7 +50,6 @@ class WokaFMVM{ } func retryConnect(){ - self.url = "https://stream.rcast.net/71643" vc.activityIndicator.startAnimating() vc.playBtn.isEnabled = false setupPlayer()