From 4bb6e5aefd3c127dffcfe7e8b6161832c728ddc2 Mon Sep 17 00:00:00 2001 From: Daniel Ornelas Date: Wed, 23 May 2018 14:08:30 -0500 Subject: [PATCH] Implement a delegate of PiPViewCoordinator to notify when user exits Picture in Picture mode --- ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift b/ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift index 173675193..e93544098 100644 --- a/ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift +++ b/ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift @@ -16,6 +16,11 @@ public typealias AnimationCompletion = (Bool) -> Void +public protocol PiPViewCoordinatorDelegate: class { + + func exitPictureInPicture() +} + /// Coordinates the view state of a specified view to allow /// to be presented in full screen or in a custom Picture in Picture mode. /// This object will also provide the drag and tap interactions of the view @@ -44,6 +49,8 @@ public class PiPViewCoordinator { return 0.25 } }() + + public weak var delegate: PiPViewCoordinatorDelegate? private(set) var isInPiP: Bool = false // true if view is in PiP mode @@ -127,6 +134,8 @@ public class PiPViewCoordinator { let exitSelector = #selector(toggleExitPiP) tapGestureRecognizer?.removeTarget(self, action: exitSelector) tapGestureRecognizer = nil + + delegate?.exitPictureInPicture() } /// Reset view to provide bounds, use this method on rotation or