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 (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Umer authored Sep 18, 2023
1 parent cb92fce commit 64990fd
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ 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

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

let environment : Environment
let blockID : CourseBlockID?
let courseQuerier : CourseOutlineQuerier
Expand Down
16 changes: 15 additions & 1 deletion Source/VideoTranscript.swift
Original file line number Diff line number Diff line change
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 64990fd

Please sign in to comment.