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

chore: handle header view in video block #1800

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Source/VideoBlockViewController.swift
Original file line number Diff line number Diff line change
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
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
Loading