Added Notificatio Navigations

This commit is contained in:
2024-08-05 17:37:06 +05:30
parent c8ec96a832
commit 72bd8dd3f2
12 changed files with 262 additions and 126 deletions

View File

@@ -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 = "<group>"; };
529B0DD32C06156B00CFC54B /* LoginNavVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginNavVC.swift; sourceTree = "<group>"; };
529B0DD52C070C0F00CFC54B /* GuestDataDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuestDataDM.swift; sourceTree = "<group>"; };
529CFEED2C60F49000B0B380 /* UserNotificationVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserNotificationVM.swift; sourceTree = "<group>"; };
52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildDM.swift; sourceTree = "<group>"; };
52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildCell.swift; sourceTree = "<group>"; };
52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LinkedChildCell.xib; sourceTree = "<group>"; };
@@ -1626,6 +1628,7 @@
52FDBA7C2BFF481A009D7AC7 /* ThemeOneVM.swift */,
524C422A2C04781B0016A11C /* ThemeTwoVM.swift */,
52BC3BF12C170264002FACA6 /* MoreVM.swift */,
529CFEED2C60F49000B0B380 /* UserNotificationVM.swift */,
);
path = ViewModel;
sourceTree = "<group>";
@@ -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 */,

View File

@@ -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"
}
}

View File

@@ -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 {

View File

@@ -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)

View File

@@ -718,17 +718,53 @@
<rect key="frame" x="0.0" y="74" width="393" height="744"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableView>
<stackView hidden="YES" opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="5iZ-Hr-WYt">
<rect key="frame" x="113.66666666666669" y="315.66666666666669" width="166" height="245.66666666666669"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="SupportGirlImage" translatesAutoresizingMaskIntoConstraints="NO" id="mxb-po-4od">
<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 Blogs Found" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oc1-tq-uxI" 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" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uwb-LF-aK3">
<rect key="frame" x="0.0" y="209.99999999999994" width="166" height="35.666666666666657"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain">
<attributedString key="attributedTitle">
<fragment content="Retry?">
<attributes>
<font key="NSFont" size="18" name="Exo2-Bold"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
</buttonConfiguration>
<connections>
<action selector="retryBtnTapped:" destination="GSM-1I-akm" eventType="touchUpInside" id="NLL-cG-WkI"/>
<action selector="retryBtnTapped:" destination="JL8-U7-koy" eventType="touchUpInside" id="RNx-NX-4xp"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="HwS-aW-IIl"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="5iZ-Hr-WYt" firstAttribute="centerX" secondItem="HwS-aW-IIl" secondAttribute="centerX" id="8XX-Fi-e5E"/>
<constraint firstItem="4Jz-rO-ToO" firstAttribute="leading" secondItem="HwS-aW-IIl" secondAttribute="leading" id="Pwc-fY-ijS"/>
<constraint firstItem="5iZ-Hr-WYt" firstAttribute="centerY" secondItem="HwS-aW-IIl" secondAttribute="centerY" id="XyJ-qZ-IcC"/>
<constraint firstItem="HwS-aW-IIl" firstAttribute="trailing" secondItem="4Jz-rO-ToO" secondAttribute="trailing" id="pPA-fS-veG"/>
<constraint firstItem="HwS-aW-IIl" firstAttribute="bottom" secondItem="4Jz-rO-ToO" secondAttribute="bottom" id="x2e-Ns-hm9"/>
<constraint firstItem="4Jz-rO-ToO" firstAttribute="top" secondItem="HwS-aW-IIl" secondAttribute="top" constant="15" id="zIS-dJ-FOj"/>
</constraints>
</view>
<connections>
<outlet property="noDataStack" destination="5iZ-Hr-WYt" id="TzW-oN-ZPU"/>
<outlet property="tableView" destination="4Jz-rO-ToO" id="AgO-yU-AtX"/>
</connections>
</viewController>
@@ -1287,10 +1323,10 @@
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBrownColor">
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGreenColor">
<color red="0.20392156862745098" green="0.7803921568627451" blue="0.34901960784313724" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>

View File

@@ -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<BaseResponseModel<[UserNotificationDM]>, 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<BaseResponseModel<[UserNotificationDM]>, 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)
// }
// }
// }
//}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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
}
}
}
}

View File

@@ -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<BaseResponseModel<[UserNotificationDM]>, 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
}
}
}
}

View File

@@ -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

View File

@@ -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()