Grimbode Grimbode - 1 month ago
235 0

No description

Swift

methods didupdateonfocus

override func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {

        if let cell = context.nextFocusedView as? DetailTabelCell {
            print("called next focused.")
            setNextCell(next: cell)
        }
        
        if let previous = context.previouslyFocusedView as? DetailTabelCell {
            print("Called previous focused.")
            setPreviousCell(previous: previous)
        }

    }

    func setNextCell(next: DetailTabelCell){
        
        next.titleLabel.holdScrolling = false
        
        
        next.descriptionLabel.isHidden = false
        next.titleLabel.textColor = self.colorTheme
        next.contentView.backgroundColor = Constants.Color.backgroundFocusColor
        
        guard next.tag == self.videos.count-1 && pageService.canSeekMorePages() else {
            return
        }
        
        let newTime = Date()
        guard newTime.timeIntervalSince(self.currentTime) <= 1 else {
            print("Not enough time has passed.")
            return
        }
        
        self.currentTime = newTime.addingTimeInterval(1)
        updatePage()

    }
    
    func setPreviousCell(previous: DetailTabelCell){
        
        previous.titleLabel.holdScrolling = true
        previous.titleLabel.restartLabel()
        
        previous.titleLabel.textColor = .white
        previous.descriptionLabel.isHidden = true
        previous.contentView.backgroundColor = Constants.Color.backgroundcolor

    }