Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
chore: handle header view in video block (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Sep 19, 2023
1 parent 9273560 commit c127244
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Source/VideoBlockViewController.swift
Expand Up @@ -10,7 +10,7 @@ import Foundation
import MediaPlayer
import UIKit

class VideoBlockViewController : OfflineSupportViewController, CourseBlockViewController, StatusBarOverriding, InterfaceOrientationOverriding, VideoTranscriptDelegate, RatingViewControllerDelegate, VideoPlayerDelegate {
class VideoBlockViewController : OfflineSupportViewController, CourseBlockViewController, StatusBarOverriding, InterfaceOrientationOverriding, VideoTranscriptDelegate, RatingViewControllerDelegate, VideoPlayerDelegate, ScrollableDelegateProvider {

typealias Environment = DataManagerProvider & OEXInterfaceProvider & ReachabilityProvider & OEXConfigProvider & OEXRouterProvider & OEXAnalyticsProvider & OEXStylesProvider & OEXSessionProvider & NetworkManagerProvider

Expand All @@ -32,6 +32,12 @@ class VideoBlockViewController : OfflineSupportViewController, CourseBlockViewCo
private var overlayLabel: UILabel?
var shouldCelebrationAppear: Bool

weak var scrollableDelegate: ScrollableDelegate? {
didSet {
videoTranscriptView?.scrollableDelegate = scrollableDelegate
}
}

init(environment : Environment, blockID : CourseBlockID?, courseID: String, shouldCelebrationAppear: Bool = false) {
self.blockID = blockID
self.environment = environment
Expand Down
16 changes: 15 additions & 1 deletion Source/VideoTranscript.swift
Expand Up @@ -12,10 +12,13 @@ protocol VideoTranscriptDelegate: AnyObject {
func didSelectSubtitleAtInterval(time: TimeInterval)
}

class VideoTranscript: NSObject, UITableViewDelegate, UITableViewDataSource{
class VideoTranscript: NSObject, UITableViewDelegate, UITableViewDataSource, ScrollableDelegateProvider {

typealias Environment = DataManagerProvider & OEXInterfaceProvider & ReachabilityProvider

weak var scrollableDelegate: ScrollableDelegate?
private var scrollByDragging = false

let transcriptTableView = UITableView(frame: CGRect.zero, style: .plain)
var transcripts = [TranscriptObject]()

Expand Down Expand Up @@ -68,7 +71,18 @@ class VideoTranscript: NSObject, UITableViewDelegate, UITableViewDataSource{
delegate?.didSelectSubtitleAtInterval(time: transcripts[indexPath.row].start)
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollByDragging {
scrollableDelegate?.scrollViewDidScroll(scrollView: scrollView)
}
}

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
scrollByDragging = false
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
scrollByDragging = true
isTableDragged = true
draggingTimer.invalidate()
draggingTimer = Timer.scheduledTimer(timeInterval: dragDelay, target: self, selector: #selector(invalidateDragging), userInfo: nil, repeats: false)
Expand Down

0 comments on commit c127244

Please sign in to comment.