HomeVC.swift 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. //
  2. // HomeVC.swift
  3. // Sirani
  4. //
  5. // Created by Anhar Solehudin on 24/03/19.
  6. // Copyright © 2019 Anhar Solehudin. All rights reserved.
  7. //
  8. import UIKit
  9. import ImageSlideshow
  10. class HomeVC: UIViewController {
  11. // Outlets
  12. @IBOutlet weak var notifContainer: UIView!
  13. @IBOutlet weak var notifBg: CircleView!
  14. @IBOutlet weak var lblNotif: UILabel!
  15. @IBOutlet weak var progressLayout: UIView!
  16. @IBOutlet weak var progress: UIActivityIndicatorView!
  17. @IBOutlet weak var slideshow: ImageSlideshow!
  18. @IBOutlet weak var container: UIView!
  19. @IBOutlet weak var moreMenuLayout: UIView!
  20. @IBOutlet weak var headerLayout: UIView!
  21. @IBOutlet weak var moreMenuContainer: UIView!
  22. @IBOutlet weak var mainMenuCV: UICollectionView!
  23. @IBOutlet weak var btnMoreMenu: UIButton!
  24. @IBOutlet weak var btnMoreNews: UIButton!
  25. @IBOutlet weak var homeNewsTV: UITableView!
  26. @IBOutlet weak var moreMenuUtamaCV: UICollectionView!
  27. @IBOutlet weak var moreMenuAplikasiODSTitleLayout: UIView!
  28. @IBOutlet weak var moreMenuOdsNotif: UIView!
  29. @IBOutlet weak var lblMoreMenuAplikasiODSNotif: UILabel!
  30. @IBOutlet weak var moreMenuAplikasiODSCV: UICollectionView!
  31. @IBOutlet weak var marginMoreMenuAplikasiODS: UIView!
  32. @IBOutlet weak var moreMenuFotoLabelTitleLayout: UIView!
  33. @IBOutlet weak var moreMenuFotoLabelNotif: UIView!
  34. @IBOutlet weak var lblMoreMenuFotoLabelNotif: UILabel!
  35. @IBOutlet weak var moreMenuFotoLabelCV: UICollectionView!
  36. @IBOutlet weak var marginMoreMenuFotoLabel: UIView!
  37. @IBOutlet weak var moreMenuAplikasiTitleLayout: UIView!
  38. @IBOutlet weak var moreMenuAplikasiNotif: UIView!
  39. @IBOutlet weak var lblMoreMenuAplikasiNotif: UILabel!
  40. @IBOutlet weak var moreMenuAplikasiCV: UICollectionView!
  41. @IBOutlet weak var marginMoreMenuAplikasi: UIView!
  42. @IBOutlet weak var moreMenuSP2SertifikatTitleLayout: UIView!
  43. @IBOutlet weak var moreMenuSP2SertifikatNotif: UIView!
  44. @IBOutlet weak var lblMoreMenuSP2SertifikatNotif: UILabel!
  45. @IBOutlet weak var moreMenuSP2SertifikatCV: UICollectionView!
  46. @IBOutlet weak var marginMoreMenuSP2Sertifikat: UIView!
  47. @IBOutlet weak var moreMenuSP2TambahanTItleLayout: UIView!
  48. @IBOutlet weak var moreMenuSP2TambahanNotif: UIView!
  49. @IBOutlet weak var lblMoreMenuSP2TambahanNotif: UILabel!
  50. @IBOutlet weak var moreMenuSP2TambahanCV: UICollectionView!
  51. @IBOutlet weak var marginMoreMenuSP2Tambahan: UIView!
  52. @IBOutlet weak var moreMenuDaftarRHUTitleLayout: UIView!
  53. @IBOutlet weak var moreMenuDaftarRhuNotif: UIView!
  54. @IBOutlet weak var lblMoreMenuDaftarRHUNotif: UILabel!
  55. @IBOutlet weak var moreMenuDaftarRHUCV: UICollectionView!
  56. @IBOutlet weak var marginMoreMenuDaftarRHU: UIView!
  57. @IBOutlet weak var moreMenuSertifikatTitleLayout: UIView!
  58. @IBOutlet weak var moreMenuSertifikatNotif: UIView!
  59. @IBOutlet weak var lblMoreMenuSertifikatNotif: UILabel!
  60. @IBOutlet weak var moreMenuSertifikatCV: UICollectionView!
  61. @IBOutlet weak var marginMoreMenuSertifikat: UIView!
  62. @IBOutlet weak var moreMenuSurveyTitleLayout: UIView!
  63. @IBOutlet weak var moreMenuSurveyNotif: UIView!
  64. @IBOutlet weak var lblMoreMenuNotif: UILabel!
  65. @IBOutlet weak var moreMenuSurveyCV: UICollectionView!
  66. @IBOutlet weak var marginMoreMenuSurvey: UIView!
  67. // id
  68. private let homeNewsCellId = "HomeNewsCellId"
  69. // initialize
  70. private let presenter = HomePresenter(siraniApiServices: SiraniApiServices())
  71. // data list
  72. private var listNews = [News]()
  73. private let listMenuUtama = MenuListData.instance.getMenuUtamaData()
  74. private var listMenuAplikasiODS = [MenuItem]()
  75. private var listMenuFotoLabel = [MenuItem]()
  76. private var listMenuAplikasi = [MenuItem]()
  77. private var listMenuSP2Sertifikat = [MenuItem]()
  78. private var listMenuSP2Tambahan = [MenuItem]()
  79. private var listMenuDaftarRHU = [MenuItem]()
  80. private var listMenuSertifikat = [MenuItem]()
  81. private var listMenuSurvey = [MenuItem]()
  82. // Constants
  83. private let menuItemSize = 85.75
  84. private let CUSTOMER_ROLE_ID = Constants.instance.CUSTOMER_ROLE_ID
  85. private let OPERATOR_ROLE_ID = Constants.instance.OPERATOR_ROLE_ID
  86. private let KEPALA_SEKSI_ROLE_ID = Constants.instance.KEPALA_SEKSI_ROLE_ID
  87. private let KEPALA_SUB_DIREKTORAT_ROLE_ID = Constants.instance.KEPALA_SUB_DIREKTORAT_ROLE_ID
  88. private let DIREKTUR_ROLE_ID = Constants.instance.DIREKTUR_ROLE_ID
  89. // Variables (notes : let is constants)
  90. private var moreMenuFrame: CGRect?
  91. private var loading = false
  92. private var selectedNewsId = 0
  93. private var moreMenuShown = false
  94. private var showMoreMenuDuration = 0.2
  95. private var userRoleId = ""
  96. public var openNotif = false
  97. // View Lifecycles
  98. override var preferredStatusBarStyle: UIStatusBarStyle {
  99. return .lightContent
  100. }
  101. override func viewWillAppear(_ animated: Bool) {
  102. AppUtility.lockOrientation(.portrait)
  103. btnMoreMenu.layer.cornerRadius = 5
  104. btnMoreNews.layer.cornerRadius = 5
  105. moreMenuFrame = moreMenuLayout.frame
  106. moreMenuLayout.frame = .init(
  107. x: 0,
  108. y: view.frame.height,
  109. width: moreMenuFrame!.size.width,
  110. height: moreMenuFrame!.size.height
  111. )
  112. let gesture = UITapGestureRecognizer(target: self, action: #selector(self.openNotifList))
  113. notifContainer.addGestureRecognizer(gesture)
  114. userRoleId = UserState.instance.getRoleId()
  115. let userId = UserState.instance.getUserId()
  116. let custId = UserState.instance.getCustId()
  117. print("userRoleId")
  118. print(userRoleId)
  119. print(userId)
  120. print(custId)
  121. if !userRoleId.isEmpty {
  122. showNotif()
  123. } else {
  124. hideNotif()
  125. }
  126. }
  127. override func viewDidLoad() {
  128. super.viewDidLoad()
  129. presenter.attachView(view: self)
  130. presenter.loadSlideshowImages()
  131. if openNotif {
  132. print("SSSSSS")
  133. performSegue(withIdentifier: "NotifListSegueId", sender: self)
  134. }
  135. setMainMenu()
  136. setNewsView()
  137. setMoreMainMenu()
  138. userRoleId = UserState.instance.getRoleId()
  139. if !userRoleId.isEmpty {
  140. setMoreMenuAplikasiODS(userRoleId: userRoleId)
  141. setMoreMenuFotoLabel(userRoleId: userRoleId)
  142. setMoreMenuAplikasi(userRoleId: userRoleId)
  143. setMoreMenuSP2Sertifikat(userRoleId: userRoleId)
  144. setMoreMenuSP2Tambahan(userRoleId: userRoleId)
  145. setMoreMenuDaftarRHU(userRoleId: userRoleId)
  146. setMoreMenuSertifikat(userRoleId: userRoleId)
  147. setMoreMenuSurvey(userRoleId: userRoleId)
  148. showNotif()
  149. } else {
  150. hideNotif()
  151. }
  152. }
  153. override func viewDidAppear(_ animated: Bool) {
  154. presenter.attachView(view: self)
  155. if openNotif {
  156. print("VVVVVV")
  157. performSegue(withIdentifier: "NotifListSegueId", sender: self)
  158. }
  159. if moreMenuShown {
  160. showMoreMenu()
  161. }
  162. let roleId = UserState.instance.getRoleId()
  163. if (userRoleId != roleId) {
  164. userRoleId = roleId
  165. if !userRoleId.isEmpty {
  166. clearMoreMenu()
  167. setMoreMenuAplikasiODS(userRoleId: userRoleId)
  168. setMoreMenuFotoLabel(userRoleId: userRoleId)
  169. setMoreMenuAplikasi(userRoleId: userRoleId)
  170. setMoreMenuSP2Sertifikat(userRoleId: userRoleId)
  171. setMoreMenuSP2Tambahan(userRoleId: userRoleId)
  172. setMoreMenuDaftarRHU(userRoleId: userRoleId)
  173. setMoreMenuSertifikat(userRoleId: userRoleId)
  174. setMoreMenuSurvey(userRoleId: userRoleId)
  175. clearMoreMenuNotifData()
  176. presenter.loadMenuNotifications()
  177. showNotif()
  178. } else {
  179. clearMoreMenu()
  180. clearMoreMenuNotifData()
  181. hideNotif()
  182. }
  183. }
  184. }
  185. override func viewWillDisappear(_ animated: Bool) {
  186. AppUtility.lockOrientation(.all)
  187. }
  188. override func viewDidDisappear(_ animated: Bool) {
  189. presenter.detachView()
  190. }
  191. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  192. if let destVC = segue.destination as? NewsDetailVC {
  193. destVC.newsId = self.selectedNewsId
  194. destVC.segueId = destVC.SEGUE_HOME_ID
  195. }
  196. }
  197. // private functions
  198. private func showNotif() {
  199. notifContainer.show()
  200. presenter.loadTotalUnreadNotif()
  201. }
  202. private func hideNotif() {
  203. notifContainer.hide()
  204. notifBg.hide()
  205. lblNotif.text = ""
  206. }
  207. private func setMainMenu() {
  208. let flowLayout = UICollectionViewFlowLayout()
  209. flowLayout.sectionInset = .init(top: 0, left: 8, bottom: 0, right: 8)
  210. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  211. flowLayout.minimumInteritemSpacing = 0
  212. flowLayout.minimumLineSpacing = 0
  213. mainMenuCV.collectionViewLayout = flowLayout
  214. mainMenuCV.delegate = self
  215. mainMenuCV.dataSource = self
  216. mainMenuCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuUtamaCellId)
  217. }
  218. private func setNewsView() {
  219. homeNewsTV.delegate = self
  220. homeNewsTV.dataSource = self
  221. let footer = UIView()
  222. footer.backgroundColor = #colorLiteral(red: 0.9814968705, green: 0.9760531783, blue: 1, alpha: 1)
  223. homeNewsTV.tableFooterView = footer
  224. presenter.loadNews(cursor: 0, prev: 1, jenis: "", columns: "")
  225. }
  226. private func showMoreMenu() {
  227. if !loading {
  228. UIView.animate(withDuration: showMoreMenuDuration, delay: 0, options: [.curveEaseOut], animations: {
  229. self.moreMenuShown = true
  230. self.moreMenuLayout.show()
  231. self.moreMenuFrame = self.moreMenuLayout.frame
  232. self.moreMenuLayout.frame = .init(x: 0, y: self.headerLayout.frame.height, width: self.moreMenuFrame!.size.width, height: self.moreMenuFrame!.size.height)
  233. })
  234. }
  235. }
  236. private func hideMoreMenu() {
  237. self.moreMenuShown = false
  238. self.moreMenuLayout.hide()
  239. self.moreMenuFrame = self.moreMenuLayout.frame
  240. self.moreMenuLayout.frame = .init(x: 0, y: view.frame.height, width: self.moreMenuFrame!.size.width, height: self.moreMenuFrame!.size.height)
  241. }
  242. private func clearMoreMenu() {
  243. moreMenuAplikasiODSTitleLayout.hide()
  244. moreMenuOdsNotif.hide()
  245. moreMenuAplikasiODSCV.hide()
  246. marginMoreMenuAplikasiODS.hide()
  247. moreMenuFotoLabelTitleLayout.hide()
  248. moreMenuFotoLabelNotif.hide()
  249. moreMenuFotoLabelCV.hide()
  250. marginMoreMenuFotoLabel.hide()
  251. moreMenuAplikasiTitleLayout.hide()
  252. moreMenuAplikasiNotif.hide()
  253. moreMenuAplikasiCV.hide()
  254. marginMoreMenuAplikasi.hide()
  255. moreMenuSP2SertifikatTitleLayout.hide()
  256. moreMenuSP2SertifikatNotif.hide()
  257. moreMenuSP2SertifikatCV.hide()
  258. marginMoreMenuSP2Sertifikat.hide()
  259. moreMenuSP2TambahanTItleLayout.hide()
  260. moreMenuSP2TambahanNotif.hide()
  261. moreMenuSP2TambahanCV.hide()
  262. marginMoreMenuSP2Tambahan.hide()
  263. moreMenuDaftarRHUTitleLayout.hide()
  264. moreMenuDaftarRhuNotif.hide()
  265. moreMenuDaftarRHUCV.hide()
  266. marginMoreMenuDaftarRHU.hide()
  267. moreMenuSertifikatTitleLayout.hide()
  268. moreMenuSertifikatNotif.hide()
  269. moreMenuSertifikatCV.hide()
  270. marginMoreMenuSertifikat.hide()
  271. moreMenuSurveyTitleLayout.hide()
  272. moreMenuSurveyNotif.hide()
  273. moreMenuSurveyCV.hide()
  274. marginMoreMenuSurvey.hide()
  275. }
  276. private func clearMoreMenuNotifData() {
  277. moreMenuOdsNotif.hide()
  278. moreMenuFotoLabelNotif.hide()
  279. moreMenuAplikasiNotif.hide()
  280. moreMenuSP2SertifikatNotif.hide()
  281. moreMenuSP2TambahanNotif.hide()
  282. moreMenuDaftarRhuNotif.hide()
  283. moreMenuSertifikatNotif.hide()
  284. moreMenuSurveyNotif.hide()
  285. for i in 0..<listMenuAplikasiODS.count {
  286. listMenuAplikasiODS[i].totalNotif = 0
  287. }
  288. for i in 0..<listMenuFotoLabel.count {
  289. listMenuFotoLabel[i].totalNotif = 0
  290. }
  291. for i in 0..<listMenuAplikasi.count {
  292. listMenuAplikasi[i].totalNotif = 0
  293. }
  294. for i in 0..<listMenuSP2Sertifikat.count {
  295. listMenuSP2Sertifikat[i].totalNotif = 0
  296. }
  297. for i in 0..<listMenuSP2Tambahan.count {
  298. listMenuSP2Tambahan[i].totalNotif = 0
  299. }
  300. for i in 0..<listMenuDaftarRHU.count {
  301. listMenuDaftarRHU[i].totalNotif = 0
  302. }
  303. for i in 0..<listMenuSertifikat.count {
  304. listMenuSertifikat[i].totalNotif = 0
  305. }
  306. for i in 0..<listMenuSurvey.count {
  307. listMenuSurvey[i].totalNotif = 0
  308. }
  309. moreMenuAplikasiODSCV.reloadData()
  310. moreMenuFotoLabelCV.reloadData()
  311. moreMenuAplikasiCV.reloadData()
  312. moreMenuSP2SertifikatCV.reloadData()
  313. moreMenuSP2TambahanCV.reloadData()
  314. moreMenuDaftarRHUCV.reloadData()
  315. moreMenuSertifikatCV.reloadData()
  316. moreMenuSurveyCV.reloadData()
  317. }
  318. private func setMoreMainMenu() {
  319. let flowLayout = UICollectionViewFlowLayout()
  320. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  321. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  322. flowLayout.minimumInteritemSpacing = 0
  323. flowLayout.minimumLineSpacing = 0
  324. moreMenuUtamaCV.collectionViewLayout = flowLayout
  325. moreMenuUtamaCV.delegate = self
  326. moreMenuUtamaCV.dataSource = self
  327. moreMenuUtamaCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.moreMenuUtamaCellId)
  328. }
  329. private func setMoreMenuAplikasiODS(userRoleId: String) {
  330. // notif
  331. moreMenuOdsNotif.layer.cornerRadius = 5
  332. // menus
  333. let flowLayout = UICollectionViewFlowLayout()
  334. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  335. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  336. flowLayout.minimumInteritemSpacing = 0
  337. flowLayout.minimumLineSpacing = 0
  338. moreMenuAplikasiODSCV.collectionViewLayout = flowLayout
  339. moreMenuAplikasiODSCV.delegate = self
  340. moreMenuAplikasiODSCV.dataSource = self
  341. moreMenuAplikasiODSCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuAplikasiODSCellId)
  342. listMenuAplikasiODS = MenuListData.instance.getMenuAplikasiOdsData(userRoleId: userRoleId)
  343. if listMenuAplikasiODS.count > 0 {
  344. moreMenuAplikasiODSCV.reloadData()
  345. moreMenuAplikasiODSTitleLayout.show()
  346. moreMenuAplikasiODSCV.show()
  347. marginMoreMenuAplikasiODS.show()
  348. }
  349. }
  350. private func setMoreMenuFotoLabel(userRoleId: String) {
  351. // notif
  352. moreMenuFotoLabelNotif.layer.cornerRadius = 5
  353. // menus
  354. let flowLayout = UICollectionViewFlowLayout()
  355. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  356. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  357. flowLayout.minimumInteritemSpacing = 0
  358. flowLayout.minimumLineSpacing = 0
  359. moreMenuFotoLabelCV.collectionViewLayout = flowLayout
  360. moreMenuFotoLabelCV.delegate = self
  361. moreMenuFotoLabelCV.dataSource = self
  362. moreMenuFotoLabelCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuFotoLabelCellId)
  363. listMenuFotoLabel = MenuListData.instance.getMenuFotoLabelData(userRoleId: userRoleId)
  364. if listMenuFotoLabel.count > 0 {
  365. moreMenuFotoLabelCV.reloadData()
  366. moreMenuFotoLabelTitleLayout.show()
  367. moreMenuFotoLabelCV.show()
  368. marginMoreMenuFotoLabel.show()
  369. }
  370. }
  371. private func setMoreMenuAplikasi(userRoleId: String) {
  372. // notif
  373. moreMenuAplikasiNotif.layer.cornerRadius = 5
  374. // menus
  375. let flowLayout = UICollectionViewFlowLayout()
  376. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  377. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  378. flowLayout.minimumInteritemSpacing = 0
  379. flowLayout.minimumLineSpacing = 0
  380. moreMenuAplikasiCV.collectionViewLayout = flowLayout
  381. moreMenuAplikasiCV.delegate = self
  382. moreMenuAplikasiCV.dataSource = self
  383. moreMenuAplikasiCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuAplikasiCellId)
  384. listMenuAplikasi = MenuListData.instance.getMenuAplikasiData(userRoleId: userRoleId)
  385. if listMenuAplikasi.count > 0 {
  386. moreMenuAplikasiCV.reloadData()
  387. moreMenuAplikasiTitleLayout.show()
  388. moreMenuAplikasiCV.show()
  389. marginMoreMenuAplikasi.show()
  390. }
  391. }
  392. private func setMoreMenuSP2Sertifikat(userRoleId: String) {
  393. // notif
  394. moreMenuSP2SertifikatNotif.layer.cornerRadius = 5
  395. // menus
  396. let flowLayout = UICollectionViewFlowLayout()
  397. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  398. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  399. flowLayout.minimumInteritemSpacing = 0
  400. flowLayout.minimumLineSpacing = 0
  401. moreMenuSP2SertifikatCV.collectionViewLayout = flowLayout
  402. moreMenuSP2SertifikatCV.delegate = self
  403. moreMenuSP2SertifikatCV.dataSource = self
  404. moreMenuSP2SertifikatCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSP2SertifikatCellId)
  405. listMenuSP2Sertifikat = MenuListData.instance.getMenuSP2SertifikatData(userRoleId: userRoleId)
  406. if listMenuSP2Sertifikat.count > 0 {
  407. moreMenuSP2SertifikatCV.reloadData()
  408. moreMenuSP2SertifikatTitleLayout.show()
  409. moreMenuSP2SertifikatCV.show()
  410. marginMoreMenuSP2Sertifikat.show()
  411. }
  412. }
  413. private func setMoreMenuSP2Tambahan(userRoleId: String) {
  414. // notif
  415. moreMenuSP2TambahanNotif.layer.cornerRadius = 5
  416. // menus
  417. let flowLayout = UICollectionViewFlowLayout()
  418. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  419. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  420. flowLayout.minimumInteritemSpacing = 0
  421. flowLayout.minimumLineSpacing = 0
  422. moreMenuSP2TambahanCV.collectionViewLayout = flowLayout
  423. moreMenuSP2TambahanCV.delegate = self
  424. moreMenuSP2TambahanCV.dataSource = self
  425. moreMenuSP2TambahanCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSP2TambahanCellId)
  426. listMenuSP2Tambahan = MenuListData.instance.getMenuSP2TambahanData(userRoleId: userRoleId)
  427. if listMenuSP2Tambahan.count > 0 {
  428. moreMenuSP2TambahanCV.reloadData()
  429. moreMenuSP2TambahanTItleLayout.show()
  430. moreMenuSP2TambahanCV.show()
  431. marginMoreMenuSP2Tambahan.show()
  432. }
  433. }
  434. private func setMoreMenuDaftarRHU(userRoleId: String) {
  435. // notif
  436. moreMenuDaftarRhuNotif.layer.cornerRadius = 5
  437. // menus
  438. let flowLayout = UICollectionViewFlowLayout()
  439. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  440. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  441. flowLayout.minimumInteritemSpacing = 0
  442. flowLayout.minimumLineSpacing = 0
  443. moreMenuDaftarRHUCV.collectionViewLayout = flowLayout
  444. moreMenuDaftarRHUCV.delegate = self
  445. moreMenuDaftarRHUCV.dataSource = self
  446. moreMenuDaftarRHUCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuDaftarRhuCellId)
  447. listMenuDaftarRHU = MenuListData.instance.getMenuDaftarRhuData(userRoleId: userRoleId)
  448. if listMenuDaftarRHU.count > 0 {
  449. moreMenuDaftarRHUCV.reloadData()
  450. moreMenuDaftarRHUTitleLayout.show()
  451. moreMenuDaftarRHUCV.show()
  452. marginMoreMenuDaftarRHU.show()
  453. }
  454. }
  455. private func setMoreMenuSertifikat(userRoleId: String) {
  456. // notif
  457. moreMenuSertifikatNotif.layer.cornerRadius = 5
  458. // menus
  459. let flowLayout = UICollectionViewFlowLayout()
  460. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  461. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  462. flowLayout.minimumInteritemSpacing = 0
  463. flowLayout.minimumLineSpacing = 0
  464. moreMenuSertifikatCV.collectionViewLayout = flowLayout
  465. moreMenuSertifikatCV.delegate = self
  466. moreMenuSertifikatCV.dataSource = self
  467. moreMenuSertifikatCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSertifikatCellId)
  468. listMenuSertifikat = MenuListData.instance.getMenuSertifikatData(userRoleId: userRoleId)
  469. if listMenuSertifikat.count > 0 {
  470. moreMenuSertifikatCV.reloadData()
  471. moreMenuSertifikatTitleLayout.show()
  472. moreMenuSertifikatCV.show()
  473. marginMoreMenuSertifikat.show()
  474. }
  475. }
  476. private func setMoreMenuSurvey(userRoleId: String) {
  477. // notif
  478. moreMenuSurveyNotif.layer.cornerRadius = 5
  479. // menus
  480. let flowLayout = UICollectionViewFlowLayout()
  481. flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
  482. flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
  483. flowLayout.minimumInteritemSpacing = 0
  484. flowLayout.minimumLineSpacing = 0
  485. moreMenuSurveyCV.collectionViewLayout = flowLayout
  486. moreMenuSurveyCV.delegate = self
  487. moreMenuSurveyCV.dataSource = self
  488. moreMenuSurveyCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSurveyCellId)
  489. listMenuSurvey = MenuListData.instance.getMenuSurveyData(userRoleId: userRoleId)
  490. if listMenuSurvey.count > 0 {
  491. moreMenuSurveyCV.reloadData()
  492. moreMenuSurveyTitleLayout.show()
  493. moreMenuSurveyCV.show()
  494. marginMoreMenuSurvey.show()
  495. }
  496. }
  497. // IB Actions
  498. @IBAction func unwindToHome(segue: UIStoryboardSegue) {}
  499. @IBAction func onBtnMoreMenuTapped(_ sender: Any) {
  500. self.showMoreMenu()
  501. if !loading {
  502. let userRoleId = UserState.instance.getRoleId()
  503. if !userRoleId.isEmpty {
  504. clearMoreMenuNotifData()
  505. presenter.loadMenuNotifications()
  506. }
  507. }
  508. }
  509. @IBAction func dismissMoreMenuLayout(_ sender: Any) {
  510. self.hideMoreMenu()
  511. }
  512. @IBAction func onBtnMoreNewsTap(_ sender: Any) {
  513. if !loading {
  514. performSegue(withIdentifier: "NewsSegueId", sender: self)
  515. }
  516. }
  517. @objc func openNotifList(sender : UITapGestureRecognizer) {
  518. performSegue(withIdentifier: "NotifListSegueId", sender: self)
  519. }
  520. public func openNotifListPage() {
  521. performSegue(withIdentifier: "NotifListSegueId", sender: self)
  522. }
  523. }
  524. // HomeViewDelegate
  525. extension HomeVC: HomeViewDelegate {
  526. func showLoading() {
  527. loading = true
  528. progress.startAnimating()
  529. progressLayout.show()
  530. }
  531. func hideLoading() {
  532. loading = false
  533. progress.stopAnimating()
  534. progressLayout.hide()
  535. }
  536. func setTotalUnreadNotif(totalUnreadNotif: Int) {
  537. if totalUnreadNotif > 0 {
  538. lblNotif.text = String(totalUnreadNotif)
  539. notifBg.show()
  540. } else {
  541. lblNotif.text = ""
  542. notifBg.hide()
  543. }
  544. }
  545. func setSlideshowImages(images: [String]) {
  546. if !images.isEmpty {
  547. var sources = [SDWebImageSource]()
  548. for url in images {
  549. sources.append(SDWebImageSource(urlString: url)!)
  550. }
  551. self.slideshow.slideshowInterval = 2.0
  552. self.slideshow.pageIndicatorPosition = .init(horizontal: .center, vertical: .under)
  553. self.slideshow.contentScaleMode = UIView.ContentMode.scaleAspectFill
  554. let pageControl = UIPageControl()
  555. pageControl.currentPageIndicatorTintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
  556. pageControl.pageIndicatorTintColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
  557. self.slideshow.pageIndicator = pageControl
  558. self.slideshow.setImageInputs(sources)
  559. }
  560. }
  561. func setNews(listNews: [News]) {
  562. if listNews.count > 0 {
  563. homeNewsTV.beginUpdates()
  564. for news in listNews {
  565. self.listNews.append(news)
  566. homeNewsTV.insertRows(
  567. at: [IndexPath(row: self.listNews.count-1, section: 0)],
  568. with: .automatic
  569. )
  570. }
  571. homeNewsTV.endUpdates()
  572. }
  573. }
  574. func setMenuNotifications(menuNotification: MenuNotification) {
  575. let userRoleId = UserState.instance.getRoleId()
  576. if userRoleId == CUSTOMER_ROLE_ID {
  577. if listMenuSP2Sertifikat.count > 0 {
  578. // total notif
  579. let totalNotif = menuNotification.tot_sp2_sertifikat
  580. if (totalNotif > 0) {
  581. lblMoreMenuSP2SertifikatNotif.text = "\(totalNotif)"
  582. moreMenuSP2SertifikatNotif.show()
  583. } else {
  584. moreMenuSP2SertifikatNotif.hide()
  585. }
  586. // sp2 sertifikat
  587. listMenuSP2Sertifikat[0].totalNotif = menuNotification.tot_sp2_sertifikat
  588. moreMenuSP2SertifikatCV.reloadData()
  589. }
  590. if listMenuSP2Tambahan.count > 0 {
  591. // total notif
  592. let tot_ods = menuNotification.tot_sp2_tambahan
  593. if (tot_ods > 0) {
  594. lblMoreMenuSP2TambahanNotif.text = "\(tot_ods)"
  595. moreMenuSP2TambahanNotif.show()
  596. } else {
  597. moreMenuSP2TambahanNotif.hide()
  598. }
  599. // sp2 tambahan
  600. listMenuSP2Tambahan[0].totalNotif = menuNotification.tot_sp2_tambahan
  601. moreMenuSP2TambahanCV.reloadData()
  602. }
  603. if listMenuSertifikat.count > 0 {
  604. // total
  605. let tot_ods = menuNotification.tot_sertifikat
  606. if (tot_ods > 0) {
  607. lblMoreMenuSertifikatNotif.text = "\(tot_ods)"
  608. moreMenuSertifikatNotif.show()
  609. } else {
  610. moreMenuSertifikatNotif.hide()
  611. }
  612. // sert sementara
  613. listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
  614. // sert berlaku
  615. listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
  616. moreMenuSertifikatCV.reloadData()
  617. }
  618. } else if userRoleId == OPERATOR_ROLE_ID {
  619. if listMenuAplikasiODS.count > 0 {
  620. // total notif
  621. let totalNotif = menuNotification.tot_ods
  622. if (totalNotif > 0) {
  623. lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
  624. moreMenuOdsNotif.show()
  625. } else {
  626. moreMenuOdsNotif.hide()
  627. }
  628. // ods sp2 baru
  629. listMenuAplikasiODS[1].totalNotif = menuNotification.cnt_ods_sp2baru
  630. // ods sp2 otirisasi
  631. listMenuAplikasiODS[2].totalNotif = menuNotification.cnt_ods_sp2otorisasi
  632. moreMenuAplikasiODSCV.reloadData()
  633. }
  634. if listMenuSertifikat.count > 0 {
  635. // total notif
  636. let totalNotif = menuNotification.tot_sertifikat
  637. if (totalNotif > 0) {
  638. lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
  639. moreMenuSertifikatNotif.show()
  640. } else {
  641. moreMenuSertifikatNotif.hide()
  642. }
  643. // sert sementara
  644. listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
  645. // sert berlaku
  646. listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
  647. moreMenuSertifikatCV.reloadData()
  648. }
  649. } else if userRoleId == KEPALA_SEKSI_ROLE_ID {
  650. if listMenuAplikasiODS.count > 0 {
  651. // total notif
  652. let totalNotif = menuNotification.tot_ods
  653. if (totalNotif > 0) {
  654. lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
  655. moreMenuOdsNotif.show()
  656. } else {
  657. moreMenuOdsNotif.hide()
  658. }
  659. // ods sp2 otorisasi
  660. listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
  661. //sp2 before
  662. listMenuAplikasiODS[1].totalNotif = menuNotification.cnt_ods_sp2before
  663. //sp2 after
  664. listMenuAplikasiODS[2].totalNotif = menuNotification.cnt_ods_sp2after
  665. moreMenuAplikasiODSCV.reloadData()
  666. }
  667. if listMenuSertifikat.count > 0 {
  668. // total notif
  669. let totalNotif = menuNotification.tot_sertifikat
  670. if (totalNotif > 0) {
  671. lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
  672. moreMenuSertifikatNotif.show()
  673. } else {
  674. moreMenuSertifikatNotif.hide()
  675. }
  676. // sert sementara
  677. listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
  678. // sert berlaku
  679. listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
  680. moreMenuSertifikatCV.reloadData()
  681. }
  682. } else if userRoleId == KEPALA_SUB_DIREKTORAT_ROLE_ID {
  683. if listMenuAplikasiODS.count > 0 {
  684. // total notif
  685. let totalNotif = menuNotification.tot_ods
  686. if (totalNotif > 0) {
  687. lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
  688. moreMenuOdsNotif.show()
  689. } else {
  690. moreMenuOdsNotif.hide()
  691. }
  692. // ods sp2 otorisasi
  693. listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
  694. moreMenuAplikasiODSCV.reloadData()
  695. }
  696. if listMenuSertifikat.count > 0 {
  697. // total notif
  698. let totalNotif = menuNotification.tot_sertifikat
  699. if (totalNotif > 0) {
  700. lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
  701. moreMenuSertifikatNotif.show()
  702. } else {
  703. moreMenuSertifikatNotif.hide()
  704. }
  705. // sert sementara
  706. listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
  707. // sert berlaku
  708. listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
  709. moreMenuSertifikatCV.reloadData()
  710. }
  711. } else if userRoleId == DIREKTUR_ROLE_ID {
  712. if listMenuAplikasiODS.count > 0 {
  713. // total notif
  714. let totalNotif = menuNotification.tot_ods
  715. if (totalNotif > 0) {
  716. lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
  717. moreMenuOdsNotif.show()
  718. } else {
  719. moreMenuOdsNotif.hide()
  720. }
  721. // ods sp2 otorisasi
  722. listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
  723. moreMenuAplikasiODSCV.reloadData()
  724. }
  725. if listMenuSertifikat.count > 0 {
  726. // total notif
  727. let totalNotif = menuNotification.tot_sertifikat
  728. if (totalNotif > 0) {
  729. lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
  730. moreMenuSertifikatNotif.show()
  731. } else {
  732. moreMenuSertifikatNotif.hide()
  733. }
  734. // sert sementara
  735. listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
  736. // sert berlaku
  737. listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
  738. moreMenuSertifikatCV.reloadData()
  739. }
  740. }
  741. }
  742. }
  743. // CollectionView functions
  744. extension HomeVC : UICollectionViewDelegate, UICollectionViewDataSource {
  745. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  746. if collectionView == self.mainMenuCV {
  747. return listMenuUtama.count
  748. } else if collectionView == self.moreMenuUtamaCV {
  749. return listMenuUtama.count
  750. } else if collectionView == self.moreMenuAplikasiODSCV {
  751. return listMenuAplikasiODS.count
  752. } else if collectionView == self.moreMenuFotoLabelCV {
  753. return listMenuFotoLabel.count
  754. } else if collectionView == self.moreMenuAplikasiCV {
  755. return listMenuAplikasi.count
  756. } else if collectionView == self.moreMenuSP2SertifikatCV {
  757. return listMenuSP2Sertifikat.count
  758. } else if collectionView == self.moreMenuSP2TambahanCV {
  759. return listMenuSP2Tambahan.count
  760. } else if collectionView == self.moreMenuDaftarRHUCV {
  761. return listMenuDaftarRHU.count
  762. } else if collectionView == self.moreMenuSertifikatCV {
  763. return listMenuSertifikat.count
  764. } else if collectionView == self.moreMenuSurveyCV {
  765. return listMenuSurvey.count
  766. } else {
  767. return 0
  768. }
  769. }
  770. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  771. if collectionView == self.mainMenuCV {
  772. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuUtamaCellId, for: indexPath) as? MenuCell {
  773. let menu = listMenuUtama[indexPath.row]
  774. cell.updateViews(menu: menu)
  775. return cell
  776. } else {
  777. return MenuCell()
  778. }
  779. } else if collectionView == self.moreMenuUtamaCV {
  780. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.moreMenuUtamaCellId, for: indexPath) as? MenuCell {
  781. let menu = listMenuUtama[indexPath.row]
  782. cell.updateViews(menu: menu)
  783. return cell
  784. } else {
  785. return MenuCell()
  786. }
  787. } else if collectionView == self.moreMenuAplikasiODSCV {
  788. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuAplikasiODSCellId, for: indexPath) as? MenuCell {
  789. let menu = listMenuAplikasiODS[indexPath.row]
  790. cell.updateViews(menu: menu)
  791. return cell
  792. } else {
  793. return MenuCell()
  794. }
  795. } else if collectionView == self.moreMenuFotoLabelCV {
  796. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuFotoLabelCellId, for: indexPath) as? MenuCell {
  797. let menu = listMenuFotoLabel[indexPath.row]
  798. cell.updateViews(menu: menu)
  799. return cell
  800. } else {
  801. return MenuCell()
  802. }
  803. } else if collectionView == self.moreMenuAplikasiCV {
  804. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuAplikasiCellId, for: indexPath) as? MenuCell {
  805. let menu = listMenuAplikasi[indexPath.row]
  806. cell.updateViews(menu: menu)
  807. return cell
  808. } else {
  809. return MenuCell()
  810. }
  811. } else if collectionView == self.moreMenuSP2SertifikatCV {
  812. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSP2SertifikatCellId, for: indexPath) as? MenuCell {
  813. let menu = listMenuSP2Sertifikat[indexPath.row]
  814. cell.updateViews(menu: menu)
  815. return cell
  816. } else {
  817. return MenuCell()
  818. }
  819. } else if collectionView == self.moreMenuSP2TambahanCV {
  820. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSP2TambahanCellId, for: indexPath) as? MenuCell {
  821. let menu = listMenuSP2Tambahan[indexPath.row]
  822. cell.updateViews(menu: menu)
  823. return cell
  824. } else {
  825. return MenuCell()
  826. }
  827. } else if collectionView == self.moreMenuDaftarRHUCV {
  828. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuDaftarRhuCellId, for: indexPath) as? MenuCell {
  829. let menu = listMenuDaftarRHU[indexPath.row]
  830. cell.updateViews(menu: menu)
  831. return cell
  832. } else {
  833. return MenuCell()
  834. }
  835. } else if collectionView == self.moreMenuSertifikatCV {
  836. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSertifikatCellId, for: indexPath) as? MenuCell {
  837. let menu = listMenuSertifikat[indexPath.row]
  838. cell.updateViews(menu: menu)
  839. return cell
  840. } else {
  841. return MenuCell()
  842. }
  843. } else if collectionView == self.moreMenuSurveyCV {
  844. if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSurveyCellId, for: indexPath) as? MenuCell {
  845. let menu = listMenuSurvey[indexPath.row]
  846. cell.updateViews(menu: menu)
  847. return cell
  848. } else {
  849. return MenuCell()
  850. }
  851. } else {
  852. return MenuCell()
  853. }
  854. }
  855. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  856. var segueId = ""
  857. if collectionView == self.mainMenuCV {
  858. segueId = listMenuUtama[indexPath.row].segueId
  859. } else if collectionView == self.moreMenuUtamaCV {
  860. segueId = listMenuUtama[indexPath.row].segueId
  861. } else if collectionView == self.moreMenuAplikasiODSCV {
  862. segueId = listMenuAplikasiODS[indexPath.row].segueId
  863. } else if collectionView == self.moreMenuFotoLabelCV {
  864. segueId = listMenuFotoLabel[indexPath.row].segueId
  865. } else if collectionView == self.moreMenuAplikasiCV {
  866. segueId = listMenuAplikasi[indexPath.row].segueId
  867. } else if collectionView == self.moreMenuSP2SertifikatCV {
  868. segueId = listMenuSP2Sertifikat[indexPath.row].segueId
  869. } else if collectionView == self.moreMenuSP2TambahanCV {
  870. segueId = listMenuSP2Tambahan[indexPath.row].segueId
  871. } else if collectionView == self.moreMenuDaftarRHUCV {
  872. segueId = listMenuDaftarRHU[indexPath.row].segueId
  873. } else if collectionView == self.moreMenuSertifikatCV {
  874. segueId = listMenuSertifikat[indexPath.row].segueId
  875. } else if collectionView == self.moreMenuSurveyCV {
  876. segueId = listMenuSurvey[indexPath.row].segueId
  877. }
  878. if !segueId.isEmpty {
  879. if !loading {
  880. performSegue(withIdentifier: segueId, sender: self)
  881. }
  882. }
  883. }
  884. }
  885. // UITableController Protocols
  886. extension HomeVC: UITableViewDelegate, UITableViewDataSource {
  887. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  888. return listNews.count
  889. }
  890. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  891. if tableView == homeNewsTV {
  892. if let cell = tableView.dequeueReusableCell(withIdentifier: homeNewsCellId, for: indexPath) as? HomeNewsCell {
  893. let news = listNews[indexPath.row]
  894. cell.updateViews(news: news)
  895. return cell
  896. } else {
  897. return HomeNewsCell()
  898. }
  899. } else {
  900. return HomeNewsCell()
  901. }
  902. }
  903. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  904. let selectedNews = self.listNews[indexPath.row]
  905. self.selectedNewsId = selectedNews.id
  906. performSegue(withIdentifier: "homeToNewsDetailSegueId", sender: self)
  907. }
  908. }