| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125 |
- //
- // HomeVC.swift
- // Sirani
- //
- // Created by Anhar Solehudin on 24/03/19.
- // Copyright © 2019 Anhar Solehudin. All rights reserved.
- //
- import UIKit
- import ImageSlideshow
- class HomeVC: UIViewController {
-
- // Outlets
- @IBOutlet weak var notifContainer: UIView!
- @IBOutlet weak var notifBg: CircleView!
- @IBOutlet weak var lblNotif: UILabel!
-
- @IBOutlet weak var progressLayout: UIView!
- @IBOutlet weak var progress: UIActivityIndicatorView!
-
- @IBOutlet weak var slideshow: ImageSlideshow!
- @IBOutlet weak var container: UIView!
- @IBOutlet weak var moreMenuLayout: UIView!
- @IBOutlet weak var headerLayout: UIView!
- @IBOutlet weak var moreMenuContainer: UIView!
- @IBOutlet weak var mainMenuCV: UICollectionView!
- @IBOutlet weak var btnMoreMenu: UIButton!
- @IBOutlet weak var btnMoreNews: UIButton!
- @IBOutlet weak var homeNewsTV: UITableView!
- @IBOutlet weak var moreMenuUtamaCV: UICollectionView!
-
- @IBOutlet weak var moreMenuNewTitleLayout: UIView!
- @IBOutlet weak var moreMenuNewNotif: UIView!
- @IBOutlet weak var lblMoreMenuUtamaNewNotif: UILabel!
- @IBOutlet weak var moreMenuUtamaNewCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuUtamaNew: UIView!
-
- @IBOutlet weak var moreMenuAplikasiODSTitleLayout: UIView!
- @IBOutlet weak var moreMenuOdsNotif: UIView!
- @IBOutlet weak var lblMoreMenuAplikasiODSNotif: UILabel!
- @IBOutlet weak var moreMenuAplikasiODSCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuAplikasiODS: UIView!
-
- @IBOutlet weak var moreMenuFotoLabelTitleLayout: UIView!
- @IBOutlet weak var moreMenuFotoLabelNotif: UIView!
- @IBOutlet weak var lblMoreMenuFotoLabelNotif: UILabel!
- @IBOutlet weak var moreMenuFotoLabelCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuFotoLabel: UIView!
-
- @IBOutlet weak var moreMenuAplikasiTitleLayout: UIView!
- @IBOutlet weak var moreMenuAplikasiNotif: UIView!
- @IBOutlet weak var lblMoreMenuAplikasiNotif: UILabel!
- @IBOutlet weak var moreMenuAplikasiCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuAplikasi: UIView!
-
- @IBOutlet weak var moreMenuSP2SertifikatTitleLayout: UIView!
- @IBOutlet weak var moreMenuSP2SertifikatNotif: UIView!
- @IBOutlet weak var lblMoreMenuSP2SertifikatNotif: UILabel!
- @IBOutlet weak var moreMenuSP2SertifikatCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuSP2Sertifikat: UIView!
-
- @IBOutlet weak var moreMenuSP2TambahanTItleLayout: UIView!
- @IBOutlet weak var moreMenuSP2TambahanNotif: UIView!
- @IBOutlet weak var lblMoreMenuSP2TambahanNotif: UILabel!
- @IBOutlet weak var moreMenuSP2TambahanCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuSP2Tambahan: UIView!
-
- @IBOutlet weak var moreMenuDaftarRHUTitleLayout: UIView!
- @IBOutlet weak var moreMenuDaftarRhuNotif: UIView!
- @IBOutlet weak var lblMoreMenuDaftarRHUNotif: UILabel!
- @IBOutlet weak var moreMenuDaftarRHUCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuDaftarRHU: UIView!
-
- @IBOutlet weak var moreMenuSertifikatTitleLayout: UIView!
- @IBOutlet weak var moreMenuSertifikatNotif: UIView!
- @IBOutlet weak var lblMoreMenuSertifikatNotif: UILabel!
- @IBOutlet weak var moreMenuSertifikatCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuSertifikat: UIView!
-
- @IBOutlet weak var moreMenuSurveyTitleLayout: UIView!
- @IBOutlet weak var moreMenuSurveyNotif: UIView!
- @IBOutlet weak var lblMoreMenuNotif: UILabel!
- @IBOutlet weak var moreMenuSurveyCV: UICollectionView!
- @IBOutlet weak var marginMoreMenuSurvey: UIView!
-
- // id
- private let homeNewsCellId = "HomeNewsCellId"
-
- // initialize
- private let presenter = HomePresenter(siraniApiServices: SiraniApiServices())
-
- // data list
- private var listNews = [News]()
- private let listMenuUtama = MenuListData.instance.getMenuUtamaData()
- private var listMenuUtamaNew = [MenuItem]()
- private var listMenuAplikasiODS = [MenuItem]()
- private var listMenuFotoLabel = [MenuItem]()
- private var listMenuAplikasi = [MenuItem]()
- private var listMenuSP2Sertifikat = [MenuItem]()
- private var listMenuSP2Tambahan = [MenuItem]()
- private var listMenuDaftarRHU = [MenuItem]()
- private var listMenuSertifikat = [MenuItem]()
- private var listMenuSurvey = [MenuItem]()
-
- // Constants
- private let menuItemSize = 85.75
- private let CUSTOMER_ROLE_ID = Constants.instance.CUSTOMER_ROLE_ID
- private let OPERATOR_ROLE_ID = Constants.instance.OPERATOR_ROLE_ID
- private let KEPALA_SEKSI_ROLE_ID = Constants.instance.KEPALA_SEKSI_ROLE_ID
- private let KEPALA_SUB_DIREKTORAT_ROLE_ID = Constants.instance.KEPALA_SUB_DIREKTORAT_ROLE_ID
- private let DIREKTUR_ROLE_ID = Constants.instance.DIREKTUR_ROLE_ID
-
- // Variables (notes : let is constants)
- private var moreMenuFrame: CGRect?
- private var loading = false
- private var selectedNewsId = 0
- private var date = ""
- private var judul = ""
- private var urlThumb = ""
- private var moreMenuShown = false
- private var showMoreMenuDuration = 0.2
- private var userRoleId = ""
- public var openNotif = false
- // View Lifecycles
- override var preferredStatusBarStyle: UIStatusBarStyle {
- return .lightContent
- }
-
- override func viewWillAppear(_ animated: Bool) {
- AppUtility.lockOrientation(.portrait)
-
- checkUserState()
-
- btnMoreMenu.layer.cornerRadius = 5
- btnMoreNews.layer.cornerRadius = 5
-
- moreMenuFrame = moreMenuLayout.frame
- moreMenuLayout.frame = .init(
- x: 0,
- y: view.frame.height,
- width: moreMenuFrame!.size.width,
- height: moreMenuFrame!.size.height
- )
-
- let gesture = UITapGestureRecognizer(target: self, action: #selector(self.openNotifList))
- notifContainer.addGestureRecognizer(gesture)
-
- userRoleId = UserState.instance.getRoleId()
- let userId = UserState.instance.getUserId()
- let custId = UserState.instance.getCustId()
- if !userRoleId.isEmpty {
- showNotif()
- } else {
- hideNotif()
- }
-
- setSlideImageView()
- setNewsView()
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- presenter.attachView(view: self)
-
- if openNotif {
- performSegue(withIdentifier: "NotifListSegueId", sender: self)
- }
-
- setMainMenu()
- // setNewsView()
- // setMoreMainMenu()
-
- userRoleId = UserState.instance.getRoleId()
- if !userRoleId.isEmpty {
- setMoreMenuUtamaNew(userRoleId: userRoleId)
- // setMoreMenuAplikasiODS(userRoleId: userRoleId)
- // setMoreMenuFotoLabel(userRoleId: userRoleId)
- // setMoreMenuAplikasi(userRoleId: userRoleId)
- // setMoreMenuSP2Sertifikat(userRoleId: userRoleId)
- // setMoreMenuSP2Tambahan(userRoleId: userRoleId)
- // setMoreMenuDaftarRHU(userRoleId: userRoleId)
- // setMoreMenuSertifikat(userRoleId: userRoleId)
- // setMoreMenuSurvey(userRoleId: userRoleId)
- showNotif()
- } else {
- hideNotif()
- }
- }
-
- override func viewDidAppear(_ animated: Bool) {
- presenter.attachView(view: self)
-
- if openNotif {
- print("VVVVVV")
- performSegue(withIdentifier: "NotifListSegueId", sender: self)
- }
-
- if moreMenuShown {
- showMoreMenu()
- }
-
- // let roleId = UserState.instance.getRoleId()
- // if (userRoleId != roleId) {
- // userRoleId = roleId
- //
- if !userRoleId.isEmpty {
- clearMoreMenu()
- setMoreMenuUtamaNew(userRoleId: userRoleId)
- // setMoreMenuAplikasiODS(userRoleId: userRoleId)
- // setMoreMenuFotoLabel(userRoleId: userRoleId)
- // setMoreMenuAplikasi(userRoleId: userRoleId)
- // setMoreMenuSP2Sertifikat(userRoleId: userRoleId)
- // setMoreMenuSP2Tambahan(userRoleId: userRoleId)
- // setMoreMenuDaftarRHU(userRoleId: userRoleId)
- // setMoreMenuSertifikat(userRoleId: userRoleId)
- // setMoreMenuSurvey(userRoleId: userRoleId)
- clearMoreMenuNotifData()
-
- if ConnectionHelper.isConnectedToNetwork() {
- self.presenter.loadMenuNotifications()
- } else {
- CommonHelper.showNoConnection(in: self)
- }
-
- showNotif()
- } else {
- clearMoreMenu()
- clearMoreMenuNotifData()
- hideNotif()
- }
- // }
- }
-
- override func viewWillDisappear(_ animated: Bool) {
- AppUtility.lockOrientation(.all)
- }
-
- override func viewDidDisappear(_ animated: Bool) {
- presenter.detachView()
- }
-
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- if let destVC = segue.destination as? NewsDetailVC {
- destVC.newsId = self.selectedNewsId
- destVC.date = self.date
- destVC.judul = self.judul
- destVC.urlThumb = self.urlThumb.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
- destVC.segueId = destVC.SEGUE_HOME_ID
- }
- }
-
- // private functions
- private func checkUserState() {
- let isLoggedIn = UserState.instance.isLoggedIn()
- if isLoggedIn {
- btnMoreMenu.show()
- } else {
- btnMoreMenu.hide()
- }
- }
-
- private func showNotif() {
- notifContainer.show()
-
- if ConnectionHelper.isConnectedToNetwork() {
- self.presenter.loadTotalUnreadNotif()
- } else {
- CommonHelper.showNoConnection(in: self)
- }
- }
-
- private func hideNotif() {
- notifContainer.hide()
- notifBg.hide()
- lblNotif.text = ""
- }
-
- private func setMainMenu() {
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 8, bottom: 0, right: 8)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- mainMenuCV.collectionViewLayout = flowLayout
- mainMenuCV.delegate = self
- mainMenuCV.dataSource = self
- mainMenuCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuUtamaCellId)
- }
-
- private func setNewsView() {
- homeNewsTV.delegate = self
- homeNewsTV.dataSource = self
- let footer = UIView()
- footer.backgroundColor = #colorLiteral(red: 0.9814968705, green: 0.9760531783, blue: 1, alpha: 1)
- homeNewsTV.tableFooterView = footer
-
- if ConnectionHelper.isConnectedToNetwork() {
- self.presenter.loadNews(cursor: 5, prev: 1, jenis: "", columns: "")
- } else {
- CommonHelper.showNoConnection(in: self)
- }
- }
- private func setSlideImageView() {
- if ConnectionHelper.isConnectedToNetwork() {
- self.presenter.loadSlideshowImages()
- } else {
- CommonHelper.showNoConnection(in: self)
- }
- }
-
- private func showMoreMenu() {
- if !loading {
- UIView.animate(withDuration: showMoreMenuDuration, delay: 0, options: [.curveEaseOut], animations: {
- self.moreMenuShown = true
- self.moreMenuLayout.show()
- self.moreMenuFrame = self.moreMenuLayout.frame
- self.moreMenuLayout.frame = .init(x: 0, y: self.headerLayout.frame.height, width: self.moreMenuFrame!.size.width, height: self.moreMenuFrame!.size.height)
- })
- }
- }
-
- private func hideMoreMenu() {
- self.moreMenuShown = false
- self.moreMenuLayout.hide()
- self.moreMenuFrame = self.moreMenuLayout.frame
- self.moreMenuLayout.frame = .init(x: 0, y: view.frame.height, width: self.moreMenuFrame!.size.width, height: self.moreMenuFrame!.size.height)
- }
-
- private func clearMoreMenu() {
- moreMenuAplikasiODSTitleLayout.hide()
- moreMenuOdsNotif.hide()
- moreMenuAplikasiODSCV.hide()
- marginMoreMenuAplikasiODS.hide()
-
- moreMenuFotoLabelTitleLayout.hide()
- moreMenuFotoLabelNotif.hide()
- moreMenuFotoLabelCV.hide()
- marginMoreMenuFotoLabel.hide()
-
- moreMenuAplikasiTitleLayout.hide()
- moreMenuAplikasiNotif.hide()
- moreMenuAplikasiCV.hide()
- marginMoreMenuAplikasi.hide()
-
- moreMenuSP2SertifikatTitleLayout.hide()
- moreMenuSP2SertifikatNotif.hide()
- moreMenuSP2SertifikatCV.hide()
- marginMoreMenuSP2Sertifikat.hide()
-
- moreMenuSP2TambahanTItleLayout.hide()
- moreMenuSP2TambahanNotif.hide()
- moreMenuSP2TambahanCV.hide()
- marginMoreMenuSP2Tambahan.hide()
-
- moreMenuDaftarRHUTitleLayout.hide()
- moreMenuDaftarRhuNotif.hide()
- moreMenuDaftarRHUCV.hide()
- marginMoreMenuDaftarRHU.hide()
-
- moreMenuSertifikatTitleLayout.hide()
- moreMenuSertifikatNotif.hide()
- moreMenuSertifikatCV.hide()
- marginMoreMenuSertifikat.hide()
-
- moreMenuSurveyTitleLayout.hide()
- moreMenuSurveyNotif.hide()
- moreMenuSurveyCV.hide()
- marginMoreMenuSurvey.hide()
- }
-
-
- private func clearMoreMenuNotifData() {
- moreMenuOdsNotif.hide()
- moreMenuFotoLabelNotif.hide()
- moreMenuAplikasiNotif.hide()
- moreMenuSP2SertifikatNotif.hide()
- moreMenuSP2TambahanNotif.hide()
- moreMenuDaftarRhuNotif.hide()
- moreMenuSertifikatNotif.hide()
- moreMenuSurveyNotif.hide()
-
- for i in 0..<listMenuAplikasiODS.count {
- listMenuAplikasiODS[i].totalNotif = 0
- }
- for i in 0..<listMenuFotoLabel.count {
- listMenuFotoLabel[i].totalNotif = 0
- }
- for i in 0..<listMenuAplikasi.count {
- listMenuAplikasi[i].totalNotif = 0
- }
- for i in 0..<listMenuSP2Sertifikat.count {
- listMenuSP2Sertifikat[i].totalNotif = 0
- }
- for i in 0..<listMenuSP2Tambahan.count {
- listMenuSP2Tambahan[i].totalNotif = 0
- }
- for i in 0..<listMenuDaftarRHU.count {
- listMenuDaftarRHU[i].totalNotif = 0
- }
- for i in 0..<listMenuSertifikat.count {
- listMenuSertifikat[i].totalNotif = 0
- }
- for i in 0..<listMenuSurvey.count {
- listMenuSurvey[i].totalNotif = 0
- }
-
- moreMenuAplikasiODSCV.reloadData()
- moreMenuFotoLabelCV.reloadData()
- moreMenuAplikasiCV.reloadData()
- moreMenuSP2SertifikatCV.reloadData()
- moreMenuSP2TambahanCV.reloadData()
- moreMenuDaftarRHUCV.reloadData()
- moreMenuSertifikatCV.reloadData()
- moreMenuSurveyCV.reloadData()
- }
-
- private func setMoreMainMenu() {
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuUtamaCV.collectionViewLayout = flowLayout
- moreMenuUtamaCV.delegate = self
- moreMenuUtamaCV.dataSource = self
- moreMenuUtamaCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.moreMenuUtamaCellId)
- }
-
- private func setMoreMenuAplikasiODS(userRoleId: String) {
- // notif
- moreMenuOdsNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuAplikasiODSCV.collectionViewLayout = flowLayout
- moreMenuAplikasiODSCV.delegate = self
- moreMenuAplikasiODSCV.dataSource = self
- moreMenuAplikasiODSCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuAplikasiODSCellId)
-
- listMenuAplikasiODS = MenuListData.instance.getMenuAplikasiOdsData(userRoleId: userRoleId)
- if listMenuAplikasiODS.count > 0 {
- moreMenuAplikasiODSCV.reloadData()
- moreMenuAplikasiODSTitleLayout.show()
- moreMenuAplikasiODSCV.show()
- marginMoreMenuAplikasiODS.show()
- }
- }
-
- private func setMoreMenuFotoLabel(userRoleId: String) {
- // notif
- moreMenuFotoLabelNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuFotoLabelCV.collectionViewLayout = flowLayout
- moreMenuFotoLabelCV.delegate = self
- moreMenuFotoLabelCV.dataSource = self
- moreMenuFotoLabelCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuFotoLabelCellId)
-
- listMenuFotoLabel = MenuListData.instance.getMenuFotoLabelData(userRoleId: userRoleId)
- if listMenuFotoLabel.count > 0 {
- moreMenuFotoLabelCV.reloadData()
- moreMenuFotoLabelTitleLayout.show()
- moreMenuFotoLabelCV.show()
- marginMoreMenuFotoLabel.show()
- }
- }
-
- private func setMoreMenuAplikasi(userRoleId: String) {
- // notif
- moreMenuAplikasiNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuAplikasiCV.collectionViewLayout = flowLayout
- moreMenuAplikasiCV.delegate = self
- moreMenuAplikasiCV.dataSource = self
- moreMenuAplikasiCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuAplikasiCellId)
-
- listMenuAplikasi = MenuListData.instance.getMenuAplikasiData(userRoleId: userRoleId)
- if listMenuAplikasi.count > 0 {
- moreMenuAplikasiCV.reloadData()
- moreMenuAplikasiTitleLayout.show()
- moreMenuAplikasiCV.show()
- marginMoreMenuAplikasi.show()
- }
- }
-
- private func setMoreMenuSP2Sertifikat(userRoleId: String) {
- // notif
- moreMenuSP2SertifikatNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuSP2SertifikatCV.collectionViewLayout = flowLayout
- moreMenuSP2SertifikatCV.delegate = self
- moreMenuSP2SertifikatCV.dataSource = self
- moreMenuSP2SertifikatCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSP2SertifikatCellId)
-
- listMenuSP2Sertifikat = MenuListData.instance.getMenuSP2SertifikatData(userRoleId: userRoleId)
- if listMenuSP2Sertifikat.count > 0 {
- moreMenuSP2SertifikatCV.reloadData()
- moreMenuSP2SertifikatTitleLayout.show()
- moreMenuSP2SertifikatCV.show()
- marginMoreMenuSP2Sertifikat.show()
- }
- }
-
- private func setMoreMenuSP2Tambahan(userRoleId: String) {
- // notif
- moreMenuSP2TambahanNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuSP2TambahanCV.collectionViewLayout = flowLayout
- moreMenuSP2TambahanCV.delegate = self
- moreMenuSP2TambahanCV.dataSource = self
- moreMenuSP2TambahanCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSP2TambahanCellId)
-
- listMenuSP2Tambahan = MenuListData.instance.getMenuSP2TambahanData(userRoleId: userRoleId)
- if listMenuSP2Tambahan.count > 0 {
- moreMenuSP2TambahanCV.reloadData()
- moreMenuSP2TambahanTItleLayout.show()
- moreMenuSP2TambahanCV.show()
- marginMoreMenuSP2Tambahan.show()
- }
- }
-
- private func setMoreMenuDaftarRHU(userRoleId: String) {
- // notif
- moreMenuDaftarRhuNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuDaftarRHUCV.collectionViewLayout = flowLayout
- moreMenuDaftarRHUCV.delegate = self
- moreMenuDaftarRHUCV.dataSource = self
- moreMenuDaftarRHUCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuDaftarRhuCellId)
-
- listMenuDaftarRHU = MenuListData.instance.getMenuDaftarRhuData(userRoleId: userRoleId)
- if listMenuDaftarRHU.count > 0 {
- moreMenuDaftarRHUCV.reloadData()
- moreMenuDaftarRHUTitleLayout.show()
- moreMenuDaftarRHUCV.show()
- marginMoreMenuDaftarRHU.show()
- }
- }
-
- private func setMoreMenuSertifikat(userRoleId: String) {
- // notif
- moreMenuSertifikatNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuSertifikatCV.collectionViewLayout = flowLayout
- moreMenuSertifikatCV.delegate = self
- moreMenuSertifikatCV.dataSource = self
- moreMenuSertifikatCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSertifikatCellId)
-
- listMenuSertifikat = MenuListData.instance.getMenuSertifikatData(userRoleId: userRoleId)
- if listMenuSertifikat.count > 0 {
- moreMenuSertifikatCV.reloadData()
- moreMenuSertifikatTitleLayout.show()
- moreMenuSertifikatCV.show()
- marginMoreMenuSertifikat.show()
- }
- }
-
- private func setMoreMenuSurvey(userRoleId: String) {
- // notif
- moreMenuSurveyNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuSurveyCV.collectionViewLayout = flowLayout
- moreMenuSurveyCV.delegate = self
- moreMenuSurveyCV.dataSource = self
- moreMenuSurveyCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuSurveyCellId)
-
- listMenuSurvey = MenuListData.instance.getMenuSurveyData(userRoleId: userRoleId)
- if listMenuSurvey.count > 0 {
- moreMenuSurveyCV.reloadData()
- moreMenuSurveyTitleLayout.show()
- moreMenuSurveyCV.show()
- marginMoreMenuSurvey.show()
- }
- }
-
- private func setMoreMenuUtamaNew(userRoleId: String) {
- // notif
- moreMenuNewNotif.layer.cornerRadius = 5
- // menus
- let flowLayout = UICollectionViewFlowLayout()
- flowLayout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
- flowLayout.itemSize = CGSize(width: menuItemSize, height: menuItemSize)
- flowLayout.minimumInteritemSpacing = 0
- flowLayout.minimumLineSpacing = 0
- moreMenuUtamaNewCV.collectionViewLayout = flowLayout
- moreMenuUtamaNewCV.delegate = self
- moreMenuUtamaNewCV.dataSource = self
- moreMenuUtamaNewCV.register(MenuCell.self, forCellWithReuseIdentifier: MenuListData.instance.menuUtamaCellNewId)
-
- listMenuUtamaNew = MenuListData.instance.getMenuUtamaNewData(userRoleId: userRoleId)
- if listMenuUtamaNew.count > 0 {
- moreMenuUtamaNewCV.reloadData()
- moreMenuNewTitleLayout.show()
- moreMenuUtamaNewCV.show()
- marginMoreMenuUtamaNew.show()
- }
- }
-
- // IB Actions
- @IBAction func unwindToHome(segue: UIStoryboardSegue) {}
-
- @IBAction func onBtnMoreMenuTapped(_ sender: Any) {
- self.showMoreMenu()
-
- if !loading {
- let userRoleId = UserState.instance.getRoleId()
- if !userRoleId.isEmpty {
- clearMoreMenuNotifData()
-
- if ConnectionHelper.isConnectedToNetwork() {
- self.presenter.loadMenuNotifications()
- } else {
- CommonHelper.showNoConnection(in: self)
- }
- }
- }
- }
-
- @IBAction func dismissMoreMenuLayout(_ sender: Any) {
- self.hideMoreMenu()
- }
-
- @IBAction func onBtnMoreNewsTap(_ sender: Any) {
- if !loading {
- performSegue(withIdentifier: "NewsSegueId", sender: self)
- }
- }
-
- @objc func openNotifList(sender : UITapGestureRecognizer) {
- performSegue(withIdentifier: "NotifListSegueId", sender: self)
- }
-
- public func openNotifListPage() {
- performSegue(withIdentifier: "NotifListSegueId", sender: self)
- }
-
- }
- // HomeViewDelegate
- extension HomeVC: HomeViewDelegate {
- func showLoading() {
- loading = true
- progress.startAnimating()
- progressLayout.show()
- }
-
- func hideLoading() {
- loading = false
- progress.stopAnimating()
- progressLayout.hide()
- }
-
- func setTotalUnreadNotif(totalUnreadNotif: Int) {
- if totalUnreadNotif > 0 {
- lblNotif.text = String(totalUnreadNotif)
- notifBg.show()
- } else {
- lblNotif.text = ""
- notifBg.hide()
- }
- }
-
- func setSlideshowImages(images: [String]) {
- if !images.isEmpty {
- var sources = [SDWebImageSource]()
- for url in images {
- if let encodedURLString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
- let webpSource = SDWebImageSource(urlString: encodedURLString) {
- sources.append(webpSource)
- }
- }
-
- self.slideshow.slideshowInterval = 2.0
- self.slideshow.pageIndicatorPosition = .init(horizontal: .center, vertical: .under)
- self.slideshow.contentScaleMode = UIView.ContentMode.scaleAspectFill
-
- let pageControl = UIPageControl()
- pageControl.currentPageIndicatorTintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
- pageControl.pageIndicatorTintColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
- self.slideshow.pageIndicator = pageControl
- self.slideshow.setImageInputs(sources)
- }
- }
-
- func setNews(listNews: [News]) {
- if listNews.count > 0 {
- homeNewsTV.beginUpdates()
- for news in listNews {
- self.listNews.append(news)
- homeNewsTV.insertRows(
- at: [IndexPath(row: self.listNews.count-1, section: 0)],
- with: .automatic
- )
- }
- homeNewsTV.endUpdates()
- homeNewsTV.reloadData()
- }
- }
-
- func setMenuNotifications(menuNotification: MenuNotification) {
- let userRoleId = UserState.instance.getRoleId()
-
- if userRoleId == CUSTOMER_ROLE_ID {
-
- if listMenuSP2Sertifikat.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_sp2_sertifikat
- if (totalNotif > 0) {
- lblMoreMenuSP2SertifikatNotif.text = "\(totalNotif)"
- moreMenuSP2SertifikatNotif.show()
- } else {
- moreMenuSP2SertifikatNotif.hide()
- }
- // sp2 sertifikat
- listMenuSP2Sertifikat[0].totalNotif = menuNotification.tot_sp2_sertifikat
- moreMenuSP2SertifikatCV.reloadData()
- }
-
- if listMenuSP2Tambahan.count > 0 {
- // total notif
- let tot_ods = menuNotification.tot_sp2_tambahan
- if (tot_ods > 0) {
- lblMoreMenuSP2TambahanNotif.text = "\(tot_ods)"
- moreMenuSP2TambahanNotif.show()
- } else {
- moreMenuSP2TambahanNotif.hide()
- }
- // sp2 tambahan
- listMenuSP2Tambahan[0].totalNotif = menuNotification.tot_sp2_tambahan
- moreMenuSP2TambahanCV.reloadData()
- }
-
- if listMenuSertifikat.count > 0 {
- // total
- let tot_ods = menuNotification.tot_sertifikat
- if (tot_ods > 0) {
- lblMoreMenuSertifikatNotif.text = "\(tot_ods)"
- moreMenuSertifikatNotif.show()
- } else {
- moreMenuSertifikatNotif.hide()
- }
- // sert sementara
- listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
- // sert berlaku
- listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
- moreMenuSertifikatCV.reloadData()
- }
-
- } else if userRoleId == OPERATOR_ROLE_ID {
-
- if listMenuAplikasiODS.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_ods
- if (totalNotif > 0) {
- lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
- moreMenuOdsNotif.show()
- } else {
- moreMenuOdsNotif.hide()
- }
- // ods sp2 baru
- listMenuAplikasiODS[1].totalNotif = menuNotification.cnt_ods_sp2baru
- // ods sp2 otirisasi
- listMenuAplikasiODS[2].totalNotif = menuNotification.cnt_ods_sp2otorisasi
- moreMenuAplikasiODSCV.reloadData()
- }
-
- if listMenuSertifikat.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_sertifikat
- if (totalNotif > 0) {
- lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
- moreMenuSertifikatNotif.show()
- } else {
- moreMenuSertifikatNotif.hide()
- }
- // sert sementara
- listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
- // sert berlaku
- listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
- moreMenuSertifikatCV.reloadData()
- }
-
- } else if userRoleId == KEPALA_SEKSI_ROLE_ID {
-
- if listMenuAplikasiODS.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_ods
- if (totalNotif > 0) {
- lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
- moreMenuOdsNotif.show()
- } else {
- moreMenuOdsNotif.hide()
- }
- // ods sp2 otorisasi
- listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
- //sp2 before
- listMenuAplikasiODS[1].totalNotif = menuNotification.cnt_ods_sp2before
- //sp2 after
- listMenuAplikasiODS[2].totalNotif = menuNotification.cnt_ods_sp2after
- moreMenuAplikasiODSCV.reloadData()
- }
-
- if listMenuSertifikat.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_sertifikat
- if (totalNotif > 0) {
- lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
- moreMenuSertifikatNotif.show()
- } else {
- moreMenuSertifikatNotif.hide()
- }
- // sert sementara
- listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
- // sert berlaku
- listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
- moreMenuSertifikatCV.reloadData()
- }
-
- } else if userRoleId == KEPALA_SUB_DIREKTORAT_ROLE_ID {
-
- if listMenuAplikasiODS.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_ods
- if (totalNotif > 0) {
- lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
- moreMenuOdsNotif.show()
- } else {
- moreMenuOdsNotif.hide()
- }
- // ods sp2 otorisasi
- listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
- moreMenuAplikasiODSCV.reloadData()
- }
-
- if listMenuSertifikat.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_sertifikat
- if (totalNotif > 0) {
- lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
- moreMenuSertifikatNotif.show()
- } else {
- moreMenuSertifikatNotif.hide()
- }
- // sert sementara
- listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
- // sert berlaku
- listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
- moreMenuSertifikatCV.reloadData()
- }
-
- } else if userRoleId == DIREKTUR_ROLE_ID {
-
- if listMenuAplikasiODS.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_ods
- if (totalNotif > 0) {
- lblMoreMenuAplikasiODSNotif.text = "\(totalNotif)"
- moreMenuOdsNotif.show()
- } else {
- moreMenuOdsNotif.hide()
- }
- // ods sp2 otorisasi
- listMenuAplikasiODS[0].totalNotif = menuNotification.cnt_ods_sp2otorisasi
- moreMenuAplikasiODSCV.reloadData()
- }
-
- if listMenuSertifikat.count > 0 {
- // total notif
- let totalNotif = menuNotification.tot_sertifikat
- if (totalNotif > 0) {
- lblMoreMenuSertifikatNotif.text = "\(totalNotif)"
- moreMenuSertifikatNotif.show()
- } else {
- moreMenuSertifikatNotif.hide()
- }
- // sert sementara
- listMenuSertifikat[0].totalNotif = menuNotification.cnt_sertifikatsementara
- // sert berlaku
- listMenuSertifikat[1].totalNotif = menuNotification.cnt_sertifikatberlaku
- moreMenuSertifikatCV.reloadData()
- }
-
- }
- }
- }
- // CollectionView functions
- extension HomeVC : UICollectionViewDelegate, UICollectionViewDataSource {
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- if collectionView == self.moreMenuUtamaNewCV {
- return listMenuUtamaNew.count
- }
- else if collectionView == self.mainMenuCV {
- return listMenuUtama.count
- } else if collectionView == self.moreMenuUtamaCV {
- return listMenuUtama.count
- } else if collectionView == self.moreMenuAplikasiODSCV {
- return listMenuAplikasiODS.count
- } else if collectionView == self.moreMenuFotoLabelCV {
- return listMenuFotoLabel.count
- } else if collectionView == self.moreMenuAplikasiCV {
- return listMenuAplikasi.count
- } else if collectionView == self.moreMenuSP2SertifikatCV {
- return listMenuSP2Sertifikat.count
- } else if collectionView == self.moreMenuSP2TambahanCV {
- return listMenuSP2Tambahan.count
- } else if collectionView == self.moreMenuDaftarRHUCV {
- return listMenuDaftarRHU.count
- } else if collectionView == self.moreMenuSertifikatCV {
- return listMenuSertifikat.count
- } else if collectionView == self.moreMenuSurveyCV {
- return listMenuSurvey.count
- } else {
- return 0
- }
- }
-
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-
- if collectionView == self.moreMenuUtamaNewCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuUtamaCellNewId, for: indexPath) as? MenuCell {
- let menu = listMenuUtamaNew[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
-
- } else if collectionView == self.mainMenuCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuUtamaCellId, for: indexPath) as? MenuCell {
- let menu = listMenuUtama[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuUtamaCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.moreMenuUtamaCellId, for: indexPath) as? MenuCell {
- let menu = listMenuUtama[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuAplikasiODSCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuAplikasiODSCellId, for: indexPath) as? MenuCell {
- let menu = listMenuAplikasiODS[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuFotoLabelCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuFotoLabelCellId, for: indexPath) as? MenuCell {
- let menu = listMenuFotoLabel[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuAplikasiCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuAplikasiCellId, for: indexPath) as? MenuCell {
- let menu = listMenuAplikasi[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuSP2SertifikatCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSP2SertifikatCellId, for: indexPath) as? MenuCell {
- let menu = listMenuSP2Sertifikat[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuSP2TambahanCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSP2TambahanCellId, for: indexPath) as? MenuCell {
- let menu = listMenuSP2Tambahan[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuDaftarRHUCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuDaftarRhuCellId, for: indexPath) as? MenuCell {
- let menu = listMenuDaftarRHU[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuSertifikatCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSertifikatCellId, for: indexPath) as? MenuCell {
- let menu = listMenuSertifikat[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else if collectionView == self.moreMenuSurveyCV {
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuListData.instance.menuSurveyCellId, for: indexPath) as? MenuCell {
- let menu = listMenuSurvey[indexPath.row]
- cell.updateViews(menu: menu)
- return cell
- } else {
- return MenuCell()
- }
- } else {
- return MenuCell()
- }
- }
-
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
- var segueId = ""
- if collectionView == self.moreMenuUtamaNewCV {
- segueId = listMenuUtamaNew[indexPath.row].segueId
- } else if collectionView == self.mainMenuCV {
- segueId = listMenuUtama[indexPath.row].segueId
- } else if collectionView == self.moreMenuUtamaCV {
- segueId = listMenuUtama[indexPath.row].segueId
- } else if collectionView == self.moreMenuAplikasiODSCV {
- segueId = listMenuAplikasiODS[indexPath.row].segueId
- } else if collectionView == self.moreMenuFotoLabelCV {
- segueId = listMenuFotoLabel[indexPath.row].segueId
- } else if collectionView == self.moreMenuAplikasiCV {
- segueId = listMenuAplikasi[indexPath.row].segueId
- } else if collectionView == self.moreMenuSP2SertifikatCV {
- segueId = listMenuSP2Sertifikat[indexPath.row].segueId
- } else if collectionView == self.moreMenuSP2TambahanCV {
- segueId = listMenuSP2Tambahan[indexPath.row].segueId
- } else if collectionView == self.moreMenuDaftarRHUCV {
- segueId = listMenuDaftarRHU[indexPath.row].segueId
- } else if collectionView == self.moreMenuSertifikatCV {
- segueId = listMenuSertifikat[indexPath.row].segueId
- } else if collectionView == self.moreMenuSurveyCV {
- segueId = listMenuSurvey[indexPath.row].segueId
- }
-
- if !segueId.isEmpty {
- if !loading {
- performSegue(withIdentifier: segueId, sender: self)
- }
- }
- }
- }
- // UITableController Protocols
- extension HomeVC: UITableViewDelegate, UITableViewDataSource {
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return listNews.count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- if tableView == homeNewsTV {
- if let cell = tableView.dequeueReusableCell(withIdentifier: homeNewsCellId, for: indexPath) as? HomeNewsCell {
-
- let news = listNews[indexPath.row]
- cell.updateViews(news: news)
-
- return cell
- } else {
- return HomeNewsCell()
- }
- } else {
- return HomeNewsCell()
- }
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- let selectedNews = self.listNews[indexPath.row]
- self.selectedNewsId = selectedNews.id
- self.date = selectedNews.dateNew()
- self.judul = selectedNews.title_news
- self.urlThumb = selectedNews.thumb_filename
- performSegue(withIdentifier: "homeToNewsDetailSegueId", sender: self)
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 140
- }
- }
|