Moving PlayAudioBehavior to MobileFirst
This commit is contained in:
parent
aaef3ea224
commit
edbe68429b
@ -61,7 +61,6 @@
|
||||
01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; };
|
||||
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; };
|
||||
01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03123A4498200D954D8 /* CaretLinkModel.swift */; };
|
||||
0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */; };
|
||||
0A0FEC7425D42A5E00AF2548 /* BaseItemPickerEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */; };
|
||||
0A0FEC7825D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */; };
|
||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; };
|
||||
@ -625,7 +624,6 @@
|
||||
01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = "<group>"; };
|
||||
01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = "<group>"; };
|
||||
01F2A03123A4498200D954D8 /* CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretLinkModel.swift; sourceTree = "<group>"; };
|
||||
0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayAudioBehavior.swift; sourceTree = "<group>"; };
|
||||
0A0FEC7325D42A5E00AF2548 /* BaseItemPickerEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryField.swift; sourceTree = "<group>"; };
|
||||
0A0FEC7725D42A8500AF2548 /* BaseItemPickerEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemPickerEntryFieldModel.swift; sourceTree = "<group>"; };
|
||||
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
|
||||
@ -1319,7 +1317,6 @@
|
||||
0A1C30972620F61A00B47F3B /* Protocols */,
|
||||
27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */,
|
||||
D23A900826125FFB007E14CE /* GetContactBehavior.swift */,
|
||||
0A01DE262626236300C2CAAC /* PlayAudioBehavior.swift */,
|
||||
);
|
||||
path = Behaviors;
|
||||
sourceTree = "<group>";
|
||||
@ -2886,7 +2883,6 @@
|
||||
D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */,
|
||||
0AE14F64238315D2005417F8 /* TextField.swift in Sources */,
|
||||
0A51F3E22475CB73002E08B6 /* LoadingSpinnerModel.swift in Sources */,
|
||||
0A01DE272626236300C2CAAC /* PlayAudioBehavior.swift in Sources */,
|
||||
D2169303251E53D9002A6324 /* SectionListTemplateModel.swift in Sources */,
|
||||
0AB764D124460F6300E7FE72 /* UIDatePicker+Extension.swift in Sources */,
|
||||
BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */,
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
//
|
||||
// PlayAudioBehavior.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Kevin Christiano on 4/9/21.
|
||||
// Copyright © 2021 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
public protocol PagePlayAudioBehaviorConsumerProtocol {
|
||||
func togglePlayPause()
|
||||
func play()
|
||||
func pause()
|
||||
func stop()
|
||||
var isPlaying: Bool { get }
|
||||
var messageID: String? { get }
|
||||
var audioFileURL: URL? { get set }
|
||||
}
|
||||
|
||||
public class PagePlayAudioBehaviorModel: PageBehaviorModelProtocol {
|
||||
public class var identifier: String { "pagePlayAudioBehavior" }
|
||||
public var shouldAllowMultipleInstances: Bool { false }
|
||||
|
||||
public init() { }
|
||||
}
|
||||
|
||||
public class PagePlayAudioBehavior: PageCustomActionHandlerBehavior, PageVisibilityBehavior {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Active Model
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var activeAudioPlayerDelegate: PagePlayAudioBehaviorConsumerProtocol?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Delegate
|
||||
//--------------------------------------------------
|
||||
|
||||
weak var delegate: MVMCoreUIDelegateObject?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Init
|
||||
//--------------------------------------------------
|
||||
|
||||
public required init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) {
|
||||
self.delegate = delegateObject
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Custom Action
|
||||
//--------------------------------------------------
|
||||
|
||||
// Either play or pause
|
||||
public func handleAction(type actionType: String?, information: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) -> Bool {
|
||||
|
||||
guard actionType == "playAudio" else { return false }
|
||||
|
||||
// Update the model. play -> pause OR pause -> play
|
||||
if Self.activeAudioPlayerDelegate?.isPlaying ?? false {
|
||||
Self.activeAudioPlayerDelegate?.pause()
|
||||
} else {
|
||||
Self.activeAudioPlayerDelegate?.play()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - PageVisibilityBehavior
|
||||
//--------------------------------------------------
|
||||
|
||||
public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) { }
|
||||
|
||||
public func onPageHidden(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||
//Stop player
|
||||
Self.activeAudioPlayerDelegate?.pause()
|
||||
}
|
||||
}
|
||||
@ -222,7 +222,6 @@ open class CoreUIModelMapping: ModelMapping {
|
||||
open class func registerBehaviors() {
|
||||
ModelRegistry.register(handler: ScreenBrightnessModifierBehavior.self, for: ScreenBrightnessModifierBehaviorModel.self)
|
||||
ModelRegistry.register(handler: PageGetContactBehavior.self, for: PageGetContactBehaviorModel.self)
|
||||
ModelRegistry.register(handler: PagePlayAudioBehavior.self, for: PagePlayAudioBehaviorModel.self)
|
||||
}
|
||||
|
||||
open override class func registerActions() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user