Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
4.2 kB
1
Indexable
Never
        NotificationCenter.default.addObserver(self, selector: #selector(self.navigateToReferralPageAlert), name: Notification.Name.Navigation.referralDetailAlert, object: nil)

        NotificationCenter.default.addObserver(self, selector: #selector(self.removeCoachmark), name: Notification.Name.Coachmark.removeCoachmark, object: nil)

    @objc private func navigateToReferralPageAlert(){
        self.modalHeight = 0.69
        self.minimumModalHeight = 565
        let vc = BlockerReferralModalViewController()
        vc.transitioningDelegate = self
        vc.modalPresentationStyle = .custom
        self.navigationController?.present(vc, animated: true)
    }

    @objc private func removeCoachmark(){
        self.checkCoachmark()
    }

    @objc private func resizeCoachmarkView() {
        self.homeTableView.beginUpdates()
        self.homeTableView.endUpdates()
    }
    

    
    private func navigateToAlbumPlaylist(data: MediaViewModel, playOnReady: Bool = false, sourcePage: String? = nil) {
        if let vc = UIStoryboard(storyboard: .AlbumPlaylist).instantiateViewController(withIdentifier: "AlbumViewController") as? AlbumViewController {
            vc.mediaData = data
            vc.playOnReady = playOnReady
            vc.sourcePage = sourcePage != nil ? sourcePage : data.title
            if StorageService.shared.getActiveIfb(){
                vc.sourcePage = "\(StorageService.shared.getActiveSegmentedHome() == 1 ? "Company" : "Personal") - \(vc.sourcePage)"
            }
            
            if sourcePage == PageSource.shared.lanjutDengarkan() || sourcePage == PageSource.shared.savedPodcast() {
                MoEngageAnalytic.shared.trackAlbum(type: data.type == "album" ? .album : .playlist, title: data.title, speakerName: data.artist?.name, albumType: data.privilege, source: sourcePage)
            } else {
                
                if sourcePage != nil {
                    MoEngageAnalytic.shared.trackAlbum(type: data.type == "album" ? .album : .playlist, title: data.title, speakerName: data.artist?.name, albumType: data.privilege, source: PageSource.shared.viewAllSource(page: data.title, source: sourcePage))
                }
            }
            if let nav = self.navigationController {
                nav.navigationBar.isHidden = false
                nav.pushViewController(vc, animated: true)
            }
        }
    }

    fileprivate func openBrowser(url: URL, navigation: UINavigationController) {
        self.browserURL = url
        let webViewController = WebViewController(url: url)
        let logo = UIImage(named: "webLogo")
        let imageView = UIImageView(image:logo)
        imageView.contentMode = .scaleAspectFit
        webViewController.navigationItem.titleView = imageView
        webViewController.navigationItem.titleView?.frame.size = CGSize(width: 40, height: 8.44)
        webViewController.navigationController?.navigationBar.isHidden = false
        webViewController.hidesBottomBarWhenPushed = true
        
//        webViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
//                                                                             target: self,
//                                                                             action: #selector(self.dismissController))
        webViewController.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(self.openWebBrowser))
        webViewController.navigationController?.setNavigationBarHidden(false, animated: false)
//        let navController = UINavigationController(rootViewController: webViewController)
        navigation.pushViewController(webViewController, animated: true)
//        navController.navigationBar.tintColor = .midnight
//        present(navController, animated: true)
    }

    private func openBadge(_ payload: InspigoMessagingDataModel) {
        if payload.id != nil {
            if StorageService.shared.getAccessToken() != "" {
                NotificationCenter.default.post(name: Notification.Name.Navigation.openBadgePopUp, object: nil, userInfo: ["payload": payload])
            }
        }
    }