one video behavior

This commit is contained in:
Pfeil, Scott Robert 2021-03-29 17:19:23 -04:00
parent 4a5f35820c
commit 7a689ea7eb
4 changed files with 9 additions and 54 deletions

View File

@ -350,8 +350,6 @@
D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; };
D23A8FEB26122F69007E14CE /* VisibleBehaviorForVideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FEA26122F69007E14CE /* VisibleBehaviorForVideoModel.swift */; };
D23A8FEE26122F7D007E14CE /* VisibleBehaviorForVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FED26122F7D007E14CE /* VisibleBehaviorForVideo.swift */; };
D23A8FF126122FAE007E14CE /* ScrollBehaviorForVideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FF026122FAE007E14CE /* ScrollBehaviorForVideoModel.swift */; };
D23A8FF426122FD8007E14CE /* ScrollBehaviorForVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FF326122FD8007E14CE /* ScrollBehaviorForVideo.swift */; };
D23A8FF82612308D007E14CE /* PageBehaviorProtocolRequirer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */; };
D23A8FFB26123189007E14CE /* PageBehaviorModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FFA26123189007E14CE /* PageBehaviorModelProtocol.swift */; };
D23A90002612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23A8FFF2612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift */; };
@ -915,8 +913,6 @@
D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = "<group>"; };
D23A8FEA26122F69007E14CE /* VisibleBehaviorForVideoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibleBehaviorForVideoModel.swift; sourceTree = "<group>"; };
D23A8FED26122F7D007E14CE /* VisibleBehaviorForVideo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibleBehaviorForVideo.swift; sourceTree = "<group>"; };
D23A8FF026122FAE007E14CE /* ScrollBehaviorForVideoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollBehaviorForVideoModel.swift; sourceTree = "<group>"; };
D23A8FF326122FD8007E14CE /* ScrollBehaviorForVideo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollBehaviorForVideo.swift; sourceTree = "<group>"; };
D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageBehaviorProtocolRequirer.swift; sourceTree = "<group>"; };
D23A8FFA26123189007E14CE /* PageBehaviorModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageBehaviorModelProtocol.swift; sourceTree = "<group>"; };
D23A8FFF2612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageBehaviorHandlerModelProtocol.swift; sourceTree = "<group>"; };
@ -1733,8 +1729,6 @@
D29C558F25C095210082E7D6 /* Video.swift */,
D23A8FEA26122F69007E14CE /* VisibleBehaviorForVideoModel.swift */,
D23A8FED26122F7D007E14CE /* VisibleBehaviorForVideo.swift */,
D23A8FF026122FAE007E14CE /* ScrollBehaviorForVideoModel.swift */,
D23A8FF326122FD8007E14CE /* ScrollBehaviorForVideo.swift */,
);
path = Video;
sourceTree = "<group>";
@ -2671,7 +2665,6 @@
D2ED27ED254B0CE700A1C293 /* ActionPopupModel.swift in Sources */,
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */,
943820842432382400B43AF3 /* WebView.swift in Sources */,
D23A8FF126122FAE007E14CE /* ScrollBehaviorForVideoModel.swift in Sources */,
0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */,
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
0A25209624645AFD000FA9F6 /* TextViewEntryField.swift in Sources */,
@ -2771,7 +2764,6 @@
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */,
D2874024249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift in Sources */,
01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */,
D23A8FF426122FD8007E14CE /* ScrollBehaviorForVideo.swift in Sources */,
0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */,
011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */,
D22479962316AF6E003FCCF9 /* HeadlineBodyLink.swift in Sources */,

View File

@ -1,25 +0,0 @@
//
// ScrollBehaviorForVideo.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/29/21.
// Copyright © 2021 Verizon Wireless. All rights reserved.
//
import Foundation
open class ScrollBehaviorForVideo: PageScrolledBehavior {
var model: PageBehaviorModelProtocol
required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
self.model = model
}
public func pageScrolled(scrollView: UIScrollView) {
// If visible to not visible, pause video.
// If not visible to visible, unpause if needed, add visible behavior
guard let model = (model as? VisibleBehaviorForVideoModel)?.videoModel,
let view = model.view else { return }
model.halted = !view.isVisible(in: scrollView)
}
}

View File

@ -1,20 +0,0 @@
//
// ScrollBehaviorForVideoModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/29/21.
// Copyright © 2021 Verizon Wireless. All rights reserved.
//
import Foundation
open class ScrollBehaviorForVideoModel: PageBehaviorModelProtocol {
public static var identifier: String = "visibleBehaviorForVideoModel"
public var shouldAllowMultipleInstances: Bool = true
public weak var videoModel: VideoModel?
init(with videoModel: VideoModel) {
self.videoModel = videoModel
}
}

View File

@ -8,7 +8,7 @@
import Foundation
open class VisibleBehaviorForVideo: PageVisibilityBehavior {
open class VisibleBehaviorForVideo: PageVisibilityBehavior, PageScrolledBehavior {
var model: PageBehaviorModelProtocol
required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
@ -25,4 +25,12 @@ open class VisibleBehaviorForVideo: PageVisibilityBehavior {
public func onPageHidden() {
(model as? VisibleBehaviorForVideoModel)?.videoModel?.halted = true
}
public func pageScrolled(scrollView: UIScrollView) {
// If visible to not visible, pause video.
// If not visible to visible, unpause if needed, add visible behavior
guard let model = (model as? VisibleBehaviorForVideoModel)?.videoModel,
let view = model.view else { return }
model.halted = !view.isVisible(in: scrollView)
}
}