HomeVC.swift 41 KB

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