Added Notificatio Navigations
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user